Working with WSO2 ESB Event Sink and WSO2 DAS


In this post I am going to point out how to integrate WSO2 ESB and WSO2 DAS to send events from ESB to the DAS server. In order to achieve this I am going to use WSO2 ESB v4.9.0 and WSO2 DAS v 3.0.0.
In wso2 ESB you can publish events through publish event mediator and event sinks. In order to achieve our task first we need to create an event receiver and an event stream at the DAS end. Also we create an event sink at the ESB end, and use publish event mediator to publish our event to the DAS’s event receiver.

Creating an event stream
Log on to DAS server and navigate to streams section as follows.




You can add three types of attributes for the event. Payload data Attributes, Meta Data Attributes and correlation data attributes. In this post I am just using the payload data attributes only. Next persist the event stream.




Creating an Event Receiver
Now we need to create an event receiver to receive the events we send from the ESB end. click on the Receivers tab and you will be navigated to the following page. There you can select the desired event type from the available number of event types. In our scenario we are going to use the wso2event type. Also you select your desired event stream you created earlier.



Creating an Event Sink

Click on the Event Sink tab and you will be navigated to the following page. Fill the relevant data to create the Event Sink.


Give a name, the username, password and the receiver URL (tcp//:<host name>:7611). Save the event sink.


<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="ProxyEvent"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
    <target>
        <inSequence>
            <publishEvent>
                <eventSink>testSink</eventSink>
                <streamName>test</streamName>
                <streamVersion>1.0.0</streamVersion>
                <attributes>
                    <meta/>
                    <correlation/>
                    <payload>
                        <attribute name="atr1" type="STRING" defaultValue="" value="testValue"/>
                        <attribute name="atr2" type="STRING" defaultValue="" value="Test Region"/>
                    </payload>
                    <arbitrary/>
                </attributes>
            </publishEvent>
        </inSequence>
    </target>
    <description/>
</proxy>

Create a proxy as above. You can see that I have used the publishEvent mediator. You include the event sink name, stream name and the stream version. In the attributes you can see we include the metadata, correlation data and payload data.

Now hit the defined proxy and you can browse data in the DAS through the Data Explorer tab. Select the table and search. Then you can see the data we published through our event sink.

Comments

  1. Can I send full payload to DAS from ESB? Or I need to send each attribute?

    ReplyDelete
  2. Hi Gabriel,
    Yes. Instead of using value you can use expression="your_xpath_expression"

    ReplyDelete

Post a Comment

Popular posts from this blog

Enabling Custom SSL Profiles in WSO2 ESB 4.8.1

Using WSO2 ESB HTTP Endpoints to define Restful Endpoints

Integrating WSO2 ESB Connectors in real world integration Scenarios