To use the JRules message-driven rule bean in a topic request with no reply, you must have the following:
-
A JMS topic connection factory resource.
-
The JMS topic destination resource.
A message client sends messages to the topic that the message-bean listens to.
To invoke a topic request with no reply:
-
Enable the client to locate the topic connection factory and topic:
TopicConnectionFactory topicConnectionFactory =
(TopicConnectionFactory) jndiContext.lookup("jms/
BRESTopicConnectionFactory");
Topic topic = (Topic) jndiContext.lookup("jms/BRESTopic");
-
Get the client to create the topic connection and topic session:
topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
-
Get the client to send a message to the topic.
String rulesetPath = "/simplexml/simplexmlruleset";
String userData = "Topic simple xml";
TopicPublisher publisher = topicSession.createPublisher(topic);
ObjectMessage requestMessage = topicSession.createObjectMessage();
// Set mandatory JMS properties.
requestMessage.setStringProperty("ilog_rules_bres_mdb_rulesetPath", rulesetPath);
requestMessage.setStringProperty("ilog_rules_bres_mdb_status","request");
requestMessage.setStringProperty("ilog_rules_bres_mdb_userData", userData);
HashMap parameters = new HashMap();
parameters.put("param1","<?xml ... >");
requestMessage.setObject(parameters);
publisher.publish(requestMessage);
-
Close the session and connection:
Related Concepts
Related Tasks
Related Samples and Tutorials