Event Streams
Event Streams are another main part in WSO2 BAM 2.5.0. All the processing happens based on streams. Here, Event streams need to be defined as WSO2Event Stream Definition. All the created streams are stored in the registry (governance) of WSO2 BAM.
Don't try to edit streams definitions directly which are stored in registry. Because it may leads to unpredictable situations.
Creating Stream Definitions (Streams)
- Start WSO2 BAM server, log in to its management console, select Main -> Event Streams and click Add Event Stream.
- Enter details in the form that appears and click the Add Event Stream button at the end of the form. For example,
Here, fill the necessary fields according to the stream definition that you want to create. - Finally, Click the Add Event Stream button to add the stream definition to the registry. Then Available Event Stream page will open. To delete event stream, click the Delete button.
Once the event stream is added successfully, you will be asked if you want to create the event builder for the stream. You can use Default WSO2Event builder or chose to create a custom event builder by clicking OK. Or else you can create the event builder later by clicking "Create Later" .
To create an event builder, event formatter or execution plan it is mandatory to create necessary event streams before hand.
Other than the server UI, you can also define the stream definition using a config file which is in the <PRODUCT_HOME>/repository/conf/data-bridge/stream-
definitions.xml
file. But this file used to create streams only in the server start-up (This file is not hot deploy-able). Please see the below syntax
<streamDefinitions xmlns="http://wso2.org/carbon/databridge"> <streamDefinition> { "name":"FlightArrivalStatsStream", "version":"1.0.0", "payloadData":[ {"name":"flightName","type":"STRING"}, {"name":"flightId","type":"STRING"}, {"name":"flightType","type":"STRING"}, {"name":"arrivalTime","type":"STRING"}, {"name":"trackNo","type":"STRING"}, {"name":"status","type":"STRING"} ] } </streamDefinition> <streamDefinition> { "name":"delayedFlightStream", "version":"1.0.0", "payloadData":[ {"name":"flightName","type":"STRING"}, {"name":"flightId","type":"STRING"}, {"name":"flightType","type":"STRING"}, {"name":"arrivalTime","type":"STRING"}, {"name":"trackNo","type":"STRING"} ] } </streamDefinition> </streamDefinitions>
Event In-Flows and Out-Flows
Each event stream lets events to flow in or out of the processing engine. These in-flows and out-flows of events can be customized to have different formats and mappings. For the events flowing in, user can create an event builder to convert them from different formats and map them to a format acceptable by the event processor. For the events flowing out, event formatters are used to convert them to various formats.
To create an event builder or a formatter, select Event Streams under the Main menu. The Available Streams page that appears contains the existing streams and supported Actions. Under the actions, users can choose to create an event builder by selecting the In-Flows and then selecting Add Event Builder. Similarly, an event formatter can be added by clicking Out-Flows in Available Streams page.
A detailed guide on Event Builders and Formatters can be found in the following sections: