This section explains, through an example scenario, how the Durable Subscriber EIP can be implemented using WSO2 ESB. The following topics are covered:
Table of Contents |
---|
...
Environment setup
- Download and install the WSO2 ESB from http://wso2.com/products/enterprise-service-bus. For a list of prerequisites and step-by-step installation instructions, refer to Getting Started Installation Guide in the WSO2 ESB documentation.
- Start three sample Axis2 server instances on ports 9000 and 9001. For instructions, refer to see Setting Up the section ESB Samples Setup - Starting Sample Back-End Servicesthe Axis2 server in the WSO2 ESB documentation.
ESB configuration
Start the ESB server and log into its management console UI (https:
//localhost:9443/carbon
). In the management console, navigate to the Main menu and click Source View in the Service Bus section. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view.
Anchor | ||||
---|---|---|---|---|
|
...
Simulating the sample scenario
Use a SOAP client like SoapUI to forward the following request to the PublishProxy service.
...
How the implementation works
Let 's us investigate the elements of the ESB configuration in detail. The line numbers below refer to the ESB configuration shown above.
- Proxy Service [line 6 in ESB config ] - A proxy service takes an incoming Stock Quote client request and clones the request by forwarding one copy each to two target sequences,
DurableSubscriber
andNonDurableSubscriber.
- Sequence [line 29 in ESB config] - The
DurableSubscriber
sequence forwards the message to the Durable Endpoint. This endpoint has theonError
attribute set to thesub1_fails
sequence (line 21 in ESB config), which will store the message in case of a failure. - Sequence [line 38 in ESB config] - The
NonDurableSubscriber
sequence works the same as the sequence described above. The only difference is that on failure, thesub2_fails
sequence (line 25 in ESB config) is called, which simply drops the message. - Sequence [line 21 in ESB config] - This sequence sets the
target.endpoint
property for theDurableEndpointSubscriber
endpoint (defined on line 48 in ESB config), and uses a Store Mediator to define the message store used to save the message. In this example, it is the store with keypending_subscription
. - messageStore [line 53 in ESB config] - Defines a new message store with the name
pending_subscriptions.
- messageProcessor [line 55 in ESB config] - The
messageProcessor
is used to define the type of processing done to a particularmessageStore
, which in this example ispending_subscription
. This example defines amessageProcessor
that uses aScheduledMessageForwardingProcessor
, which retries sending the messages every second with a maximum number of delivery attempts set to 50.