Using the JMS JCA Wizard

ProcedureTo Create a Message Driven Bean

  1. Right-click the new project, and then select New -> Other.

    The New File Wizard appears.

    Figure 16 New JCA Message-Driven Bean

    Create MDB

  2. Select Java EE under Categories, and then select JCA Message-Driven Bean under File Types .

  3. Click Next.

    The Name and Location window appears.

    Figure 17 Configuring the Message-Driven Bean

    The Name MDB Field

  4. Enter a unique Class Name and a valid Package name.

  5. Click Next.

    The Choose Inbound JCA window appears.

  6. Select the JMS Adapter and click Next.

    The Edit Activation Configuration window appears.

    Figure 18 Edit Activation Configuration

    Edit Activation Configuration

  7. Set the Destination lookup to the JNDI Name of the Queue and click Finish.

    A new Message-Driven Bean is created.

  8. Drag a Queue rom the Palette panel on the right into the Java Editor.

    The Create JMS Destination dialog box appears.

    Figure 19 JMS Destination

    JMS Destination

  9. Enter a valid JNDI Name, Variable Name, and click OK.

    The Java code for the Queue instance is populated into the Java Editor. Repeat the above steps for as many Queues that are needed.

  10. Drag a Session from the Palette panel in the right into the onMessage() method in the Java Editor.

    The JMS Adapter Declaration dialog box appears.

    Figure 20 JMS Adapter Declaration

    JMS Adapter Declaration

  11. Enter a valid method name, such as RequestReply and click Finish.

    The Java code for the JMS Session is populated into the Java Editor.

  12. Drag a Request-Reply from the Palette panel on the right into the new method.

    The Create JMS Request-Reply dialog box appears.

    Figure 21 JMS Request-Reply

    JMS Request-Reply

  13. Select following values for the fields:

    • Select Method – Select the method you specified earlier on the JMS Adapter Declaration dialog box.

    • Request Message – Select message.

    • Request Destination – Select the JMS queue or topic you created for the adapter.

    • Non-transactional Connection Factory – Select a connection factory that contains “notx” in the name.

  14. Click OK.

  15. In the Request-Reply method, enter the following code beneath the first line of code:

    jmsSession.createProducer(queue2).send(replyMessage);

    Figure 22 Request-Reply Method

    Request-Reply Method

  16. Save the file.