This section explains, through an example scenario, how the Event Message EIP can be implemented using the WSO2 ESB. The following topics are covered:
Introduction to Event Message
The Event Message EIP is used for reliable, asynchronous event notification between applications. For more information, see http://www.eaipatterns.com/EventMessage.html.
Figure 1: Event Message EIP
When a subject has an event to be announced, it will create an event object, wrap it in a message, and send it to a set of subscribers. This example scenario uses several Axis2 server instances as subscribers. When a message arrives in the ESB, it will be transmitted through the event mediator to each of these server instances that act as a subscriber.
The following diagram depicts how this example can be simulated using the ESB.
Figure 2: Example scenario of the Event Message EIP
Before digging into implementation details, let's take a look at the relationship between the example scenario and the Event Message EIP, by comparing their core components.
|Event Message EIP (Figure 1)||Event Message Example Scenario (Figure 2)|
|Subject||Stock Quote Client|
|Event Message||Event, Topic|
|Observer||Stock Quote Service|
The ESB configuration
Given below is the ESB configuration for simulating the example scenario explained above.
Simulating the example scenario
Now, let's try out the example scenario explained above.
Setting up the environment
You need to set up the ESB, and the back-end service:
- Download the
Event-Message_1.0.0.zipfile, which includes the ESB configuration described above.
See Setting up the Environment for instructions on setting up the ESB and the back-end service.
When you set up the environment, note that you need to start two instances of the back-end service (Stock Quote Service) to simulate this example.
- Follow the steps below to create an event for the subscriber with port 9000.
- Start the ESB and log into its Management Console. For instructions, see Starting the ESB in WSO2 ESB documentation.
- Click Topics from the Main menu, and then click Add.
stockquoteas the topic name and then click Add Topic.
- In the Topic browser, click the newly created
stockquotetopic and then click Subscribe to create a static subscription.
- Enter in the Event Sink URL field and click Subscribe.
- Repeat the above steps to add another subscriber in port 9001.
Executing the sample
Send the following message from a SOAP client like SoapUI:
Analyzing the output
Observe the two Axis2 server instances. Both instances will receive the request, which was sent from the client.
Ouput of both Axis Server consoles:
samples.services.SimpleStockQuoteService :: Generating quote for : foo
You don't get a response in the Soap Ui.