Calling a topic request with no reply

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 JMS topic connection factory resource.

  • The JMS topic destination resource.

A message client sends messages to the topic that the message-bean listens to.

Procedure

To call a topic request with no reply:

  1. 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”);
  2. Get the client to create the topic connection and topic session:
    topicConnection = topicConnectionFactory.createTopicConnection();
    topicSession = topicConnection.createTopicSession(false,
                   Session.AUTO_ACKNOWLEDGE);
  3. Get the client to send a message to the topic.
    String rulesetPath = "/simplexml/simplexmlruleset";
    String userData = "Topic simple xml";
    1. Create a topic publisher.
      TopicPublisher publisher = topicSession.createPublisher(topic);
    2. Create a message.
      ObjectMessage requestMessage = topicSession.createObjectMessage();
    3. 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);
    4. Set the ruleset parameters.
      HashMap parameters = new HashMap();
      parameters.put("param1","<?xml ... >");
      requestMessage.setObject(parameters);
    5. Send the message.
      publisher.publish(requestMessage);
    6. Close the topic publisher.
      publisher.close();
  4. Close the topic session and connection.
    topicSession.close();
    topicConnection.close();