[jboss-svn-commits] JBL Code SVN: r7461 - in labs/jbossesb/trunk/product: core/listeners/src/org/jboss/soa/esb/listeners/gateway core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway etc/examples/listeners

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Nov 8 06:56:14 EST 2006


Author: estebanschifman
Date: 2006-11-08 06:56:06 -0500 (Wed, 08 Nov 2006)
New Revision: 7461

Added:
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java
   labs/jbossesb/trunk/product/etc/examples/listeners/gatewayExample.xml
Removed:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/gatewayExample.xml
Modified:
   labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
   labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
Log:
add JmsGatewayListener unit test

Modified: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java	2006-11-08 11:22:09 UTC (rev 7460)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListener.java	2006-11-08 11:56:06 UTC (rev 7461)
@@ -22,17 +22,21 @@
 
 package org.jboss.soa.esb.listeners.gateway;
 
+import java.io.ByteArrayOutputStream;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 
 import javax.enterprise.deploy.spi.exceptions.ConfigurationException;
+import javax.jms.BytesMessage;
 import javax.jms.JMSException;
 import javax.jms.MessageConsumer;
+import javax.jms.ObjectMessage;
 import javax.jms.Queue;
 import javax.jms.QueueConnection;
 import javax.jms.QueueConnectionFactory;
 import javax.jms.QueueSession;
+import javax.jms.TextMessage;
 import javax.naming.Context;
 
 import org.apache.log4j.Logger;
@@ -45,6 +49,7 @@
 import org.jboss.soa.esb.helpers.ConfigTree;
 import org.jboss.soa.esb.listeners.ListenerTagNames;
 import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
 import org.jboss.soa.esb.services.registry.RegistryException;
 
 public class JmsGatewayListener implements Runnable
@@ -115,6 +120,9 @@
 			catch (RegistryException e1){	_logger.warn("unable to unRegister service",e1); }
 		
 
+		if (null != _messageReceiver) 
+            try { _messageReceiver.close(); }
+            catch (Exception e1) {/* Tried my best - Just continue */ }
 		if (null != _queueSession) 
             try { _queueSession.close(); }
             catch (Exception e1) {/* Tried my best - Just continue */ }
@@ -140,24 +148,9 @@
         	throw new ConfigurationException("EPR <"+_targetServiceName+"> not found in registry");
 
     	_queueName 	= _controller.obtainAtt(_config, JMSEpr.DESTINATION_NAME_TAG, null);
+    	
+    	resolveComposerClass();
  
-        // Look for first "action" element - only first one will be used
-        String tagName = ListenerTagNames.ACTION_ELEMENT_TAG;
-        ConfigTree actionElement = _config.getFirstChild(tagName);
-        if (null==actionElement)
-        	throw new ConfigurationException("Missing <"+tagName+"> element");
-        // class attribute
-        _composerName	= _controller.obtainAtt(actionElement,ListenerTagNames.ACTION_CLASS_TAG,null);
-        _composerClass = Class.forName(_composerName);
-    	Constructor oConst = _composerClass.getConstructor(new Class[] {ConfigTree.class});
-    	_composer= oConst.newInstance(_config);            	
-
-    	// From here onwards, all attributes have a default value
-    	// process attribute
-    	tagName	= ListenerTagNames.PROCESS_METHOD_TAG;
-    	String sProcessMethod = _controller.obtainAtt(_config,tagName,tagName);
-    	_processMethod = _composerClass.getMethod(sProcessMethod,new Class[] {Message.class});
-
         // No problem if selector is null - everything in queue will be returned
         _messageSelector = _config.getAttribute(JMSEpr.MESSAGE_SELECTOR_TAG);
         
@@ -166,6 +159,32 @@
         prepareMessageReceiver();
     } // ________________________________
     
+    protected void resolveComposerClass() throws Exception
+    {
+        // Look for first "action" element - only first one will be used
+        String tagName = ListenerTagNames.ACTION_ELEMENT_TAG;
+        ConfigTree actionElement = _config.getFirstChild(tagName);
+        String sProcessMethod =  null;
+        if (null!=actionElement)
+        {	// class attribute
+            _composerName	= _controller.obtainAtt(actionElement,ListenerTagNames.ACTION_CLASS_TAG,null);
+            _composerClass = Class.forName(_composerName);
+        	Constructor oConst = _composerClass.getConstructor(new Class[] {ConfigTree.class});
+        	_composer= oConst.newInstance(_config);
+        	tagName	= ListenerTagNames.PROCESS_METHOD_TAG;
+        	sProcessMethod = _controller.obtainAtt(_config,tagName,tagName);
+        }
+        else
+        {
+        	_composerName = PackageJmsMessageContents.class.getName();
+        	_composerClass= PackageJmsMessageContents.class;
+        	_composer	= new PackageJmsMessageContents();
+        	sProcessMethod = "process";
+        }
+
+    	_processMethod = _composerClass.getMethod(sProcessMethod,new Class[] {Object.class});
+    } //________________________________
+
     private void prepareMessageReceiver() throws Exception
     {
         _queueConnection = null;
@@ -223,6 +242,54 @@
         return null;
     } //________________________________
     
+/**
+ * Default gateway action for plain jms messages
+ * <p/>It will just drop the jms message contents into a esb Message
+ * @author <a href="mailto:schifest at heuristica.com.ar">schifest at heuristica.com.ar</a>
+ * @since Version 4.0
+ *
+ */
+    private static class PackageJmsMessageContents
+    {
+    	public Message process (Object obj) throws Exception
+    	{
+    		if (! (obj instanceof javax.jms.Message))
+    			throw new Exception ("Object must be instance of javax.jms.Message");
+    		byte[] bytes = getMessageContent((javax.jms.Message)obj);
+    		if (null==bytes)
+    			return null;
+
+    		Message message = MessageFactory.getInstance().getMessage();
+    		message.getBody().setContents(getMessageContent((javax.jms.Message)obj));
+    		return message;
+    	}
+    	
+    	private byte[] getMessageContent(javax.jms.Message jMess) throws Exception
+    	{
+    		if (jMess instanceof TextMessage)
+    			return ((TextMessage)jMess).getText().getBytes();
+
+    		if (jMess instanceof BytesMessage)
+    		{	
+    			BytesMessage jBytes =(BytesMessage)jMess;
+	    		ByteArrayOutputStream out = new ByteArrayOutputStream();
+	    		byte[] ba = new byte[1000];
+	    		int iQread;
+	    		while (-1!= (iQread=jBytes.readBytes(ba)))
+	    			if (iQread > 0)
+	    				out.write(ba,0,iQread);
+	    		out.close();
+	    		return out.toByteArray();
+    		}
+
+    		if (jMess instanceof ObjectMessage)
+    			return ((ObjectMessage)jMess).getObject().toString().getBytes();
+    		_logger.warn("Message type "+jMess.getClass().getSimpleName()
+    				+" not supported - Message is ignored");
+    		return null;
+    	}
+    } //____________________________________________________
+
     protected final static Logger _logger = Logger.getLogger(JmsGatewayListener.class);
 
     protected String			_queueName;

Deleted: labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/gatewayExample.xml
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/gatewayExample.xml	2006-11-08 11:22:09 UTC (rev 7460)
+++ labs/jbossesb/trunk/product/core/listeners/src/org/jboss/soa/esb/listeners/gateway/gatewayExample.xml	2006-11-08 11:56:06 UTC (rev 7461)
@@ -1,18 +0,0 @@
-<GatewayListenerControllerExample
-	parameterReloadSecs="180"
->
-   <JmsGatewayExample
-    target-service-name="your target service name"
-    service-name="JmsGatewayService"
-   	listenerClass="org.jboss.soa.esb.listeners.gateway.JmsGatewayListener"
-	connection-factory="ConnectionFactory"
-	destination-type="queue"
-   	destination-name="queue/A"
-	jndi-type="jboss"
-    jndi-URL="localhost"
-    message-selector="service='composeExampleService'"
-   >
-	   <action class="org.jboss.soa.esb.message.listeners.MockComposer" process="composeEmptyMessage" />
-   </JmsGatewayExample>
-   
-</GatewayListenerControllerExample>

Modified: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java	2006-11-08 11:22:09 UTC (rev 7460)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/FileGatewayListenerUnitTest.java	2006-11-08 11:56:06 UTC (rev 7461)
@@ -1,3 +1,25 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * 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.soa.esb.listeners.gateway;
 
 import java.io.ByteArrayOutputStream;
@@ -17,16 +39,16 @@
 
 	private static final String TMP_DIR	= System.getProperty("java.io.tmpdir","/tmp"); 
 
-	private Logger _logger = Logger.getLogger(this.getClass());
-	static File _gatewayConfig		= new File(TMP_DIR,"gatewayConfig.xml");
-	static File _esbListenerConfig 	= new File(TMP_DIR,"esbListenerConfig.xml");
-	static File _returnFile			= new File(TMP_DIR,"messageBack.txt");
-	static File _droppedFile		= new File(TMP_DIR,"legacy.dat");
+	private Logger _logger			= Logger.getLogger(this.getClass());
+	static File _gatewayConfig		= new File(TMP_DIR,"fileGatewayConfig.xml");
+	static File _esbListenerConfig 	= new File(TMP_DIR,"fileEsbListenerConfig.xml");
+	static File _returnFile			= new File(TMP_DIR,"fileMessageBack.txt");
+	static File _droppedFile		= new File(TMP_DIR,"fileLegacy.dat");
 	static String POST_SUFFIX 		= ".sentToEsb";
 	static File _doneFile			= new File(_droppedFile.toString()+POST_SUFFIX);
 
-	
-	static String THE_TEXT = "This is the text that will travel around";
+	static String SERVICE_NAME	= "testFileGateway";
+	static String THE_TEXT		= "This is the FILE text that will travel around";
 
 	String _appServer		= System.getProperty("unit.test.appserver","localhost");
 	EsbListenerController	_esbListController;
@@ -72,10 +94,10 @@
         catch (Exception e) { }
     }
 	
-	public static class MockAction 
+	public static class MockMessageAwareAction 
 	{
 	    ConfigTree _config;
-	    public MockAction(ConfigTree config) { _config = config; } 
+	    public MockMessageAwareAction(ConfigTree config) { _config = config; } 
 	    public Message writeToDisk (Message message) throws Exception 
 	    {
 	    	bytesToFile(_returnFile, message.getBody().getContents());
@@ -90,7 +112,7 @@
 		.append("<FileGateway parameterReloadSecs=\"180\">\n")
 		 .append("  <GatewayConfig\n")
 		 .append("     target-service-category=\"eprManager\"\n")
-		 .append("     target-service-name=\"testService\"\n")
+		 .append("     target-service-name=\"").append(SERVICE_NAME).append("\"\n")
 		 .append("     gatewayClass=\"org.jboss.soa.esb.listeners.gateway.FileGatewayListener\"\n")
 		 .append("     pollLatencySeconds=\"5\"\n")
 		 .append("     inputDir=\"").append(TMP_DIR).append("\"\n")
@@ -110,7 +132,7 @@
 		.append("<DummyTester parameterReloadSecs=\"180\">\n")
 		.append("   <DummyActionConfig\n")
 		.append("   service-category=\"eprManager\"\n")
-		.append("	service-name=\"testService\"\n")
+		.append("	service-name=\"").append(SERVICE_NAME).append("\"\n")
 		.append("	service-description=\"My Dummy Service Name\"\n")
 		.append("	epr-description=\"EPR descriptionnnnnnnnnnnnnnn\"\n")		
 		.append("  	listenerClass=\"org.jboss.soa.esb.listeners.message.JmsQueueListener\"\n")
@@ -119,9 +141,9 @@
 		.append("	destination-name=\"queue/A\"\n")
 		.append("	jndi-type=\"jboss\"\n")
 		.append("	jndi-URL=\"").append(_appServer).append("\"\n")
-		.append("	message-selector=\"service='test'\"\n")
+		.append("	message-selector=\"service='testFileGateway'\"\n")
 		.append("	>\n")
-		.append("	   <action class=\"").append(MockAction.class.getName()).append("\" process=\"writeToDisk\" />\n")
+		.append("	   <action class=\"").append(MockMessageAwareAction.class.getName()).append("\" process=\"writeToDisk\" />\n")
 		.append("   </DummyActionConfig>\n")
 		.append("</DummyTester>\n")
 		;

Added: labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java	2006-11-08 11:22:09 UTC (rev 7460)
+++ labs/jbossesb/trunk/product/core/listeners/tests/src/org/jboss/soa/esb/listeners/gateway/JmsGatewayListenerUnitTest.java	2006-11-08 11:56:06 UTC (rev 7461)
@@ -0,0 +1,223 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * 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.soa.esb.listeners.gateway;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.OutputStream;
+
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.naming.Context;
+
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.eprs.JMSEpr;
+import org.jboss.soa.esb.common.tests.BaseTest;
+import org.jboss.soa.esb.helpers.AppServerContext;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.listeners.message.EsbListenerController;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.util.Util;
+
+public class JmsGatewayListenerUnitTest extends BaseTest 
+{
+
+	private static final String TMP_DIR	= System.getProperty("java.io.tmpdir","/tmp"); 
+
+	private Logger _logger			= Logger.getLogger(this.getClass());
+	static File _gatewayConfig		= new File(TMP_DIR,"jmsGatewayConfig.xml");
+	static File _esbListenerConfig 	= new File(TMP_DIR,"jmsEsbListenerConfig.xml");
+	static File _returnFile			= new File(TMP_DIR,"jmsMessageBack.txt");
+
+	
+	static String SERVICE_NAME	= "testJmsGateway";
+	static String THE_TEXT 		= "This is the JMS text that will travel around";
+
+	String _appServer		= System.getProperty("unit.test.appserver","localhost");
+	EsbListenerController	_esbListController;
+	GatewayListenerController _gatewayController;
+
+	public void setUp() throws Exception
+	{
+		_logger.info("Writing temp files to "+TMP_DIR);
+    	writeGatewayConfig();
+    	writeEsbListenerConfig();
+
+    	// delete this one just to make sure asserts take the new ones
+    	_returnFile.delete();
+    	
+    	// send a message so when gateway comes up, it will have something waiting
+    	sendJmsMessage(THE_TEXT);
+	}
+	
+	public void tearDown() throws Exception
+	{
+    	_gatewayConfig.delete();
+    	_esbListenerConfig.delete();
+    	_returnFile.delete();
+	}
+	
+	public void test_JmsGatewayListener() throws Exception 
+    {
+        try 
+        {
+    		_esbListController = new EsbListenerController(_esbListenerConfig.toString());
+    		new Thread(_esbListController).start();
+    		Thread.sleep(2000);
+    		_gatewayController = new GatewayListenerController(_gatewayConfig.toString());
+    		new Thread(_gatewayController).start();
+    		Thread.sleep(4000);
+
+    		_esbListController.requestEnd();
+    		_gatewayController.requestEnd();    
+    		
+    		assertEquals(THE_TEXT, stringFromFile(_returnFile));
+        } 
+        catch (Exception e) { }
+    }
+	
+	public static class MockMessageAwareAction 
+	{
+	    ConfigTree _config;
+	    public MockMessageAwareAction(ConfigTree config) { _config = config; } 
+	    public Message writeToDisk (Message message) throws Exception 
+	    {
+	    	bytesToFile(_returnFile, message.getBody().getContents());
+	    	return message;
+	    } // ________________________________
+
+	} // ___________________________________________________
+
+	void writeGatewayConfig() throws Exception
+	{
+		StringBuilder sb = new StringBuilder()
+		.append("<JmsGateway parameterReloadSecs=\"180\">\n")
+		 .append("  <GatewayConfig\n")
+		 .append("     target-service-category=\"eprManager\"\n")
+		 .append("     target-service-name=\"").append(SERVICE_NAME).append("\"\n")
+		 .append("     gatewayClass=\"org.jboss.soa.esb.listeners.gateway.JmsGatewayListener\"\n")
+		 .append("     connection-factory=\"ConnectionFactory\"\n")
+		 .append("     destination-type=\"queue\"\n")
+		 .append("     destination-name=\"queue/A\"\n")
+		 .append("     jndi-type=\"jboss\"\n")
+		 .append("     jndi-URL=\"").append(_appServer).append("\"\n")
+		 .append("     message-selector=\"messSelector='testJmsGateway'\"\n")
+		 .append("   >\n")
+		 .append("   </GatewayConfig>\n")
+		 .append("</JmsGateway>\n")
+		 ;
+		bytesToFile(_gatewayConfig, sb.toString().getBytes());
+		_logger.info("GatewayConfiguration\n"+stringFromFile(_gatewayConfig));
+	}
+	
+	void writeEsbListenerConfig() throws Exception
+	{
+		StringBuilder sb = new StringBuilder()
+		.append("<DummyTester parameterReloadSecs=\"180\">\n")
+		.append("   <DummyActionConfig\n")
+		.append("   service-category=\"eprManager\"\n")
+		.append("	service-name=\"").append(SERVICE_NAME).append("\"\n")
+		.append("	service-description=\"My Dummy Service Name\"\n")
+		.append("	epr-description=\"EPR descriptionnnnnnnnnnnnnnn\"\n")		
+		.append("  	listenerClass=\"org.jboss.soa.esb.listeners.message.JmsQueueListener\"\n")
+		.append("	connection-factory=\"ConnectionFactory\"\n")
+		.append("	destination-type=\"queue\"\n")
+		.append("	destination-name=\"queue/A\"\n")
+		.append("	jndi-type=\"jboss\"\n")
+		.append("	jndi-URL=\"").append(_appServer).append("\"\n")
+		.append("	message-selector=\"service='testJmsGateway'\"\n")
+		.append("	>\n")
+		.append("	   <action class=\"").append(MockMessageAwareAction.class.getName()).append("\" process=\"writeToDisk\" />\n")
+		.append("   </DummyActionConfig>\n")
+		.append("</DummyTester>\n")
+		;
+		bytesToFile(_esbListenerConfig, sb.toString().getBytes());
+		_logger.info("EsbListenerConfiguration\n"+stringFromFile(_esbListenerConfig));
+	}
+	
+	static void bytesToFile(File file, byte[] text) throws Exception
+	{
+		OutputStream out = new FileOutputStream(file);
+		out.write(text);
+		out.close();
+	}
+
+	static String stringFromFile(File file) throws Exception
+	{
+		ByteArrayOutputStream out = new ByteArrayOutputStream();
+
+		FileInputStream	inp = new FileInputStream(file);
+		byte[] ba = new byte[1000];
+		int iQ;
+		while (-1 != (iQ=inp.read(ba)))
+			if (iQ > 0)
+				out.write(ba,0,iQ);
+		inp.close();
+		
+		out.close();
+		return out.toString();
+	}
+	void sendJmsMessage(String text) throws Exception
+	{
+		ConfigTree tree = ConfigTree.fromInputStream(new FileInputStream(_gatewayConfig))
+				.getAllChildren()[0];
+        String sJndiType = tree.getAttribute(JMSEpr.JNDI_TYPE_TAG);
+        String sJndiURL = _appServer;
+        Context oJndiCtx = AppServerContext.getServerContext(sJndiType,sJndiURL);
+        String sFactoryClass = tree.getAttribute(JMSEpr.CONNECTION_FACTORY_TAG);
+        if (Util.isNullString(sFactoryClass))
+        	sFactoryClass = "ConnectionFactory";        
+        Object tmp = oJndiCtx.lookup(sFactoryClass);
+        
+        String sQname = tree.getAttribute(JMSEpr.DESTINATION_NAME_TAG);
+        javax.jms.Queue queue = (javax.jms.Queue) oJndiCtx.lookup(sQname);
+        QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
+        QueueConnection qConn = qcf.createQueueConnection();
+        QueueSession qSess = qConn.createQueueSession(false,QueueSession.AUTO_ACKNOWLEDGE);
+        javax.jms.Message jMess = qSess.createTextMessage(THE_TEXT);
+        String[] sa = tree.getAttribute(JMSEpr.MESSAGE_SELECTOR_TAG).split("=");
+        // strip apostrophes
+        String sVal = sa[1].substring(1).substring(0,-2+sa[1].length());
+        jMess.setStringProperty(sa[0],sVal);
+        MessageProducer producer = qSess.createProducer(queue);
+
+        producer.send(jMess);
+        
+		if (null != producer)
+			try { producer.close(); }
+			catch (JMSException e) {/*  OK do nothing  */ }
+		if (null != qSess)
+			try { qSess.close(); }
+			catch (JMSException e) {/*  OK do nothing  */ }
+		if (null != qConn)
+			try { qConn.close(); }
+			catch (JMSException e) {/*  OK do nothing  */ }
+        
+    } //________________________________
+
+}

Added: labs/jbossesb/trunk/product/etc/examples/listeners/gatewayExample.xml
===================================================================
--- labs/jbossesb/trunk/product/etc/examples/listeners/gatewayExample.xml	2006-11-08 11:22:09 UTC (rev 7460)
+++ labs/jbossesb/trunk/product/etc/examples/listeners/gatewayExample.xml	2006-11-08 11:56:06 UTC (rev 7461)
@@ -0,0 +1,18 @@
+<GatewayListenerControllerExample
+	parameterReloadSecs="180"
+>
+   <JmsGatewayExample
+    target-service-name="your target service name"
+    service-name="JmsGatewayService"
+   	listenerClass="org.jboss.soa.esb.listeners.gateway.JmsGatewayListener"
+	connection-factory="ConnectionFactory"
+	destination-type="queue"
+   	destination-name="queue/A"
+	jndi-type="jboss"
+    jndi-URL="localhost"
+    message-selector="service='composeExampleService'"
+   >
+	   <action class="org.jboss.soa.esb.message.listeners.MockComposer" process="composeEmptyMessage" />
+   </JmsGatewayExample>
+   
+</GatewayListenerControllerExample>




More information about the jboss-svn-commits mailing list