Calling a queue request with no reply

To call a queue request with no reply, you write code that locates the connection factory and queue, creates the queue connection and session, then closes the sender and the queue connection and session.

About this task

To use a message-driven rule bean in a queue request with no reply, you must have a JMS queue connection factory resource and the JMS queue destination resource.

A message client sends messages to the queue on which the message-bean listens.

Procedure

To call a queue request with no reply:

  1. Enable the client to locate the connection factory and queue:
    QueueConnectionFactory queueConnectionFactory =
     (QueueConnectionFactory) jndiContext.lookup("jms/
                                    RESQueueConnectionFactory");
    Queue queueIn = (Queue) jndiContext.lookup("jms/BRESQueueIn");
  2. Get the client to create the queue connection and session:
    queueConnection = queueConnectionFactory.createQueueConnection();
    queueSession = queueConnection.createQueueSession(false,
                   Session.AUTO_ACKNOWLEDGE);
  3. 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:

    1. Create a sender to the JMS Queue that listens to the MDB.
      QueueSender queueSender = queueSession.createSender(queueIn);
    2. Create the JMS object message.
      ObjectMessage oMessage = queueSession.createObjectMessage();
      String rulesetPath = "/simplexml/simplexmlruleset";
      String userData = "Queue with XML parameter";
    3. Set the JMS properties.

      The rulesetPath and status properties are mandatory. The userData property is optional.

      oMessage.setStringProperty("ilog_rules_bres_mdb_rulesetPath", rulesetPath);
      oMessage.setStringProperty("ilog_rules_bres_mdb_status","request");
      oMessage.setStringProperty("ilog_rules_bres_mdb_userData", userData);
    4. Pass the parameters.
      HashMap parameters = new HashMap();
      parameters.put("paramXml","<?xml ... >");
      oMessage.setObject(parameters); 
    5. Send the message.
      queueSender.send(oMessage);
    6. Close the sender.
      queueSender.close();
  4. Close the session and connection:
    queueSession.close();
    queueConnection.close();