To call a topic request with no reply, you write code that
locates the topic connection factory and topic, creates the topic
connection and topic session, sends a message to the topic, then closes
the connection and session.
About this task
To
use the Decision Server message-driven
rule bean in a topic request with no reply, you must have the following:
A message client sends messages to the topic that the message-bean
listens to.
Procedure
To call 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";
- Create a topic publisher.
TopicPublisher publisher = topicSession.createPublisher(topic);
- Create a message.
ObjectMessage requestMessage = topicSession.createObjectMessage();
- Set the mandatory and optional JMS properties.
The rulesetPath and request properties
are mandatory, the userData property is optional.
requestMessage.setStringProperty("ilog_rules_bres_mdb_rulesetPath",
rulesetPath);
requestMessage.setStringProperty("ilog_rules_bres_mdb_status","request");
requestMessage.setStringProperty("ilog_rules_bres_mdb_userData", userData);
- Set the ruleset parameters.
HashMap parameters = new HashMap();
parameters.put("param1","<?xml ... >");
requestMessage.setObject(parameters);
- Send the message.
publisher.publish(requestMessage);
- Close the topic publisher.
publisher.close();
- Close the topic session and connection.
topicSession.close();
topicConnection.close();