The Java EE 6 Tutorial

ProcedureTo Deploy and Run the Clients for the Asynchronous Receive Example Using Ant and the appclient Command

  1. Deploy the client JAR file to the GlassFish Server, then retrieve the client stubs:


    ant getclient
    

    Ignore the message that states that the application is deployed at a URL.

  2. Run the AsynchConsumer client, specifying the topic destination type.


    appclient -client client-jar/asynchconsumerClient.jar topic
    

    The client displays the following lines (along with some application client container output) and appears to hang:


    Destination type is topic
    To end program, type Q or q, then <return>
  3. In the terminal window where you ran the Producer client previously, run the client again, sending three messages.


    appclient -client client-jar/producerClient.jar topic 3
    

    The output of the client looks like this (along with some application client container output):


    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 (along with some application client container output):


    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.

  4. Type Q or q and press Return to stop the client.

  5. Now run the clients 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:


    appclient -client client-jar/producerClient.jar queue 3
    

    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
  6. Run the AsynchConsumer client:


    appclient -client client-jar/asynchconsumerClient.jar queue
    

    The output of the client looks like this (along with some application client container output):


    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
  7. Type Q or q to stop the client.