You can publish the events to BAM/CEP by using the DataPublisher. AsyncDataPublisher is enhanced version of DataPublisher which incorporates all the constructors and API of of general DataPublisher and send events asynchronously. Thats is in general data publishers, making the connection is synchronous/blocking therefore the network latency might affect the connection time and publishing efficieny. The AsyncDataPublisher connects to the receiver asynchronously and cache and re-use the stream id in efficient manner.
There are mainly three steps involved in creating the AsyncDataPublisher.
1.Create a AsyncDataPublisher Instance with any of available constructors.
Eg: AsyncDataPublisher asyncDataPublisher = new AsyncDataPublisher("url","userName", "password");
2. Add the stream definition json string which you would like to publish via the AsyncDataPublisher. You can add any number of stream definitions and any time you can include that. But make sure before you publish the event for a specific stream definition, you should include it in the AsyncDataPublisher.
Eg: asyncDataPublisher.addStreamDefinition("stream def");
Eg: asyncDataPublisher.publish("stream name", "stream version", metaDataObjectArray, correlationDataObjectArray, payLoadDataObjectArray );
This will send events with additional advantage as mentioned above.