[jboss-cvs] JBossAS SVN: r82549 - in projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor: src/org/jboss/tutorial/mdb_deployment_descriptor/client and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Dec 26 02:10:28 EST 2008
Author: jaikiran
Date: 2008-12-26 02:10:28 -0500 (Fri, 26 Dec 2008)
New Revision: 82549
Modified:
projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/META-INF/jboss.xml
projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/src/org/jboss/tutorial/mdb_deployment_descriptor/client/Client.java
Log:
Minor changes to the MDB deployment descriptor tutorial to cleanup the connection and also add a depends element in the MDB configuration
Modified: projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/META-INF/jboss.xml
===================================================================
--- projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/META-INF/jboss.xml 2008-12-26 07:07:46 UTC (rev 82548)
+++ projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/META-INF/jboss.xml 2008-12-26 07:10:28 UTC (rev 82549)
@@ -7,6 +7,7 @@
<message-driven>
<ejb-name>ExampleMDB</ejb-name>
<destination-jndi-name>queue/tutorial/example</destination-jndi-name>
+ <depends>jboss.messaging.destination:service=Queue,name=tutorial</depends>
</message-driven>
</enterprise-beans>
</jboss>
Modified: projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/src/org/jboss/tutorial/mdb_deployment_descriptor/client/Client.java
===================================================================
--- projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/src/org/jboss/tutorial/mdb_deployment_descriptor/client/Client.java 2008-12-26 07:07:46 UTC (rev 82548)
+++ projects/ejb3/trunk/docs/tutorial/mdb_deployment_descriptor/src/org/jboss/tutorial/mdb_deployment_descriptor/client/Client.java 2008-12-26 07:10:28 UTC (rev 82549)
@@ -39,14 +39,23 @@
InitialContext ctx = new InitialContext();
Queue queue = (Queue) ctx.lookup("queue/tutorial/example");
QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
- cnn = factory.createQueueConnection();
- session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ try {
+ cnn = factory.createQueueConnection();
+ session = cnn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+
+ TextMessage msg = session.createTextMessage("Hello World");
+
+ sender = session.createSender(queue);
+ sender.send(msg);
+ System.out.println("Message sent successfully to remote queue.");
+ } finally {
+ // Cleanup
+ // close the connection
+ if (cnn != null)
+ {
+ cnn.close();
+ }
+ }
- TextMessage msg = session.createTextMessage("Hello World");
-
- sender = session.createSender(queue);
- sender.send(msg);
- System.out.println("Message sent successfully to remote queue.");
-
}
}
More information about the jboss-cvs-commits
mailing list