[jboss-svn-commits] JBL Code SVN: r13606 - in labs/jbossesb/trunk/product/samples/quickstarts/recipient_list: src and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Jul 18 12:37:53 EDT 2007
Author: ldimaggi at redhat.com
Date: 2007-07-18 12:37:53 -0400 (Wed, 18 Jul 2007)
New Revision: 13606
Added:
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/ReceiveJMSMessage.java
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendCBRJMSMessage.java
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendJMSMessage.java
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendStaticRouterJMSMessage.java
Removed:
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/quickstart/
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/build.xml
Log:
Reorganized to match other quickstarts' dir structure
Modified: labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/build.xml 2007-07-18 14:28:10 UTC (rev 13605)
+++ labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/build.xml 2007-07-18 16:37:53 UTC (rev 13606)
@@ -12,7 +12,7 @@
<target name="runtest-cbr" depends="compile">
<echo>Runs Content Based Router Test</echo>
- <java fork="yes" classname="quickstart.recipientList.test.SendCBRJMSMessage" failonerror="true">
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.recipientList.test.SendCBRJMSMessage" failonerror="true">
<arg value="ESB recipient list pattern quickstart - content based router test"/>
<classpath refid="exec-classpath"/>
</java>
@@ -20,7 +20,7 @@
<target name="runtest" depends="compile">
<echo>Runs JMS Sender - to destination channel</echo>
- <java fork="yes" classname="quickstart.recipientList.test.SendJMSMessage" failonerror="true">
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.recipientList.test.SendJMSMessage" failonerror="true">
<arg value="ESB recipient list pattern quickstart - message to destination channel"/>
<classpath refid="exec-classpath"/>
</java>
@@ -28,7 +28,7 @@
<target name="static-router" depends="compile">
<echo>Runs Static-Router Test</echo>
- <java fork="yes" classname="quickstart.recipientList.test.SendStaticRouterJMSMessage" failonerror="true">
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.recipientList.test.SendStaticRouterJMSMessage" failonerror="true">
<arg value="ESB recipient list pattern quickstart - static router test"/>
<classpath refid="exec-classpath"/>
</java>
@@ -36,7 +36,7 @@
<target name="receive-destination" depends="compile">
<echo>Runs Test Recipient List destination regular message receiver</echo>
- <java fork="yes" classname="quickstart.recipientList.test.ReceiveJMSMessage" failonerror="true">
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.recipientList.test.ReceiveJMSMessage" failonerror="true">
<arg value="queue/qsrecipientlist_regular_Request"/>
<classpath refid="exec-classpath"/>
</java>
@@ -44,7 +44,7 @@
<target name="receive-destination1" depends="compile">
<echo>Runs Test Recipient List destination 1 message receiver</echo>
- <java fork="yes" classname="quickstart.recipientList.test.ReceiveJMSMessage" failonerror="true">
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.recipientList.test.ReceiveJMSMessage" failonerror="true">
<arg value="queue/qsrecipientlist_1_Request"/>
<classpath refid="exec-classpath"/>
</java>
@@ -52,7 +52,7 @@
<target name="receive-destination2" depends="compile">
<echo>Runs Test Recipient List destination 2 message receiver</echo>
- <java fork="yes" classname="quickstart.recipientList.test.ReceiveJMSMessage" failonerror="true">
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.recipientList.test.ReceiveJMSMessage" failonerror="true">
<arg value="queue/qsrecipientlist_2_Request"/>
<classpath refid="exec-classpath"/>
</java>
Added: labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/ReceiveJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/ReceiveJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/ReceiveJMSMessage.java 2007-07-18 16:37:53 UTC (rev 13606)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.recipientList.test;
+
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueReceiver;
+import javax.jms.QueueSession;
+import javax.jms.ObjectMessage;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+
+import javax.jms.MessageListener;
+import javax.jms.Message;
+
+public class ReceiveJMSMessage {
+ QueueConnection conn = null;
+ QueueSession receiverSession = null;
+ Queue receiverQueue = null;
+ QueueReceiver queueReceiver = null;
+ InitialContext iniCtx = null;
+ QueueConnectionFactory qcf = null;
+ String receiveQueueName = "queue/D"; // Default to queue/D
+
+ // Ref: http://docs.jboss.org/jbossas/jboss4guide/r5/html/ch6.chapt.html#d0e12917
+ public static class ExListener implements MessageListener
+ {
+ public void onMessage(Message msg)
+ {
+ TextMessage tm = (TextMessage) msg;
+ try {
+ System.out.println("onMessage, recv text=" + tm.getText());
+ } catch(Throwable t) {
+ t.printStackTrace();
+ }
+ }
+ }
+
+ public ReceiveJMSMessage() {
+
+ }
+ public void receiveOne() {
+ try {
+ if (iniCtx == null) iniCtx = new InitialContext();
+ if (qcf == null) qcf = (QueueConnectionFactory) iniCtx.lookup("ConnectionFactory");
+ if (conn == null) {
+ conn = qcf.createQueueConnection();
+ conn.start();
+ }
+
+ receiverQueue = (Queue) iniCtx.lookup(receiveQueueName);
+ receiverSession = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ queueReceiver = receiverSession.createReceiver(receiverQueue);
+ TextMessage msg = (TextMessage) queueReceiver.receive(2000);
+
+ // Ref: http://docs.jboss.org/jbossas/jboss4guide/r5/html/ch6.chapt.html#d0e12917
+ queueReceiver.setMessageListener(new ExListener());
+
+ } catch (Exception e) {
+ System.out.println(e);
+ }
+ }
+
+ public static void main(String[] args) {
+ ReceiveJMSMessage receiver = new ReceiveJMSMessage();
+
+ if(args[0] != null) {
+ receiver.receiveQueueName = args[0];
+ System.out.println("Receiving on: " + receiver.receiveQueueName );
+ }
+ while (true) { // loop until I'm killed
+ receiver.receiveOne();
+ }
+ }
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendCBRJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendCBRJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendCBRJMSMessage.java 2007-07-18 16:37:53 UTC (rev 13606)
@@ -0,0 +1,113 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.recipientList.test;
+
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.jms.JMSException;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueSession;
+import javax.jms.QueueSender;
+import javax.jms.ObjectMessage;
+import javax.jms.TextMessage;
+
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+public class SendCBRJMSMessage {
+ QueueConnection conn;
+ QueueSession session;
+ Queue que;
+
+
+ public void setupConnection() throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/qsrecipientlist_cbr_Request"); //quickstart_simple_cbr_Request");
+ session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ System.out.println("Connection Started");
+ }
+
+ public void stop() throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public void sendAMessage(String msg) throws JMSException {
+
+ QueueSender send = session.createSender(que);
+ TextMessage tm = session.createTextMessage(msg);
+ send.send(tm);
+ send.close();
+ }
+
+ public String readAsciiFile(String fileName) throws IOException {
+ FileReader fr = null;
+ char[] thechars = null;
+
+ try {
+ File thefile = new File( fileName );
+ fr = new FileReader( thefile );
+ int size = (int) thefile.length();
+ thechars = new char[size];
+
+ int count, index = 0;
+
+ // read in the bytes from the input stream
+ while( ( count = fr.read( thechars, index, size ) ) > 0 ) {
+ size -= count;
+ index += count;
+ }
+ } catch(Exception e) {
+ System.out.println(e);
+ }
+ finally {
+ if( fr != null )
+ fr.close();
+ }
+ return new String(thechars);
+
+ } // readAsciiFile
+
+ public static void main(String args[]) throws Exception
+ {
+
+ SendCBRJMSMessage sm = new SendCBRJMSMessage();
+ sm.setupConnection();
+ String fileContent = sm.readAsciiFile("SampleOrder.xml");
+ System.out.println("---------------------------------------------");
+ System.out.println(fileContent);
+ System.out.println("---------------------------------------------");
+ sm.sendAMessage(fileContent);
+ sm.stop();
+
+ }
+
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendJMSMessage.java 2007-07-18 16:37:53 UTC (rev 13606)
@@ -0,0 +1,73 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.recipientList.test;
+
+import javax.jms.JMSException;
+import javax.jms.TextMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class SendJMSMessage {
+ QueueConnection conn;
+
+ QueueSession session;
+
+ Queue que;
+
+ public void setupConnection() throws JMSException, NamingException {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/qsrecipientlist_regular_Request");
+ session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ System.out.println("Connection Started");
+ }
+
+ public void stop() throws JMSException {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public void sendAMessage(String msg) throws JMSException {
+
+ QueueSender send = session.createSender(que);
+ TextMessage tm = session.createTextMessage(msg);
+ send.send(tm);
+ send.close();
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ SendJMSMessage sm = new SendJMSMessage();
+ sm.setupConnection();
+ sm.sendAMessage(args[0]);
+ sm.stop();
+ }
+
+}
Added: labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendStaticRouterJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendStaticRouterJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/recipient_list/src/org/jboss/soa/esb/samples/quickstart/recipientList/test/SendStaticRouterJMSMessage.java 2007-07-18 16:37:53 UTC (rev 13606)
@@ -0,0 +1,76 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * 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,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.recipientList.test;
+
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Queue;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSender;
+import javax.jms.QueueSession;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+public class SendStaticRouterJMSMessage {
+ QueueConnection conn;
+ QueueSession session;
+ Queue que;
+
+
+ public void setupConnection() throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+ Object tmp = iniCtx.lookup("ConnectionFactory");
+ QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+ conn = qcf.createQueueConnection();
+ que = (Queue) iniCtx.lookup("queue/qsrecipientlist_static_router_Request");
+ session = conn.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ conn.start();
+ System.out.println("Connection Started");
+ }
+
+ public void stop() throws JMSException
+ {
+ conn.stop();
+ session.close();
+ conn.close();
+ }
+
+ public void sendAMessage(String msg) throws JMSException {
+
+ QueueSender send = session.createSender(que);
+ ObjectMessage tm = session.createObjectMessage(msg);
+ send.send(tm);
+ send.close();
+ }
+
+
+ public static void main(String args[]) throws Exception
+ {
+ SendStaticRouterJMSMessage sm = new SendStaticRouterJMSMessage();
+ sm.setupConnection();
+ sm.sendAMessage(args[0]);
+ sm.stop();
+
+ }
+
+}
More information about the jboss-svn-commits
mailing list