2. Using the Tutorial Examples 3. Getting Started with Web Applications 5. JavaServer Pages Technology 7. JavaServer Pages Standard Tag Library 10. JavaServer Faces Technology 11. Using JavaServer Faces Technology in JSP Pages 12. Developing with JavaServer Faces Technology 13. Creating Custom UI Components 14. Configuring JavaServer Faces Applications 15. Internationalizing and Localizing Web Applications 16. Building Web Services with JAX-WS 17. Binding between XML Schema and Java Classes 19. SOAP with Attachments API for Java 21. Getting Started with Enterprise Beans 23. A Message-Driven Bean Example 24. Introduction to the Java Persistence API 25. Persistence in the Web Tier 26. Persistence in the EJB Tier 27. The Java Persistence Query Language 28. Introduction to Security in the Java EE Platform 29. Securing Java EE Applications 31. The Java Message Service API 32. Java EE Examples Using the JMS API A Java EE Application That Uses the JMS API with a Session Bean Writing the Application Components for theclientsessionmdb Example Coding the Application Client:MyAppClient.java Coding the Publisher Session Bean Coding the Message-Driven Bean:MessageBean.java Creating Resources for theclientsessionmdb Example Building, Deploying, and Running theclientsessionmdb Example Using NetBeans IDE Building, Deploying, and Running theclientsessionmdb Example Using Ant A Java EE Application That Uses the JMS API with an Entity Overview of theclientmdbentity Example Application Writing the Application Components for theclientmdbentity Example Coding the Application Client:HumanResourceClient.java Coding the Message-Driven Beans for theclientmdbentity Example Coding the Entity Class for theclientmdbentity Example Creating Resources for theclientmdbentity Example Building, Deploying, and Running theclientmdbentity Example Using NetBeans IDE Building, Deploying, and Running theclientmdbentity Example Using Ant An Application Example That Consumes Messages from a Remote Server Overview of theconsumeremote Example Modules Writing the Module Components for theconsumeremote Example Creating Resources for theconsumeremote Example Using Two Application Servers for theconsumeremote Example Building, Deploying, and Running theconsumeremoteModules Using NetBeans IDE Building, Deploying, and Running theconsumeremote Modules Using Ant An Application Example That Deploys a Message-Driven Bean on Two Servers Overview of thesendremote Example Modules Writing the Module Components for thesendremote Example Coding the Application Client:MultiAppServerClient.java Coding the Message-Driven Bean:ReplyMsgBean.java Creating Resources for thesendremote Example Using Two Application Servers for thesendremote Example Building, Deploying, and Running thesendremote Modules Using NetBeans IDE Building, Deploying, and Running thesendremote Modules Using Ant 36. The Coffee Break Application | An Application Example That Consumes Messages from a Remote ServerThis section and the following section explain how to write, compile, package, deploy,and run a pair of Java EE modules that run on twoJava EE servers and that use the JMS API to interchange messages witheach other. It is a common practice to deploy different components of anenterprise application on different systems within a company, and these examples illustrate ona small scale how to do this for an application that uses theJMS API. However, the two examples work in slightly different ways. In this first example,the deployment information for a message-driven bean specifies the remote server from whichit willconsume messages. In the next example, the same bean is deployedon two different servers, so it is the client module that specifies theservers (one local, one remote) to which it issending messages. This first example divides the example inChapter 23, A Message-Driven Bean Example into two modules (notapplications): one containing the application client, and the other containing the message-driven bean. This section covers the following topics:
You will find the source files for this section intut-install/javaeetutorial5/examples/jms/consumeremote/. Pathnames in this section are relative to this directory. Overview of theconsumeremote Example ModulesExcept for the fact that it is packaged as two separate modules,this example is very similar to the one inChapter 23, A Message-Driven Bean Example:
The basic steps of the modules are as follows.
Figure 32-3 illustrates the structure of this application. You can see that it isalmost identical toFigure 23-1 except that there are two Java EE servers. The queueused is the one on the remote server; the queue must also existon the local server for resource injection to succeed. Figure 32-3 A Java EE Application That Consumes Messages from a Remote Server ![]() Writing the Module Components for theconsumeremote ExampleWriting the components of the modules involves
The application client,jupiterclient/src/java/SimpleClient.java, is almost identical to the one inThesimplemessage Application Client. Similarly, the message-driven bean,earthmdb/src/java/MessageBean.java, is almost identical to the one inThe Message-Driven Bean Class. The only major difference is that the client and the bean arepackaged in two separate modules. Creating Resources for theconsumeremote ExampleFor this example, the message-driven bean uses the connection factory namedjms/JupiterConnectionFactory, whichyou created inCreating Administered Objects for Multiple Systems. Use the Admin Console to verify that the connectionfactory still exists and that itsAddressList property is set to the nameof the remote system. Because this bean must use a specific connection factory, theconnection factory is specified in themdb-connection-factory element of thesun-ejb-jar.xml file. If you deleted the connection factory, you can recreate it as follows:
The application client can use any connection factory that exists on the remoteserver; it usesjms/ConnectionFactory. Both components use the queue namedjms/Queue, which youcreated inCreating JMS Administered Objects for the Synchronous Receive Example. Using Two Application Servers for theconsumeremote ExampleAs inRunning JMS Client Programs on Multiple Systems, the two servers are namedearth andjupiter. The Application Server must be running on both systems. Which system you use to package and deploy the modules and whichsystem you use to run the client depend on your network configuration (whichfile system you can access remotely). These instructions assume that you can access thefile system ofjupiter fromearth but cannot access the file system ofearth fromjupiter. (You can use the same systems forjupiter andearththat you used inRunning JMS Client Programs on Multiple Systems.) You can package both modules onearth and deploy the message-driven bean there.The only action you perform onjupiter is running the client module. Building, Deploying, and Running theconsumeremoteModules Using NetBeans IDETo package the modules using NetBeans IDE, perform these steps:
To deploy theearthmdb module and run the application client, perform these steps:
Onjupiter, the output of theappclient command looks like this: Sending message: This is message 1Sending message: This is message 2Sending message: This is message 3 Onearth, the output in the server log looks something like this (wrappedin logging information): MESSAGE BEAN: Message received: This is message 1MESSAGE BEAN: Message received: This is message 2MESSAGE BEAN: Message received: This is message 3 Undeploy the message-driven bean after you finish running the client. To undeploy theearthmdb module, perform these steps:
To remove the generated files, follow these steps:
You can also delete thejupiterclient.jar file from the remote filesystem. Building, Deploying, and Running theconsumeremote Modules Using AntTo package the modules using Ant, perform these steps:
To deploy theearthmdb module, perform these steps:
To copy thejupiterclient module to the remote system, perform these steps:
To run the client, perform the following steps:
Onjupiter, the output of theappclient command looks like this: Sending message: This is message 1Sending message: This is message 2Sending message: This is message 3 Onearth, the output in the server log looks something like this (wrappedin logging information): MESSAGE BEAN: Message received: This is message 1MESSAGE BEAN: Message received: This is message 2MESSAGE BEAN: Message received: This is message 3 Undeploy the message-driven bean after you finish running the client. To undeploy theearthmdb module, perform these steps:
You can also delete thejupiterclient.jar file from the remote filesystem. To remove the generated files, use the following command in both theearthmdb andjupiterclient directories: ant clean Copyright © 2010, Oracle and/or its affiliates. All rights reserved.Legal Notices |