Sample 0107 - Load Balancing and Fail-Over Data Publisher
Introduction
This sample demonstrates how to set up an execution plan with a basic pass through query. It selects some attributes of each incoming event and gives an output event with the selected attributes. This sample uses wso2Event
for both inputs and outputs, but we send events to two databridge listening servers using LoadBalancing
data publisher.
The query used in this sample is as follows:
from InMediationStatsStream select meta_host, timestamp, resource_id, direction, fault_count, count insert into OutMediationStatsStream;
The above query,
- Processes the events received through
InMediationStatsStream
- From each event received, selects the attributes (meta_host, timestamp, resource_id, direction, fault_count, count) specified under the
select
clause - Gives output events through the
OutMediationStatsStream
. Because this query does no processing apart from selecting a few attributes, it can be considered as a pass-through query.Â
Prerequisites
See Prerequisites in CEP Samples Setup page.
Building the sample
Start the WSO2 CEP server with the sample configuration numbered 0107. For instructions, see Starting sample CEP configurations. This sample configuration does the following:
- Creates
<CEP_HOME>/repository/conf/data-bridge/stream-definitions.xml
file, which is used to create the stream definitions for the sample. - Points the default Axis2 repo to
<CEP_HOME>/sample/artifacts/0107
(by default, the Axis2 repo is<CEP_HOME>/repository/deployment/server
).
Executing the sample
Open a terminal, go to
<CEP_HOME>/samples/consumers/wso2-event
and run the command below:ant -Dport=7661
Again, open another terminal, go to
<CEP_HOME>/samples/consumers/wso2-event
and run the following command:ant -Dport=7662
Both steps build the sampleÂ
wso2event
consumer and execute it.Do not close these terminals. They are required to keep the servers running and receiving events.
Open another terminal, go to
<CEP_HOME>/samples/producers/mediation-stats
and run ant from there.
It builds and runs thewso2event
producer, which sends some mediation statistics data to the CEP server.From the terminal opened in step 3, see the events sent.
Note
To configure host, port, username, password and No. of events use -Dhost=xxxx -Dport=xxxx -Dusername=xxxx -Dpassword=xxxx -Devents=xx.
For example : ant -Devents=5
See the output events received from the CEP via the terminals opened in step  1 and 2.
For example, given below is the console output of the consumer when sending 5 events from the producer.ÂTerminal 1 with port 7661 - Output
Terminal 2 with port 7662 - Output
Note that the events are published according to round-robin algorithm to both data-bridge listening servers. For more information, see Setting up Multi Receiver and Load Balancing Data Agent.