This section provides an example to write a client code to subscribe events from the already created Event Channels.
You can refer to the example code for details at OEBPS_HOME\bpserver\examples\EventPublisherExample.zip.
private static void subscribeBP ServerMessages(){
Session tsession = null;
try {
BMJMSService jmsService = new BMJMSService(factory_name, provider);
//post-filter expression based on SQL92
String postFilter = "";
if((appName != null) && (!appName.equals(""))) {
postFilter = "PROCESSTEMPLATENAME = '" + appName + "'";
}
// first parameter is connection factory (if null take default)
// second and third parameter is userName and password. By default security is not enabled.
javax.jms.Connection conn = jmsService.createConnection(null, user, password);
tsession = jmsService.createSession(conn);
//Example for Post Filter on event:::
//postFilter = "PROCESSTEMPLATENAME = 'Hiring' AND EVENT_VALUE = 'I_COMPLETED'";
//Create the subscriber with the above message filter
javax.jms.MessageConsumer tsubscriber = jmsService.createMessageConsumer(tsession, eventPublisherTopic, postFilter);
while (true) {
/* Subscribe the message from the topic in a loop*/
Message msg = tsubscriber.receive();
if(msg.propertyExists("PROCESSTEMPLATENAME")) {
System.out.println();
System.out.println("Message received");
System.out.print("ProcessTemplateName=" +
msg.getStringProperty("PROCESSTEMPLATENAME"));