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
//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();
//Create a nontransacted session using autoacknowledgement QueueSession queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
// 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);
// Look up the destination of the reply to queue Queue replyToQueue = (Queue) initialContext.lookup("MyReplyToQueue"); // Create message consumer QueueReceiver queueReceiver = queueSession.createReceiver(replyToQueue);
// 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();
// Final housekeeping: free resources queueConnection.close();