Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The Event-Driven Consumer EIP allows an application to automatically consume messages as they become available. For more information, refer to http://www.eaipatterns.com/EventDrivenConsumer.html.

 

 

 

 

 






Figure 1: Event-Driven Consumer EIP 

...

Before digging into implementation details, let's take a look at the relationship between the example scenario and the Event-Driven Consumer EIP by comparing their core components.

Event-Driven Consumer EIP (Figure 1)Event-Driven Consumer Example Scenario (Figure 2)
SenderSimple Stock Quote Client
MessageSimple Stock Quote Request
Event Driven ConsumerEvent Mediator
ReceiverTopic Subscriber, Simple Stock Quote Service

Environment setup

  1. Download and install WSO2 ESB from http://wso2.com/products/enterprise-service-bus. For a list of prerequisites and step-by-step installation instructions, refer to Installation Guide in the WSO2 ESB documentation.
  2. Start two sample Axis2 server. For instructions, refer to the section section Setting Up the ESB Samples - Starting the Axis2 server in the WSO2 ESB documentation.
  3. Follow the steps below to create an event.
    • Start the ESB server and log into its management console UI (https: //localhost:9443/carbon ).
    • Select the Topics menu from the Main menu and then select the Add sub menu.
    • Enter EventConsumerTopic as the name for the topic, and then click Add Topic.
    • Click the newly created topic EventConsumerTopic in the topic browser tree and click Subscribe to create a static subscription.
    • Enter the value   http://localhost:9000/services/SimpleStockQuoteService in the Event Sink URL field and click Subscribe.

...

Code Block
languagehtml/xml
linenumberstrue
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://ws.apache.org/ns/synapse">
   <sequence name="fault">
      <log level="full">
         <property name="MESSAGE" value="Executing default &#34;fault&#34; sequence"/>
         <property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
         <property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
      </log>
      <drop/>
   </sequence>
   <sequence name="main">
      <log/>
      <event topic="EventConsumerTopic"/>
   </sequence>
</definitions>

...