The Java EE 6 Tutorial

ProcedureTo Deploy and Run the Clients for the Asynchronous Receive Example Using NetBeans IDE

  1. Run the AsynchConsumer example:

    1. Right-click the asynchconsumer project and select Properties.

    2. Select Run from the Categories tree.

    3. In the Arguments field, type the following:


      topic
      
    4. Click OK.

    5. Right-click the project and select Run.

      The client displays the following lines and appears to hang:


      Destination type is topic
      To end program, type Q or q, then <return>
  2. Now run the Producer example:

    1. Right-click the producer project and select Properties.

    2. Select Run from the Categories tree.

    3. In the Arguments field, type the following:


      topic 3
      
    4. Click OK.

    5. Right-click the project and select Run.

      The output of the client looks like this:


      Destination type is topic
      Sending message: This is message 1 from producer
      Sending message: This is message 2 from producer
      Sending message: This is message 3 from producer

      In the other window, the AsynchConsumer client displays the following:


      Destination type is topic
      To end program, type Q or q, then <return>
      Reading message: This is message 1 from producer
      Reading message: This is message 2 from producer
      Reading message: This is message 3 from producer
      Message is not a TextMessage

      The last line appears because the client has received the non-text control message sent by the Producer client.

  3. Type Q or q in the Output window and press Return to stop the client.

  4. Now run the Producer client using a queue.

    In this case, as with the synchronous example, you can run the Producer client first, because there is no timing dependency between the sender and receiver.

    1. Right-click the producer project and select Properties.

    2. Select Run from the Categories tree.

    3. In the Arguments field, type the following:


      queue 3
      
    4. Click OK.

    5. Right-click the project and select Run.

      The output of the client looks like this:


      Destination type is queue
      Sending message: This is message 1 from producer
      Sending message: This is message 2 from producer
      Sending message: This is message 3 from producer
  5. Run the AsynchConsumer client.

    1. Right-click the asynchconsumer project and select Properties.

    2. Select Run from the Categories tree.

    3. In the Arguments field, type the following:


      queue
      
    4. Click OK.

    5. Right-click the project and select Run.

      The output of the client looks like this:


      Destination type is queue
      To end program, type Q or q, then <return>
      Reading message: This is message 1 from producer
      Reading message: This is message 2 from producer
      Reading message: This is message 3 from producer
      Message is not a TextMessage
  6. Type Q or q in the Output window and press Return to stop the client.