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:
- Enable the client to locate the connection factory and
queue:
QueueConnectionFactory queueConnectionFactory =
(QueueConnectionFactory) jndiContext.lookup("jms/
RESQueueConnectionFactory");
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 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);
- Pass the parameters.
HashMap parameters = new HashMap();
parameters.put("paramXml","<?xml ... >");
oMessage.setObject(parameters);
- Send the message.
queueSender.send(oMessage);
- Close the sender.
queueSender.close();
- Close the session and connection:
queueSession.close();
queueConnection.close();