[jboss-cvs] JBoss Messaging SVN: r5900 - in trunk/examples/jms: src/org/jboss/jms/example and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Feb 19 09:34:04 EST 2009
Author: ataylor
Date: 2009-02-19 09:34:03 -0500 (Thu, 19 Feb 2009)
New Revision: 5900
Added:
trunk/examples/jms/src/org/jboss/jms/example/Sender.java
Modified:
trunk/examples/jms/build.xml
Log:
added mdb example
Modified: trunk/examples/jms/build.xml
===================================================================
--- trunk/examples/jms/build.xml 2009-02-19 12:24:56 UTC (rev 5899)
+++ trunk/examples/jms/build.xml 2009-02-19 14:34:03 UTC (rev 5900)
@@ -253,14 +253,13 @@
<target name="jar" depends="compile">
<jar destfile="${build.dir}/mdb-example.jar"
basedir="${build.dir}"
- includes="**/*MDBExample.class">
+ includes="**/*.class">
</jar>
</target>
<target name="ear" depends="jar">
<jar destfile="${build.dir}/mdb-example.ear">
<zipfileset dir="${build.dir}" includes="mdb-example.jar"/>
- <zipfileset dir="./config/META-INF"/>
</jar>
</target>
Added: trunk/examples/jms/src/org/jboss/jms/example/Sender.java
===================================================================
--- trunk/examples/jms/src/org/jboss/jms/example/Sender.java (rev 0)
+++ trunk/examples/jms/src/org/jboss/jms/example/Sender.java 2009-02-19 14:34:03 UTC (rev 5900)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005-2008, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.jms.example;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.TextMessage;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+
+/**
+ * @author <a href="mailto:andy.taylor at jboss.org">Andy Taylor</a>
+ */
+public class Sender
+{
+ public static void main(String[] args) throws Exception
+ {
+ String destinationName = "/queue/testQueue";
+ InitialContext ic = new InitialContext();
+ ConnectionFactory cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
+ Queue queue = (Queue)ic.lookup(destinationName);
+
+ Connection connection = cf.createConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer sender = session.createProducer(queue);
+
+ Queue temporaryQueue = session.createTemporaryQueue();
+ MessageConsumer consumer = session.createConsumer(temporaryQueue);
+ TextMessage message = session.createTextMessage("Hello!");
+ message.setJMSReplyTo(temporaryQueue);
+ sender.send(message);
+ connection.start();
+
+ message = (TextMessage)consumer.receive(500000);
+
+
+ if (message == null)
+ {
+ throw new Exception("Have not received any reply. The example failed!");
+ }
+
+ connection.close();
+ }
+}
More information about the jboss-cvs-commits
mailing list