This sample demonstrates how to publish XML, JSON or custom Text events via HTTP transport. Custom events are events with custom mappings that does not adhere to the default event formats. For more information on event formats, see Event Formats. This sample does not do any processing on the outgoing event. Use log event publisher, and log the published event to verify if the messages have been properly published.
Set up the prerequisites required for all samples.
Building the sample
Start the WSO2 CEP server with the sample configuration numbered 0062. For instructions, see Starting sample CEP configurations. This sample configuration does the following:
- Changes the default Axis2 repo from
- Creates three streams with the following ids:
- Loads the events-xml.csv, events-json.csv, events-text.csv and related configuration files so that event simulator can be used to send events to the three different pre-configured event publishers.
- Creates the following three event publishers to log the received messages via an HTTP servlet receiver:
- httpXml - Publishes events in default XML event format
- httpJson - Publishes events in default JSON event format
- httpText - Publishes the event as a customized text message
Executing the sample
Open another terminal, go to
<CEP_HOME>/samples/cep/consumers/generic-log-serviceand run the following command:
It builds the servlet web application that logs any HTTP traffic it receives. Events published by the http event publisher will be sent to this web application and logged.
- Go to the management console of CEP and determine the required stream and select 'Play' to play the events.
The following streams are configured to publish the following event formats via the different pre-configured http event output adapters.
You can see the events getting received by CEP by the logs printed in the CEP console by the generic-log-service web application