To use the JRules message-driven rule bean in a queue request with no reply, you must have the following:
-
a JMS queue connection factory resource
-
the JMS queue destination resource
A message client sends messages to the queue that the message-bean listens to.
To invoke a queue request with no reply:
-
Enable the client to locate the connection factory and queue:
QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) jndiContext.lookup("jms/
BRESQueueConnectionFactory");
Queue queueIn = (Queue) jndiContext.lookup("jms/BRESQueueIn");
-
Get the client to create the queue connection and session:
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession(false,
Session.AUTO_ACKNOWLEDGE);
-
Get the client to send a message to the queue.
A client can send a message containing a single parameter that takes an XML schema as its value, as follows:
// Create a sender to the JMS Queue that listens to the MDB.
QueueSender queueSender = queueSession.createSender(queueIn);
// Create the JMS Object Message.
ObjectMessage oMessage = queueSession.createObjectMessage();
String rulesetPath = "/simplexml/simplexmlruleset";
String userData = "Queue with XML parameter";
// Set mandatory JMS properties.
oMessage.setStringProperty("ilog_rules_bres_mdb_rulesetPath", rulesetPath);
oMessage.setStringProperty("ilog_rules_bres_mdb_status","request");
oMessage.setStringProperty("ilog_rules_bres_mdb_userData", userData);
HashMap parameters = new HashMap();
parameters.put("paramXml","<?xml ... >");
oMessage.setObject(parameters);
queueSender.send(oMessage);
-
Close the session and connection:
Related Concepts
Related Tasks
Related Samples and Tutorials