Accessing the process choreographer JMS interface

Why and when to perform this task

Process choreographer accepts Java Message Service (JMS) messages that follow the point-to-point paradigm. An application that sends or receives JMS messages must include the following actions.

Steps for this task

  1. Create a connection to process choreographer.
    Use Java Naming and Directory Interface (JNDI) lookup to retrieve the connection factory. The JNDI-lookup name must be the same as the name specified when the process choreographer external request queue is configured.
    //Obtain the default initial JNDI context
    Context initialContext = new InitialContext();
    
    // Look up the connection factory
    QueueConnectionFactory queueConnectionFactory = 
         (QueueConnectionFactory) initialContext.lookup("jms/BPECF");
    
    // Create connection
    QueueConnection queueConnection = 
         queueConnectionFactory.createQueueConnection();
  2. Create a session so that message producers and consumers can be created.
    //Create a nontransacted session using autoacknowledgement
    QueueSession queueSession = 
         queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
  3. Create a message producer to send messages.
    The JNDI-lookup name must be the same as the name specified when the process choreographer external request queue is configured.
    // Look up the destination of the process choreographer queue 
    // to send messages to
    Queue bpeQueue = (Queue) initialContext.lookup("jms/BPEApiQueue");
    // Create message producer
    QueueSender queueSender = queueSession.createSender(bpeQueue);
  4. Create a message consumer to receive replies.
    The JNDI-lookup name must specify a user-defined destination to which replies are sent.
    // Look up the destination of the reply to queue
    Queue replyToQueue = (Queue) initialContext.lookup("MyReplyToQueue");
    // Create message consumer
    QueueReceiver queueReceiver = queueSession.createReceiver(replyToQueue);
  5. Send requests and receive replies.
    // Start sending and receiving messages
    queueConnection.start();
       
    // Create message - see the task descriptions for examples - and send
    ObjectMessage message = queueSession.createObjectMessage();
    // message.SetStringProperty(..);
    // message.setObject(...);
    
    queueSender.send(message);
    
    // Receive message and analyze reply 
    // See the detailed task descriptions for examples
    Message reply = queueReceiver.receive();
  6. Close the connection to the free resources.
    // Final housekeeping: free resources
    queueConnection.close();

Related concepts
Structure of a process choreographer JMS message
Authorization for JMS renderings



Searchable topic ID:   t6accjms
Last updated: Jun 21, 2007 8:07:48 PM CDT    WebSphere Business Integration Server Foundation, Version 5.0.2
http://publib.boulder.ibm.com/infocenter/wasinfo/index.jsp?topic=/com.ibm.wasee.doc/info/ee/wfapi/tasks/t6accjms.html

Library | Support | Terms of Use | Feedback