Sun Java System Message Queue 4.2 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
  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,
  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 =
  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.

  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 =
                 (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.