The Java EE 5 Tutorial

Building, Deploying, and Running the sendremote Modules Using Ant

    To package the modules, perform these steps:

  1. Go to the following directory:

    tut-install/javaeetutorial5/examples/jms/sendremote/multiclient/
    
  2. Type the following command:


    ant
    

    This command creates a JAR file that contains the client class file and a manifest file.

  3. Change to the directory replybean:


    cd ../replybean
    
  4. Type the following command:


    ant
    

    This command creates a JAR file that contains the bean class file.

    To deploy the replybean module on the local and remote servers, perform the following steps:

  1. Verify that you are still in the directory replybean.

  2. Type the following command:


    ant deploy
    

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

  3. Type the following command:


    ant deploy-remote -Dsys=remote-system-name
    

    Replace remote-system-name with the actual name of the remote system.

    To deploy and run the client, perform these steps:

  1. Change to the directory multiclient:


    cd ../multiclient
    
  2. Type the following command:


    ant run
    

On the local system, the output looks something like this:


running application client container.
Sent message: text: id=1 to local app server
Sent message: text: id=2 to remote app server
ReplyListener: Received message: id=1, text=ReplyMsgBean processed message: text: id=1 to local
 app server
Sent message: text: id=3 to local app server
ReplyListener: Received message: id=3, text=ReplyMsgBean processed message: text: id=3 to local
 app server
ReplyListener: Received message: id=2, text=ReplyMsgBean processed message: text: id=2 to remote
 app server
Sent message: text: id=4 to remote app server
ReplyListener: Received message: id=4, text=ReplyMsgBean processed message: text: id=4 to remote
 app server
Sent message: text: id=5 to local app server
ReplyListener: Received message: id=5, text=ReplyMsgBean processed message: text: id=5 to local
 app server
Sent message: text: id=6 to remote app server
ReplyListener: Received message: id=6, text=ReplyMsgBean processed message: text: id=6 to remote
 app server
Sent message: text: id=7 to local app server
ReplyListener: Received message: id=7, text=ReplyMsgBean processed message: text: id=7 to local
 app server
Sent message: text: id=8 to remote app server
ReplyListener: Received message: id=8, text=ReplyMsgBean processed message: text: id=8 to remote
 app server
Sent message: text: id=9 to local app server
ReplyListener: Received message: id=9, text=ReplyMsgBean processed message: text: id=9 to local
 app server
Sent message: text: id=10 to remote app server
ReplyListener: Received message: id=10, text=ReplyMsgBean processed message: text: id=10 to remote
 app server
Waiting for 0 message(s) from local app server
Waiting for 0 message(s) from remote app server
Finished
Closing connection 1
Closing connection 2

On the local system, where the message-driven bean receives the odd-numbered messages, the output in the server log looks like this (wrapped in logging information):


ReplyMsgBean: Received message: text: id=1 to local app server
ReplyMsgBean: Received message: text: id=3 to local app server
ReplyMsgBean: Received message: text: id=5 to local app server
ReplyMsgBean: Received message: text: id=7 to local app server
ReplyMsgBean: Received message: text: id=9 to local app server

On the remote system, where the bean receives the even-numbered messages, the output in the server log looks like this (wrapped in logging information):


ReplyMsgBean: Received message: text: id=2 to remote app server
ReplyMsgBean: Received message: text: id=4 to remote app server
ReplyMsgBean: Received message: text: id=6 to remote app server
ReplyMsgBean: Received message: text: id=8 to remote app server
ReplyMsgBean: Received message: text: id=10 to remote app server

    Undeploy the modules after you finish running the client. To undeploy the multiclient module, perform these steps:

  1. Verify that you are still in the directory multiclient.

  2. Type the following command:


    ant undeploy
    

    To undeploy the replybean module, perform these steps:

  1. Change to the directory replybean:


    cd ../replybean
    
  2. Type the following command:


    ant undeploy
    
  3. Type the following command:


    ant undeploy-remote -Dsys=remote-system-name
    

    Replace remote-system-name with the actual name of the remote system.

To remove the generated files, use the following command in both the replybean and multiclient directories:


ant clean