Sun Java System Message Queue 4.3 Developer's Guide for Java Clients

ProcedureTo Receive the JMS Message, Transform it into a SOAP Message, and Process It

  1. Instantiate a ConnectionFactory object and set its attribute values.


    QueueConnectioFactory myQConnFact = new
             com.sun.messaging.QueueConnectionFactory();
  2. Use the ConnectionFactory object to create a Connection object.


    QueueConnection myQConn = myQConnFact.createQueueConnection();
  3. Use the Connection object to create one or more Session objects.


    QueueSession myRQSess = myQConn.createQueueSession(false,
             session.AUTO_ACKNOWLEDGE);
  4. Instantiate a Destination object and set its name attribute.


    Queue myRQueue = new com.sun.messaging.Queue("mySOAPQ");
  5. Use a Session object and a Destination object to create any needed MessageConsumer objects.


    QueueReceiver myQueueReceiver =
         myRQSess.createReceiver(myRQueue);
  6. If needed, instantiate a MessageListener object and register it with a MessageConsumer object.

  7. Start the QueueConnection you created in Example 1: Deferring SOAP Processing. Messages for consumption by a client can only be delivered over a connection that has been started.


    myQConn.start();
  8. Receive a message from the queue.

    The code below is an example of a synchronous consumption of messages:


    Message myJMS = myQueueReceiver.receive();
  9. Use the Message Transformer to convert the JMS message back to a SOAP message.


    SOAPMessage MySoap =
             MessageTransformer.SOAPMessageFromJMSMessage
                 (myJMS, MyMsgFactory);

    If you specify null for the MessageFactory argument, the default Message Factory is used to construct the SOAP Message.

  10. Disassemble the SOAP message in preparation for further processing. See The SOAP Message Object for information.