WSO2 Complex Event Processor is succeeded by WSO2 Stream Processor. To view the latest documentation for WSO2 SP, see WSO2 Stream Processor Documentation.

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: remove un-relavant notes

...

  1. Set up the prerequisites required for all samples.
  2. Set up the two nodes (ignore the presenter node and backup node configurations for this sample) as mentioned in the configuring High Availability in CEP nodes sectionSummarised steps are as follows.

    1. Set the value of the <Offset> element of the <CEP_HOME>/repository/conf/carbon.xml file as shown below in Node2to start it with a port offset of 1. 

    2. In the <CEP_HOME>/repository/conf/axis2/axis2.xml file, enable clustering in wka mode on both nodes.

    3. In the <CEP_HOME>/repository/conf/event-processor.xml file, enable HA mode and configure both nodes to have separate <eventSync/> and <management/> host and port configs.

    4. Share the registry by adding the Node1's H2 database as the Node2's database.

Building the sample

Start both WSO2 CEP nodes with the sample configuration numbered 0503. For instructions, see Starting sample CEP configurations

This sample configuration creates the following.

  • Two streams with the IDs org.wso2.sample.pizza.orderStream:1.0.0 and org.wso2.sample.order.count:1.0.0
  • An event receiver named pizzaOrderReceiver
  • An event publisher named pizzaCountPublisher
  • An execution plan named PizzaOrdersExecutionPlan

Executing the sample

Follow the steps below to execute the sample.

  1. Navigate to the <CEP_HOME>/samples/cep/producers/http/ directory of any node, and execute the following Ant command using another tab in the CLI: 

    ant -Durl=http://localhost:9763/endpoints/pizzaOrderReceiver -Dsn=0503

    Note

    Do not close this terminal. It is required to keep the server running and receiving events.

    This builds the HTTP client and publishes the events defined in the <CEP_HOME>/samples/cep/artifacts/0503/pizzaOrderReceiver.txt file to the pizzaOrderReceiver endpoint in Node1.

    You view Node 1 (active node) receiving the output events in the logs of it in the CLI as shown below.

    published events received by Node 1

     

    Info

    Value of totalOrders is incremented by one for each new event, and the sum of the prices is increased by the frequency of each event.

  2. Repeat step 1 using the following Ant command: ant -Durl=http://localhost:9764/endpoints/pizzaOrderReceiver  -Dsn=0503

    Note

    Do not close this terminal. It is required to keep the server running and receiving events. 

    This builds the HTTP client and publishes the events defined in the <CEP_HOME>/samples/cep/artifacts/0503/pizzaOrderReceiver.txt file to the pizzaOrderReceiver endpoint in Node2.

    You view Node1 (active node) receiving the output events in the logs of it in the CLI as shown below.

    events published to Node2

    Info

    Even if events are sent to one server, the two nodes coordinate in a way so that both receive all the events. Only the active node publishes the output events.

  3.  Shutdown the active node (Node1). Now, Node2 becomes the active node.
  4. Repeat step 2 and use the command to send events to the running node.

    You view the running node receiving the output events in the logs of it in the CLI as shown below.

    Even though one node is down, the other carries on processing the events.