Event sinks contain information about transport endpoints provided by other systems. Events can be published to these endpoints. Endpoint transport and authentication URLs and credentials are captured in event sinks.
Adding an event sink
Follow the steps below to add an event sink.
- Open the ESB Management Console. On the Configure tab, click Event Sinks to open the Event Sinks Configuration page.
- Click Add Event Sink to open the Add Event Sink page.
Enter values for the following parameters.
Parameter Name Description Name The name of the event sink. Username The user name of the data-bridge endpoint. Password The password of the data-bridge endpoint. Receiver URL The URL of the data-bridge endpoint. For example,
Multiple endpoints can be specified for load balancing and multiple receiver modes, by using the correct URL format.
Authenticator URL The secure data-bridge endpoint URL that should be used for authentication. For example,
The URL specified here should match the specified Receiver URL parameter.
- Click Save.
Let's look at a sample where WSO2 ESB uses event sinks to publish mediation data to WSO2 Data Analytics Server (WSO2 DAS).
Setting up WSO2 Data Analytics Server
Download and install WSO2 DAS. For instructions on how to download and install WSO2 DAS, see Getting Started with WSO2 DAS.
The unzipped WSO2 DAS distribution folder will be referred to as
<DAS_HOME>throughout the documentation.
It is not possible to start multiple WSO2 products with their default configurations simultaneously in the same environment. Since all WSO2 products use the same port in their default configuration, there will be port conflicts. Therefore, to avoid port conflicts, apply a port offset in the
<DAS_HOME>/repository/conf/carbon.xmlfile by changing the offset value to 1 as follows:
- Open a command prompt and go to the
- Start WSO2 DAS by executing
sh wso2server.sh(on Linux/OS X) or
- Log in to the management console of WSO2 DAS server at https://localhost:9444/carbon/ using admin for the username and password.
Create an event stream in DAS by navigating to Main->Streams in the management console. Click on Add Event Stream and fill in the details as in the following table:
Field Value Event Stream Name stockquote_stream Event Stream Version 1.0.0
Add the Stream Attributes as in the following table:
Meta Data Attributes Attribute Name http_method Attribute Type string Attribute Name destination Attribute Type string Correlation Attributes Attribute Name date Attribute Type string Payload Data Attributes Attribute Name symbol Attribute Type string Attribute Name request Attribute Type string
Click Next[Persist Event].
- On the next page, select the check box Persist Event Stream and then select the attributes that need to be persisted by selecting the relevant check boxes. Select all attributes by selecting the check boxes Persist Attribute under Meta Data Attributes, Correlation Data Attributes and Payload Data Attributes. See WSO2 DAS documentation for details on persisting data.
Click Save Event Stream.
You need to add an Event Receiver in WSO2 DAS to receive events. In WSO2 DAS, navigate to Main->Receivers and click on Add Event Receiver and fill in the following information:
Field Value Event Receiver Name ESB_RECEIVER Input Event Adapter Type Select wso2event
Click Add Event Receiver.
Setting up WSO2 ESB
- If you have not already done so, see Getting Started with WSO2 ESB for details on installing and running WSO2 ESB.
- Log in to the management console at https://localhost:9443/carbon/ using admin for the username and password.
Create an event sink in WSO2 ESB by navigating to Configure ->Event Sinks in the management console. Click on Add Event Sink.
Fill in the details as in the following table:
Field Value Name das_event_sink Username admin Password admin Receiver URL tcp://localhost:7612 Authenticator URL ssl://localhost:7712
In WSO2 DAS the default thrift port and the authentication port are 7611 and 7711 respectively. Due to the port offset you configured the new ports are 7612 and 7712 as defined above.
Create a REST API by navigating to Main ->APIs in the management console and click on Add API. Fill in the details as in the table below:
Field Value API Name StockQuoteAPI context /stockquote
Click on Switch to source view.
In source view, add the following API configuration where the publish mediator uses the created event sink
das_event_sinkto publish to the event stream named
stockquote_streamthat we created in WSO2 DAS:
Deploy the back-end service
SimpleStockQuoteService. For instructions on deploying sample back-end services, see Deploying sample back-end services.
Start the Axis2 server. For instructions on starting the Axis2 server, see Starting the Axis2 server.
Open a command line terminal and enter the following request to invoke the API you defined above:
You will see the response from the SimpleStockQuoteService.
Exploring published data in WSO2 DAS
In WSO2 DAS navigate to Main->Data Explorer and select the table STOCKQUOTE_STREAM from the drop down list and click on Search. You can then view the data published from ESB in the table as follows: