Accessing the JMS interface from a business process application

The JMS interface can be accessed by business process applications only.
Business 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.
  1. Create a connection to Business 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 Business 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 Business Process Choreographer external request queue is configured.
    // Look up the destination of the Business 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 Business Process Choreographer JMS message
Authorization for JMS renderings