Java Reference
In-Depth Information
3. To create any needed resources, deploy the client JAR file to the GlassFish
Server, then retrieve the client stubs, type the following command:
ant getclient
Ignore the message that states that the application is deployed at a URL.
4. Because this example takes no command-line arguments, you can run the cli-
ent using the following command:
ant run
Alternatively, you can type the following command:
appclient -client client-jar/durablesubscriberexampleClient.jar
5. After you run the client, you can delete the connection factory jms/Dur-
ableConnectionFactory by using the following command:
asadmin delete-jms-resource jms/DurableConnectionFactory
A Local Transaction Example
TransactedExample.java demonstrates the use of transactions in a JMS client
application. The example is in the tut-install /examples/jms/advanced/trans-
actedexample/src/java/ directory.
This example shows how to use a queue and a topic in a single transaction as well as how
to pass a session to a message listener's constructor function. The example represents a
highly simplified e-commerce application in which the following actions occur.
1. A retailer sends a MapMessage to the vendor order queue, ordering a quantity of
computers, and waits for the vendor's reply:
Click here to view code image
producer = session.createProducer(vendorOrderQueue);
outMessage = session.createMapMessage();
outMessage.setString("Item", "Computer(s)");
outMessage.setInt("Quantity", quantity);
outMessage.setJMSReplyTo(retailerConfirmQueue);
producer.send(outMessage);
System.out.println("Retailer: ordered " + quantity + " com-
puter(s)");
orderConfirmReceiver = ses-
sion.createConsumer(retailerConfirmQueue);
connection.start();
Search WWH ::




Custom Search