[jboss-svn-commits] JBL Code SVN: r23919 - in labs/jbossesb/workspace/skeagh: examples/jms-router/esb-jms-router and 34 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Nov 18 07:13:26 EST 2008
Author: beve
Date: 2008-11-18 07:13:26 -0500 (Tue, 18 Nov 2008)
New Revision: 23919
Added:
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/run.bat
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/JmsClient.java
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/MyTestService.java
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jboss-esb.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jndi.properties
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/log4j.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/jbossesb/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/jbossesb/busconfig/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/jbossesb/busconfig/jms/
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties
labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/log4j.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/pom.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/esb/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/esb/examples/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/esb/examples/jmsrouter/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/esb/examples/jmsrouter/JmsConsumer.java
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/jndi.properties
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/log4j.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/test/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/test/resources/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/test/resources/log4j.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/activemq.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/pom.xml
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposer.java
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposerImpl.java
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposer.java
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposerImpl.java
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/package.html
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/package.html
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/EsbMessageComposerImplTest.java
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/JmsMessageComposerImplTest.java
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml
Removed:
labs/jbossesb/workspace/skeagh/examples/jms-router/activemq.xml
labs/jbossesb/workspace/skeagh/examples/jms-router/config.properties
labs/jbossesb/workspace/skeagh/examples/jms-router/src/
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInformationExtractor.java
labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInformationExtractorTest.java
Modified:
labs/jbossesb/workspace/skeagh/examples/jms-router/README.TXT
labs/jbossesb/workspace/skeagh/examples/jms-router/pom.xml
labs/jbossesb/workspace/skeagh/routing/jms/pom.xml
labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
Log:
work for https://jira.jboss.org/jira/browse/JBESB-2013 "Create Inbound and Outbound routers for JMS"
Modified: labs/jbossesb/workspace/skeagh/examples/jms-router/README.TXT
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/README.TXT 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/README.TXT 2008-11-18 12:13:26 UTC (rev 23919)
@@ -1,8 +1,7 @@
About This Example:
===================
- This example illustrates a simple JBossESB 5.0 JMS Router.
+ This example illustrates a simple JBossESB 5.0 JMS Inbound and Outbound Routers.
-
How to Run?
===========
Requirements:
@@ -10,12 +9,47 @@
2. Maven 2.x (http://maven.apache.org/download.html)
Running:
- 1. run "mvn activemq:run". This starts the JMS Provider.
+ 1. From the jms-provider directory run:
+ "mvn activemq:run"
+ This starts the JMS Provider.
2. Open a new console window ("Window 2")
- 3. run "mvn clean install pax:provision". This starts the OSGi container (Felix) and deploys the ESB.
- 4. Open a new console window ("Window 3")
- 3. run "mvn exec:java". This publishes a JMS Message to the JMS Queue that will trigger the ESB process.
+ 3. From the jms-consumer directory run:
+ "mvn exec:java"
+ This starts a JMS Consumer that listens to the outbound routers queue.
+ 6. Open a new console window ("Window 3")
+ 7. From the esb-jms-router directory run:
+ "mvn pax:provision"
+ This will start JBossESB in OSGi container Felix.
+ 4. Open a new console window ("Window 4")
+ 5. From the esb-jms-router directory run:
+ "mvn exec:java"
+ Type something at the command line and hit return. The text typed will become the message payload.
+ This will post a JMS Message to the inbound routers queue.
+ To exit the client type CTRL-C.
+ We recommend that you setup the windows so they call can be seen at the same time. The jms-provider
+ window does not need to be visible as no output is expected to it.
+
+Expected output
+===============
+ "Window 4" (JMS Client):
+ > Specify message payload test >some text
+ Sent message [ID:danbev-laptop-41003-1227008237853-1:0:1:1:1] to [jbossesb.TestQueue]
+
+ "Window 3" (esb service deployment):
+ ---------------------------------------------------------------------->
+ Message payload 'some text'
+ <----------------------------------------------------------------------
+
+ "Window 2" (jms-consumer):
+ [ Received Message[1]
+ [JMSMessageID : ID:danbev-laptop-54663-1227008186571-1:0:1:1:1]
+ [JMSCorrelelationID : ID:danbev-laptop-41003-1227008237853-1:0:1:1:1]
+ [MessageType : TextMessage]
+ [Text :
+ some text]
+ ]
+
Things to try
=============
At the felix commmand prompt ("Window 2"):
Deleted: labs/jbossesb/workspace/skeagh/examples/jms-router/activemq.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/activemq.xml 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/activemq.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -1,20 +0,0 @@
-<beans
- xmlns="http://www.springframework.org/schema/beans"
- xmlns:amq="http://activemq.org/config/1.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://activemq.org/config/1.0 http://activemq.apache.org/schema/activemq-core.xsd
- http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
-
- <!-- Allows us to use system properties as variables in this configuration file -->
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
-
- <broker xmlns="http://activemq.org/config/1.0" useJmx="false" dataDirectory="${activemq.base}/target/activemq">
-
- <transportConnectors>
- <transportConnector uri="tcp://localhost:61717"/>
- </transportConnectors>
-
- </broker>
-
-</beans>
\ No newline at end of file
Deleted: labs/jbossesb/workspace/skeagh/examples/jms-router/config.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/config.properties 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/config.properties 2008-11-18 12:13:26 UTC (rev 23919)
@@ -1,485 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-#
-# Framework config properties.
-#
-org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \
- org.osgi.service.packageadmin; version=1.2.0, \
- org.osgi.service.startlevel; version=1.1.0, \
- org.osgi.service.url; version=1.0.0, \
- org.osgi.util.tracker; version=1.3.3 \
- ${jre-${java.specification.version}}
-
-m2.path=${user.home}/.m2/repository
-apache.m2.path=${m2.path}/org/apache
-jbossesb.m2.path=${m2.path}/jboss/jbossesb
-
-#org.osgi.framework.bootdelegation=sun.*,com.sun.*
-#felix.cache.profile=foo
-felix.auto.start.1= \
- "file:${apache.m2.path}/felix/org.apache.felix.shell/1.0.2/org.apache.felix.shell-1.0.2.jar" \
- "file:${apache.m2.path}/felix/org.apache.felix.shell.tui/1.0.2/org.apache.felix.shell.tui-1.0.2.jar" \
- "file:${apache.m2.path}/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar" \
- "file:${jbossesb.m2.path}/jbossesb-api/5.0-SNAPSHOT/jbossesb-api-5.0-SNAPSHOT.jar" \
- "file:${jbossesb.m2.path}/jbossesb-osgi-runtime/5.0-SNAPSHOT/jbossesb-osgi-runtime-5.0-SNAPSHOT.jar" \
- "file:${jbossesb.m2.path}/jbossesb-routing-jms/5.0-SNAPSHOT/jbossesb-routing-jms-5.0-SNAPSHOT.jar" \
- "file:${jbossesb.m2.path}/jbossesb-examples-helloworld/5.0-SNAPSHOT/jbossesb-examples-helloworld-5.0-SNAPSHOT.jar"
-
-felix.log.level=1
-felix.startlevel.framework=1
-felix.startlevel.bundle=1
-#felix.service.urlhandlers=false
-
-#
-# Bundle config properties.
-#
-org.osgi.service.http.port=8080
-osgi.shell.telnet=on
-obr.repository.url=http://felix.apache.org/obr/releases.xml
-
-
-#
-# Java platform package export properties.
-#
-jre-1.3=, \
- javax.accessibility; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- version="1.3.0"
-
-jre-1.4=, \
- javax.accessibility; \
- javax.crypto; \
- javax.crypto.interfaces; \
- javax.crypto.spec; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml.parsers; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stream; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.w3c.dom; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version="1.4.0"
-
-jre-1.5=, \
- javax.accessibility; \
- javax.activity; \
- javax.crypto; \
- javax.crypto.interfaces; \
- javax.crypto.spec; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.bmp; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.management; \
- javax.management.loading; \
- javax.management.modelmbean; \
- javax.management.monitor; \
- javax.management.openmbean; \
- javax.management.relation; \
- javax.management.remote; \
- javax.management.remote.rmi; \
- javax.management.timer; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.rmi.ssl; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.security.sasl; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.sql.rowset; \
- javax.sql.rowset.serial; \
- javax.sql.rowset.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.plaf.synth; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml; \
- javax.xml.datatype; \
- javax.xml.namespace; \
- javax.xml.parsers; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stream; \
- javax.xml.validation; \
- javax.xml.xpath; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.omg.stub.javax.management.remote.rmi; \
- org.w3c.dom; \
- org.w3c.dom.bootstrap; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.ls; \
- org.w3c.dom.ranges; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version="1.5.0"
-
-jre-1.6=, \
- javax.accessibility; \
- javax.activation; \
- javax.activity; \
- javax.annotation; \
- javax.annotation.processing; \
- javax.crypto; \
- javax.crypto.interfaces; \
- javax.crypto.spec; \
- javax.imageio; \
- javax.imageio.event; \
- javax.imageio.metadata; \
- javax.imageio.plugins.bmp; \
- javax.imageio.plugins.jpeg; \
- javax.imageio.spi; \
- javax.imageio.stream; \
- javax.jws; \
- javax.jws.soap; \
- javax.lang.model; \
- javax.lang.model.element; \
- javax.lang.model.type; \
- javax.lang.model.util; \
- javax.management; \
- javax.management.loading; \
- javax.management.modelmbean; \
- javax.management.monitor; \
- javax.management.openmbean; \
- javax.management.relation; \
- javax.management.remote; \
- javax.management.remote.rmi; \
- javax.management.timer; \
- javax.naming; \
- javax.naming.directory; \
- javax.naming.event; \
- javax.naming.ldap; \
- javax.naming.spi; \
- javax.net; \
- javax.net.ssl; \
- javax.print; \
- javax.print.attribute; \
- javax.print.attribute.standard; \
- javax.print.event; \
- javax.rmi; \
- javax.rmi.CORBA; \
- javax.rmi.ssl; \
- javax.script; \
- javax.security.auth; \
- javax.security.auth.callback; \
- javax.security.auth.kerberos; \
- javax.security.auth.login; \
- javax.security.auth.spi; \
- javax.security.auth.x500; \
- javax.security.cert; \
- javax.security.sasl; \
- javax.sound.midi; \
- javax.sound.midi.spi; \
- javax.sound.sampled; \
- javax.sound.sampled.spi; \
- javax.sql; \
- javax.sql.rowset; \
- javax.sql.rowset.serial; \
- javax.sql.rowset.spi; \
- javax.swing; \
- javax.swing.border; \
- javax.swing.colorchooser; \
- javax.swing.event; \
- javax.swing.filechooser; \
- javax.swing.plaf; \
- javax.swing.plaf.basic; \
- javax.swing.plaf.metal; \
- javax.swing.plaf.multi; \
- javax.swing.plaf.synth; \
- javax.swing.table; \
- javax.swing.text; \
- javax.swing.text.html; \
- javax.swing.text.html.parser; \
- javax.swing.text.rtf; \
- javax.swing.tree; \
- javax.swing.undo; \
- javax.tools; \
- javax.transaction; \
- javax.transaction.xa; \
- javax.xml; \
- javax.xml.bind; \
- javax.xml.bind.annotation; \
- javax.xml.bind.annotation.adapters; \
- javax.xml.bind.attachment; \
- javax.xml.bind.helpers; \
- javax.xml.bind.util; \
- javax.xml.crypto; \
- javax.xml.crypto.dom; \
- javax.xml.crypto.dsig; \
- javax.xml.crypto.dsig.dom; \
- javax.xml.crypto.dsig.keyinfo; \
- javax.xml.crypto.dsig.spec; \
- javax.xml.datatype; \
- javax.xml.namespace; \
- javax.xml.parsers; \
- javax.xml.soap; \
- javax.xml.stream; \
- javax.xml.stream.events; \
- javax.xml.stream.util; \
- javax.xml.transform; \
- javax.xml.transform.dom; \
- javax.xml.transform.sax; \
- javax.xml.transform.stax; \
- javax.xml.transform.stream; \
- javax.xml.validation; \
- javax.xml.ws; \
- javax.xml.ws.handler; \
- javax.xml.ws.handler.soap; \
- javax.xml.ws.http; \
- javax.xml.ws.soap; \
- javax.xml.ws.spi; \
- javax.xml.xpath; \
- org.ietf.jgss; \
- org.omg.CORBA; \
- org.omg.CORBA_2_3; \
- org.omg.CORBA_2_3.portable; \
- org.omg.CORBA.DynAnyPackage; \
- org.omg.CORBA.ORBPackage; \
- org.omg.CORBA.portable; \
- org.omg.CORBA.TypeCodePackage; \
- org.omg.CosNaming; \
- org.omg.CosNaming.NamingContextExtPackage; \
- org.omg.CosNaming.NamingContextPackage; \
- org.omg.Dynamic; \
- org.omg.DynamicAny; \
- org.omg.DynamicAny.DynAnyFactoryPackage; \
- org.omg.DynamicAny.DynAnyPackage; \
- org.omg.IOP; \
- org.omg.IOP.CodecFactoryPackage; \
- org.omg.IOP.CodecPackage; \
- org.omg.Messaging; \
- org.omg.PortableInterceptor; \
- org.omg.PortableInterceptor.ORBInitInfoPackage; \
- org.omg.PortableServer; \
- org.omg.PortableServer.CurrentPackage; \
- org.omg.PortableServer.POAManagerPackage; \
- org.omg.PortableServer.POAPackage; \
- org.omg.PortableServer.portable; \
- org.omg.PortableServer.ServantLocatorPackage; \
- org.omg.SendingContext; \
- org.omg.stub.java.rmi; \
- org.omg.stub.javax.management.remote.rmi; \
- org.w3c.dom; \
- org.w3c.dom.bootstrap; \
- org.w3c.dom.css; \
- org.w3c.dom.events; \
- org.w3c.dom.html; \
- org.w3c.dom.ls; \
- org.w3c.dom.ranges; \
- org.w3c.dom.stylesheets; \
- org.w3c.dom.traversal; \
- org.w3c.dom.views; \
- org.w3c.dom.xpath; \
- org.xml.sax; \
- org.xml.sax.ext; \
- org.xml.sax.helpers; \
- version=\"1.6.0\"
Property changes on: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/config.properties 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,485 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+#
+# Framework config properties.
+#
+org.osgi.framework.system.packages=org.osgi.framework; version=1.4.0, \
+ org.osgi.service.packageadmin; version=1.2.0, \
+ org.osgi.service.startlevel; version=1.1.0, \
+ org.osgi.service.url; version=1.0.0, \
+ org.osgi.util.tracker; version=1.3.3 \
+ ${jre-${java.specification.version}}
+
+m2.path=${user.home}/.m2/repository
+apache.m2.path=${m2.path}/org/apache
+jbossesb.m2.path=${m2.path}/jboss/jbossesb
+
+#org.osgi.framework.bootdelegation=sun.*,com.sun.*
+#felix.cache.profile=foo
+felix.auto.start.1= \
+ "file:${apache.m2.path}/felix/org.apache.felix.shell/1.0.2/org.apache.felix.shell-1.0.2.jar" \
+ "file:${apache.m2.path}/felix/org.apache.felix.shell.tui/1.0.2/org.apache.felix.shell.tui-1.0.2.jar" \
+ "file:${apache.m2.path}/geronimo/specs/geronimo-jms_1.1_spec/1.1.1/geronimo-jms_1.1_spec-1.1.1.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-api/5.0-SNAPSHOT/jbossesb-api-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-osgi-runtime/5.0-SNAPSHOT/jbossesb-osgi-runtime-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-routing-jms/5.0-SNAPSHOT/jbossesb-routing-jms-5.0-SNAPSHOT.jar" \
+ "file:${jbossesb.m2.path}/jbossesb-examples-helloworld/5.0-SNAPSHOT/jbossesb-examples-helloworld-5.0-SNAPSHOT.jar"
+
+felix.log.level=1
+felix.startlevel.framework=1
+felix.startlevel.bundle=1
+#felix.service.urlhandlers=false
+
+#
+# Bundle config properties.
+#
+org.osgi.service.http.port=8080
+osgi.shell.telnet=on
+obr.repository.url=http://felix.apache.org/obr/releases.xml
+
+
+#
+# Java platform package export properties.
+#
+jre-1.3=, \
+ javax.accessibility; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ version="1.3.0"
+
+jre-1.4=, \
+ javax.accessibility; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.4.0"
+
+jre-1.5=, \
+ javax.accessibility; \
+ javax.activity; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.bmp; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.management; \
+ javax.management.loading; \
+ javax.management.modelmbean; \
+ javax.management.monitor; \
+ javax.management.openmbean; \
+ javax.management.relation; \
+ javax.management.remote; \
+ javax.management.remote.rmi; \
+ javax.management.timer; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.rmi.ssl; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.security.sasl; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.sql.rowset; \
+ javax.sql.rowset.serial; \
+ javax.sql.rowset.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.plaf.synth; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml; \
+ javax.xml.datatype; \
+ javax.xml.namespace; \
+ javax.xml.parsers; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stream; \
+ javax.xml.validation; \
+ javax.xml.xpath; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.omg.stub.javax.management.remote.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.bootstrap; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.ls; \
+ org.w3c.dom.ranges; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version="1.5.0"
+
+jre-1.6=, \
+ javax.accessibility; \
+ javax.activation; \
+ javax.activity; \
+ javax.annotation; \
+ javax.annotation.processing; \
+ javax.crypto; \
+ javax.crypto.interfaces; \
+ javax.crypto.spec; \
+ javax.imageio; \
+ javax.imageio.event; \
+ javax.imageio.metadata; \
+ javax.imageio.plugins.bmp; \
+ javax.imageio.plugins.jpeg; \
+ javax.imageio.spi; \
+ javax.imageio.stream; \
+ javax.jws; \
+ javax.jws.soap; \
+ javax.lang.model; \
+ javax.lang.model.element; \
+ javax.lang.model.type; \
+ javax.lang.model.util; \
+ javax.management; \
+ javax.management.loading; \
+ javax.management.modelmbean; \
+ javax.management.monitor; \
+ javax.management.openmbean; \
+ javax.management.relation; \
+ javax.management.remote; \
+ javax.management.remote.rmi; \
+ javax.management.timer; \
+ javax.naming; \
+ javax.naming.directory; \
+ javax.naming.event; \
+ javax.naming.ldap; \
+ javax.naming.spi; \
+ javax.net; \
+ javax.net.ssl; \
+ javax.print; \
+ javax.print.attribute; \
+ javax.print.attribute.standard; \
+ javax.print.event; \
+ javax.rmi; \
+ javax.rmi.CORBA; \
+ javax.rmi.ssl; \
+ javax.script; \
+ javax.security.auth; \
+ javax.security.auth.callback; \
+ javax.security.auth.kerberos; \
+ javax.security.auth.login; \
+ javax.security.auth.spi; \
+ javax.security.auth.x500; \
+ javax.security.cert; \
+ javax.security.sasl; \
+ javax.sound.midi; \
+ javax.sound.midi.spi; \
+ javax.sound.sampled; \
+ javax.sound.sampled.spi; \
+ javax.sql; \
+ javax.sql.rowset; \
+ javax.sql.rowset.serial; \
+ javax.sql.rowset.spi; \
+ javax.swing; \
+ javax.swing.border; \
+ javax.swing.colorchooser; \
+ javax.swing.event; \
+ javax.swing.filechooser; \
+ javax.swing.plaf; \
+ javax.swing.plaf.basic; \
+ javax.swing.plaf.metal; \
+ javax.swing.plaf.multi; \
+ javax.swing.plaf.synth; \
+ javax.swing.table; \
+ javax.swing.text; \
+ javax.swing.text.html; \
+ javax.swing.text.html.parser; \
+ javax.swing.text.rtf; \
+ javax.swing.tree; \
+ javax.swing.undo; \
+ javax.tools; \
+ javax.transaction; \
+ javax.transaction.xa; \
+ javax.xml; \
+ javax.xml.bind; \
+ javax.xml.bind.annotation; \
+ javax.xml.bind.annotation.adapters; \
+ javax.xml.bind.attachment; \
+ javax.xml.bind.helpers; \
+ javax.xml.bind.util; \
+ javax.xml.crypto; \
+ javax.xml.crypto.dom; \
+ javax.xml.crypto.dsig; \
+ javax.xml.crypto.dsig.dom; \
+ javax.xml.crypto.dsig.keyinfo; \
+ javax.xml.crypto.dsig.spec; \
+ javax.xml.datatype; \
+ javax.xml.namespace; \
+ javax.xml.parsers; \
+ javax.xml.soap; \
+ javax.xml.stream; \
+ javax.xml.stream.events; \
+ javax.xml.stream.util; \
+ javax.xml.transform; \
+ javax.xml.transform.dom; \
+ javax.xml.transform.sax; \
+ javax.xml.transform.stax; \
+ javax.xml.transform.stream; \
+ javax.xml.validation; \
+ javax.xml.ws; \
+ javax.xml.ws.handler; \
+ javax.xml.ws.handler.soap; \
+ javax.xml.ws.http; \
+ javax.xml.ws.soap; \
+ javax.xml.ws.spi; \
+ javax.xml.xpath; \
+ org.ietf.jgss; \
+ org.omg.CORBA; \
+ org.omg.CORBA_2_3; \
+ org.omg.CORBA_2_3.portable; \
+ org.omg.CORBA.DynAnyPackage; \
+ org.omg.CORBA.ORBPackage; \
+ org.omg.CORBA.portable; \
+ org.omg.CORBA.TypeCodePackage; \
+ org.omg.CosNaming; \
+ org.omg.CosNaming.NamingContextExtPackage; \
+ org.omg.CosNaming.NamingContextPackage; \
+ org.omg.Dynamic; \
+ org.omg.DynamicAny; \
+ org.omg.DynamicAny.DynAnyFactoryPackage; \
+ org.omg.DynamicAny.DynAnyPackage; \
+ org.omg.IOP; \
+ org.omg.IOP.CodecFactoryPackage; \
+ org.omg.IOP.CodecPackage; \
+ org.omg.Messaging; \
+ org.omg.PortableInterceptor; \
+ org.omg.PortableInterceptor.ORBInitInfoPackage; \
+ org.omg.PortableServer; \
+ org.omg.PortableServer.CurrentPackage; \
+ org.omg.PortableServer.POAManagerPackage; \
+ org.omg.PortableServer.POAPackage; \
+ org.omg.PortableServer.portable; \
+ org.omg.PortableServer.ServantLocatorPackage; \
+ org.omg.SendingContext; \
+ org.omg.stub.java.rmi; \
+ org.omg.stub.javax.management.remote.rmi; \
+ org.w3c.dom; \
+ org.w3c.dom.bootstrap; \
+ org.w3c.dom.css; \
+ org.w3c.dom.events; \
+ org.w3c.dom.html; \
+ org.w3c.dom.ls; \
+ org.w3c.dom.ranges; \
+ org.w3c.dom.stylesheets; \
+ org.w3c.dom.traversal; \
+ org.w3c.dom.views; \
+ org.w3c.dom.xpath; \
+ org.xml.sax; \
+ org.xml.sax.ext; \
+ org.xml.sax.helpers; \
+ version=\"1.6.0\"
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/pom.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-examples-jms-router</artifactId>
+ <version>${jboss.esb.version}</version>
+ </parent>
+ <name>JBoss ESB - JMS Router Example (ESB)</name>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-examples-jms-router-esb-jms-router</artifactId>
+ <version>${jboss.esb.version}</version>
+ <url>http://www.jboss.org/jbossesb/</url>
+ <packaging>bundle</packaging>
+
+ <properties>
+ <felix.log.level>1</felix.log.level><!-- 4=debug -->
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.main</artifactId>
+ <version>1.2.1</version>
+ </dependency>
+
+ <!-- JBossESB OSGi bundle -->
+ <dependency>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-api</artifactId>
+ <version>${jboss.esb.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-osgi-runtime</artifactId>
+ <version>${jboss.esb.version}</version>
+ </dependency>
+
+ <!-- JBossESB JMS Routing bundle -->
+ <dependency>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-routing-jms</artifactId>
+ <version>${jboss.esb.version}</version>
+ </dependency>
+
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <configuration>
+ <executable>java</executable>
+ <mainClass>org.jboss.esb.examples.jmsrouter.JmsClient</mainClass>
+ <arguments>
+ <argument>jbossesb.TestQueue</argument>
+ <!--argument>Message payload text...</argument-->
+ </arguments>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.ops4j</groupId>
+ <artifactId>maven-pax-plugin</artifactId>
+ <version>1.3</version>
+ <extensions>true</extensions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.0</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>org.jboss.esb.examples.jmsrouter, org.apache.activemq.jndi</Export-Package>
+ <Import-Package>org.jboss.esb.jms, org.jboss.esb.api.*, *;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
+ <Embed-Dependency>activemq-core, backport-util-concurrent, log4j, commons-logging, geronimo-j2ee-management_1.1_spec</Embed-Dependency>
+ <Embed-Transitive>true</Embed-Transitive>
+ <JBossESB-ConfigFile>/jboss-esb.xml</JBossESB-ConfigFile>
+ <JBossESB-DeploymentName>TestDeploymentName</JBossESB-DeploymentName>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/run.bat
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/run.bat (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/run.bat 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,15 @@
+ at echo off
+
+setlocal
+
+set JAVA_OPTS=
+
+if "%1" == "-debug" (
+ set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y %JAVA_OPTS%
+)
+
+set FELIX_JAR="%USERPROFILE%\.m2\repository\org\apache\felix\org.apache.felix.main\1.2.1\org.apache.felix.main-1.2.1.jar"
+
+"%JAVA_HOME%\bin\java" %JAVA_OPTS% -jar %FELIX_JAR%
+
+endlocal
\ No newline at end of file
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/JmsClient.java
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/JmsClient.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/JmsClient.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,216 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.examples.jmsrouter;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageProducer;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ * Client that post a message to a JMS destination.
+ * <p/>
+ * Usage:
+ * java org.jboss.esb.examples.JmsClient destination
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public final class JmsClient
+{
+ private MessageProducer messageProducer;
+ private QueueConnection qConnection;
+ private QueueSession qSession;
+
+ /**
+ * Private constructor.
+ */
+ private JmsClient()
+ {
+ }
+
+ /**
+ * Main method.
+ *
+ * @param args - the arguments from the command line. See class javadoc for usage
+ * @throws NamingException
+ * @throws JMSException
+ */
+ public static void main(final String... args) throws JMSException, NamingException
+ {
+ if (args.length < 1)
+ {
+ printUsage();
+ System.exit(-1);
+ }
+
+ final String destinationName = args[0];
+ final JmsClient jmsClient = new JmsClient();
+ jmsClient.setupMessageProducer(destinationName);
+
+ addShutdownHook(jmsClient);
+
+ while (true)
+ {
+ try
+ {
+ jmsClient.sendMessage(jmsClient.getPayload(), destinationName);
+ }
+ catch (final JMSException e)
+ {
+ e.printStackTrace();
+ }
+ catch (NamingException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * @param destinationName - the jms destination to send to
+ * @throws JMSException - is a JMS exception is thrown
+ * @throws NamingException - if a JNDI lookup failes
+ */
+ private void setupMessageProducer(final String destinationName) throws JMSException, NamingException
+ {
+ final InitialContext ctx = new InitialContext();
+
+ QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
+ qConnection = factory.createQueueConnection();
+ qConnection.start();
+
+ qSession = qConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ messageProducer = qSession.createProducer((Destination)ctx.lookup(destinationName));
+ }
+
+ /**
+ *
+ * @param payload - the payload to send
+ * @param destinationName - the jms destination to send to
+ * @throws JMSException - is a JMS exception is thrown
+ * @throws NamingException - if a JNDI lookup failes
+ */
+ private void sendMessage(final String payload, final String destinationName) throws JMSException, NamingException
+ {
+ final TextMessage textMessage = qSession.createTextMessage(payload);
+ messageProducer.send(textMessage);
+ System.out.println("Sent message [" + textMessage.getJMSMessageID() + "] to [" + destinationName + "]");
+ }
+
+ private static void printUsage(final String... args)
+ {
+ System.err.println("*****************************************************************************");
+ System.err.println("Usage: ");
+ System.err.println("java org.jboss.esb.examples.JmsClient destination ");
+ System.err.println("");
+ System.err.println("Arguments provided:");
+ System.err.println(Arrays.asList(args));
+ System.err.println("*****************************************************************************");
+ }
+
+ /**
+ * Prompts for the message payload to be entered from the command line.
+ *
+ * @param message The message to be displayed to the user.
+ * @return String The text typed at the command line by the user.
+ */
+ private static String getPayloadFromCommandLine(final String message)
+ {
+ try
+ {
+ BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
+ System.out.print("> " + message);
+ return in.readLine();
+ }
+ catch (final IOException e)
+ {
+ e.printStackTrace();
+ }
+ System.out.println(System.getProperty("line.separator"));
+ return null;
+ }
+
+ private String getPayload()
+ {
+ return getPayloadFromCommandLine("Specify message payload test >");
+ }
+
+ private void shutdown()
+ {
+ if (messageProducer != null)
+ {
+ try
+ {
+ messageProducer.close();
+ }
+ catch (final JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ if (qSession != null)
+ {
+ try
+ {
+ qSession.close();
+ }
+ catch (final JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ if (qConnection != null)
+ {
+ try
+ {
+ qConnection.close();
+ }
+ catch (final JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private static void addShutdownHook(final JmsClient jmsClient)
+ {
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ @Override
+ public void run()
+ {
+ jmsClient.shutdown();
+ }
+ });
+ }
+}
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/MyTestService.java
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/MyTestService.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/java/org/jboss/esb/examples/jmsrouter/MyTestService.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,47 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright XXXX, Red Hat Middleware LLC, 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-2008, JBoss Inc.
+ */
+package org.jboss.esb.examples.jmsrouter;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.service.Service;
+import org.jboss.esb.api.service.ServiceException;
+
+/**
+ * Simple Test service.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ */
+public final class MyTestService implements Service
+{
+ /**
+ * Processes the message.
+ * @param msg - the esb message object instance.
+ * @return Messsage - the esb message object instance.
+ * @throws ServiceException - if an exception occurs during processing.
+ */
+ public Message process(final Message msg) throws ServiceException
+ {
+ System.out.println("---------------------------------------------------------------------->");
+ System.out.println("Message payload '" + msg.getPayload() + "'");
+ System.out.println("<----------------------------------------------------------------------");
+ return msg;
+ }
+
+}
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jboss-esb.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jboss-esb.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jboss-esb.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,16 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+ <services>
+ <service serviceCategory="examples" serviceName="helloworld" serviceDescription="First Example" class="org.jboss.esb.examples.jmsrouter.MyTestService">
+ <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
+ <property name="java.naming.provider.url">tcp://localhost:61717</property>
+ <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
+ <property name="jmsDestination">dynamicQueues/jbossesb.TestQueue</property>
+ </inRouter>
+ <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
+ <property name="jmsDestination">jbossesb.TestOutQueue</property>
+ <property name="java.naming.provider.url">tcp://localhost:61717</property>
+ <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
+ </outRouter>
+ </service>
+ </services>
+</jbossesb>
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jndi.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jndi.properties (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/jndi.properties 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,17 @@
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+connectionFactoryNames = connectionFactory, ConnectionFactory, queueConnectionFactory, topicConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.jbossesb.TestQueue = jbossesb.TestQueue
+queue.jbossesb.TestOutQueue = jbossesb.TestOutQueue
+
+queue.jbossesb.jms.bus = jbossesb.jms.bus
+
+# register some topics in JNDI using the form
+# topic.[jndiName] = [physicalName]
+topic.jbossesb.deployment.coordintation.topic = jbossesb.deployment.coordintation.topic
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/log4j.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/main/resources/log4j.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+
+ <category name="org.milyn">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.quartz">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.jboss.esb">
+ <priority value="debug"/>
+ </category>
+
+ <category name="org.jboss.esb.examples.helloworld">
+ <priority value="info"/>
+ </category>
+
+ <category name="org.apache.activemq">
+ <priority value="ERROR"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
+
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/META-INF/jbossesb/busconfig/jms/default.properties 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,20 @@
+###########################################################################################
+# Default JMS bus config for testing.
+#
+# Using ActiveMQ because it's so easy to embed. Apparently JBM v2.0 will also be
+# easy to embed. We might be able to switch to that then!!
+##########################################################################################
+
+# JNDI Settings...
+# NOTE: The JNDI settings in this config file must be the same as those
+# set in the JMSTestRunner class!!
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# Bus Queues and Topics...
+deployment.coordintation.topic=jbossesb.deployment.coordintation.topic
+deployment.bus.queue=jbossesb.jms.bus
+
+# ActiveMQ Queue and Topic deployments...
+topic.jbossesb.deployment.coordintation.topic=jbossesb.deployment.coordintation.topic
+queue.jbossesb.jms.bus=jbossesb.jms.bus
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/log4j.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/esb-jms-router/src/test/resources/log4j.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+
+ <category name="org.milyn">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.quartz">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.jboss">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.jboss.esb.examples.helloworld">
+ <priority value="info"/>
+ </category>
+
+ <category name="org.apache.activemq">
+ <priority value="ERROR"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
+
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/pom.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/pom.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-examples-jms-router</artifactId>
+ <version>${jboss.esb.version}</version>
+ </parent>
+ <name>JBoss ESB - JMS Router Example (Consumer)</name>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-examples-jms-router-consumer</artifactId>
+ <version>${jboss.esb.version}</version>
+ <url>http://www.jboss.org/jbossesb/</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>exec-maven-plugin</artifactId>
+ <configuration>
+ <executable>java</executable>
+ <mainClass>org.jboss.esb.examples.jmsrouter.JmsConsumer</mainClass>
+ <arguments>
+ <argument>jbossesb.TestOutQueue</argument>
+ </arguments>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/esb/examples/jmsrouter/JmsConsumer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/esb/examples/jmsrouter/JmsConsumer.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/java/org/jboss/esb/examples/jmsrouter/JmsConsumer.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,135 @@
+/*
+ Milyn - Copyright (C) 2006
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License (version 2.1) as published by the Free Software
+ Foundation.
+
+ This library 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:
+ http://www.gnu.org/licenses/lgpl.txt
+ */
+package org.jboss.esb.examples.jmsrouter;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageListener;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ *
+ * @author <a href="mailto:daniel.bevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class JmsConsumer implements MessageListener
+{
+ private static int messageCounter;
+ private Connection connection;
+
+ private static JmsConsumer consumer;
+
+ public static void main(String[] args) throws Exception
+ {
+ consumer = new JmsConsumer();
+ consumer.setupMessageListener(args[0]);
+
+ Runtime.getRuntime().addShutdownHook(new Thread()
+ {
+ @Override
+ public void run()
+ {
+ consumer.closeConnection();
+ }
+ });
+
+ Object sleep = new Object();
+ synchronized (sleep)
+ {
+ sleep.wait();
+ }
+ }
+
+ private void setupMessageListener(final String destinationName) throws NamingException, JMSException
+ {
+ InitialContext context = null;
+ try
+ {
+ context = new InitialContext();
+ ConnectionFactory connectionFactory = (ConnectionFactory) context.lookup("ConnectionFactory");
+ connection = connectionFactory.createConnection();
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ Destination destination = (Destination) context.lookup(destinationName);
+ MessageConsumer consumer = session.createConsumer(destination);
+ consumer.setMessageListener(this);
+ connection.start();
+ System.out.println("JMS Listener started");
+ }
+ catch (final NamingException e)
+ {
+ throw e;
+ }
+ catch (final JMSException e)
+ {
+ throw e;
+ } finally
+ {
+ try
+ {
+ context.close();
+ }
+ catch (final NamingException ignore)
+ {
+ }
+ }
+ }
+
+ public void onMessage(Message message)
+ {
+ messageCounter++;
+ System.out.println("\n[ Received Message[" + messageCounter + "]");
+ try
+ {
+ System.out.println("\t[JMSMessageID : " + message.getJMSMessageID() + "]");
+ System.out.println("\t[JMSCorrelelationID : " + message.getJMSCorrelationID() + "]");
+ if (message instanceof ObjectMessage)
+ {
+ System.out.println("\t[MessageType : ObjectMessage]");
+ System.out.println("\t[Object : " + ((ObjectMessage) message).getObject() + "]");
+ } else if (message instanceof TextMessage)
+ {
+ System.out.println("\t[MessageType : TextMessage]");
+ System.out.println("\t[Text : \n" + ((TextMessage) message).getText() + "]");
+ }
+ } catch (JMSException e)
+ {
+ e.printStackTrace();
+ }
+ System.out.println("]");
+ }
+
+ private void closeConnection()
+ {
+ System.out.println("Closing JMS Listener...");
+ try
+ {
+ if (connection != null)
+ connection.close();
+ }
+ catch (final JMSException e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/jndi.properties
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/jndi.properties (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/jndi.properties 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,11 @@
+java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory
+java.naming.provider.url=tcp://localhost:61717
+
+# use the following property to specify the JNDI name the connection factory
+# should appear as.
+connectionFactoryNames = connectionFactory, ConnectionFactory, queueConnectionFactory, topicConnectionFactory
+
+# register some queues in JNDI using the form
+# queue.[jndiName] = [physicalName]
+queue.jbossesb.TestOutQueue = jbossesb.TestOutQueue
+
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/log4j.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/main/resources/log4j.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+
+ <category name="org.milyn">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.quartz">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.jboss.esb">
+ <priority value="debug"/>
+ </category>
+
+ <category name="org.jboss.esb.examples.helloworld">
+ <priority value="info"/>
+ </category>
+
+ <category name="org.apache.activemq">
+ <priority value="ERROR"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
+
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/test/resources/log4j.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/jms-consumer/src/test/resources/log4j.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,62 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!--
+ | For more configuration infromation and examples see the Jakarta Log4j
+ | owebsite: http://jakarta.apache.org/log4j
+ -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
+
+ <!-- ============================== -->
+ <!-- Append messages to the console -->
+ <!-- ============================== -->
+
+ <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <!-- The default pattern: Date Priority [Category] Message\n -->
+ <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%t][%c{1}] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+
+ <category name="org.milyn">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.quartz">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.jboss">
+ <priority value="error"/>
+ </category>
+
+ <category name="org.jboss.esb.examples.helloworld">
+ <priority value="info"/>
+ </category>
+
+ <category name="org.apache.activemq">
+ <priority value="ERROR"/>
+ </category>
+
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ </root>
+
+</log4j:configuration>
+
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/activemq.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/activemq.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/activemq.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,20 @@
+<beans
+ xmlns="http://www.springframework.org/schema/beans"
+ xmlns:amq="http://activemq.org/config/1.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
+ http://activemq.org/config/1.0 http://activemq.apache.org/schema/activemq-core.xsd
+ http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">
+
+ <!-- Allows us to use system properties as variables in this configuration file -->
+ <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+
+ <broker xmlns="http://activemq.org/config/1.0" useJmx="false" dataDirectory="${activemq.base}/target/activemq">
+
+ <transportConnectors>
+ <transportConnector uri="tcp://localhost:61717"/>
+ </transportConnectors>
+
+ </broker>
+
+</beans>
\ No newline at end of file
Added: labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/pom.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/jms-provider/pom.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-examples-jms-router</artifactId>
+ <version>${jboss.esb.version}</version>
+ </parent>
+ <name>JBoss ESB - JMS Router Example (Provider)</name>
+ <groupId>jboss.jbossesb</groupId>
+ <artifactId>jbossesb-examples-jms-router-provider</artifactId>
+ <version>${jboss.esb.version}</version>
+ <url>http://www.jboss.org/jbossesb/</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.activemq.tooling</groupId>
+ <artifactId>maven-activemq-plugin</artifactId>
+ <version>4.1.2</version>
+ <configuration>
+ <configFile>./activemq.xml</configFile>
+ <fork>false</fork>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
Modified: labs/jbossesb/workspace/skeagh/examples/jms-router/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/examples/jms-router/pom.xml 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/examples/jms-router/pom.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -11,11 +11,13 @@
<artifactId>jbossesb-examples-jms-router</artifactId>
<version>${jboss.esb.version}</version>
<url>http://www.jboss.org/jbossesb/</url>
- <packaging>bundle</packaging>
+ <packaging>pom</packaging>
- <properties>
- <felix.log.level>1</felix.log.level><!-- 4=debug -->
- </properties>
+ <modules>
+ <module>jms-provider</module>
+ <module>jms-consumer</module>
+ <module>esb-jms-router</module>
+ </modules>
<dependencies>
<dependency>
@@ -23,11 +25,6 @@
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.main</artifactId>
- <version>1.2.1</version>
- </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
@@ -73,75 +70,6 @@
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
</dependency>
-
- <!-- JBossESB OSGi bundle -->
- <dependency>
- <groupId>jboss.jbossesb</groupId>
- <artifactId>jbossesb-api</artifactId>
- <version>${jboss.esb.version}</version>
- </dependency>
- <dependency>
- <groupId>jboss.jbossesb</groupId>
- <artifactId>jbossesb-osgi-runtime</artifactId>
- <version>${jboss.esb.version}</version>
- </dependency>
-
- <!-- JBossESB JMS Routing bundle -->
- <dependency>
- <groupId>jboss.jbossesb</groupId>
- <artifactId>jbossesb-routing-jms</artifactId>
- <version>${jboss.esb.version}</version>
- </dependency>
-
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.activemq.tooling</groupId>
- <artifactId>maven-activemq-plugin</artifactId>
- <version>4.1.2</version>
- <configuration>
- <configFile>./activemq.xml</configFile>
- <fork>false</fork>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <configuration>
- <executable>java</executable>
- <mainClass>org.jboss.esb.examples.jmsrouter.JmsClient</mainClass>
- <arguments>
- <argument>jbossesb.TestQueue</argument>
- <!--argument>Message payload text...</argument-->
- </arguments>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.ops4j</groupId>
- <artifactId>maven-pax-plugin</artifactId>
- <version>1.3</version>
- <extensions>true</extensions>
- </plugin>
-
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.0</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>org.jboss.esb.examples.jmsrouter, org.apache.activemq.jndi</Export-Package>
- <Import-Package>org.jboss.esb.jms, org.jboss.esb.api.*, *;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
- <Embed-Dependency>activemq-core, backport-util-concurrent, log4j, commons-logging, geronimo-j2ee-management_1.1_spec</Embed-Dependency>
- <Embed-Transitive>true</Embed-Transitive>
- <JBossESB-ConfigFile>/jboss-esb.xml</JBossESB-ConfigFile>
- <JBossESB-DeploymentName>TestDeploymentName</JBossESB-DeploymentName>
- </instructions>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
Modified: labs/jbossesb/workspace/skeagh/routing/jms/pom.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/pom.xml 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/routing/jms/pom.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -76,7 +76,7 @@
<extensions>true</extensions>
<configuration>
<instructions>
- <Export-Package>org.jboss.esb.jms</Export-Package>
+ <Export-Package>org.jboss.esb.jms.*</Export-Package>
<Import-Package>*;resolution:=optional</Import-Package> <!-- TODO: Replace global import with explicit package imports? -->
<Embed-Dependency>jbossesb-commons, log4j</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
Modified: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInboundRouter.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -20,36 +20,39 @@
*/
package org.jboss.esb.jms;
+import java.util.Properties;
+
+import javax.jms.JMSException;
+
import org.apache.log4j.Logger;
import org.jboss.esb.api.annotations.Initialize;
import org.jboss.esb.api.annotations.Property;
+import org.jboss.esb.api.annotations.Uninitialize;
import org.jboss.esb.api.annotations.Property.Use;
-import org.jboss.esb.api.annotations.Uninitialize;
import org.jboss.esb.api.context.InvocationContext;
import org.jboss.esb.api.context.ResourceLocator;
+import org.jboss.esb.api.exception.ConfigurationException;
import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.routing.InboundRouter;
import org.jboss.esb.api.routing.MessageDispatcher;
-import org.jboss.esb.api.routing.InboundRouter;
-import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.jms.composers.EsbMessageComposer;
+import org.jboss.esb.jms.util.RouterUtil;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.Queue;
-import javax.naming.Context;
-import java.util.Properties;
-
/**
* Inbound router for JMS.
* <br><br>
* Sample usage:
* <br>
* <pre>{@code
+ *
* <inRouter name="inrouter1" class="org.jboss.esb.jms.JmsInboundRouter">
* <property name="jmsDestination">jbossesb.TestQueue</property>
* </inRouter>
*
- * Optional properties (default shown):
- * <property name="extractProperties">true</property>
+ * Optional properties (defaults shown):
+ * <property name="extractJmsProperties">true</property>
+ * <property name="esbMessageComposer">org.jboss.esb.jms.composers.EsbMessageComposerImpl</property>
* <property name="java.naming.provider.url">jnp://localhost:1099</property>
* <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
* <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
@@ -59,6 +62,7 @@
* Properties decription:
* <lu>
* <li>extractProperties true if JMS Headers and properties should be extracted and added to the invocation context</li>
+ * <li>esbMessageComposer the class name of an concrete implementation of org.jboss.esb.jms.EsbMessageComposer.</li>
* </lu>
*
* @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
@@ -74,8 +78,9 @@
* MessageDispatcher used to dipatch the message to the ESB.
*/
private MessageDispatcher dispatcher;
+
/**
- * Resource locator
+ * Resource locator.
*/
private ResourceLocator resourceLocator;
@@ -89,14 +94,21 @@
* JMS connection properties.
*/
@org.jboss.esb.api.annotations.Properties
- private final Properties jmsProperties = getDefaultProperties();
+ private final Properties configProperties = RouterUtil.getDefaultProperties();
/**
- * Should JMSHeaders and user properties be extracted from the JMS Message.
+ * Should JMSHeaders and user properties be extracted from the JMS Message and added
+ * to the inbound ESB Message.
*/
@Property(use = Use.OPTIONAL, defaultVal = "true")
- private boolean extractProperties;
+ private boolean extractJmsProperties;
+ /**
+ * The message composer to use.
+ */
+ @Property(use = Use.OPTIONAL, name = "esbMessageComposer", defaultVal = "org.jboss.esb.jms.composers.EsbMessageComposerImpl")
+ private String messageComposerClass;
+
/**
* The JMS Session on which the listener is created.
*/
@@ -107,48 +119,33 @@
*/
private JmsMessageListener messageListener;
+ /**
+ * MessageComposer strategy.
+ */
+ private EsbMessageComposer esbMessageComposer;
+
/**
* Sets up the JmsMesssageListener of this class.
*
* @throws JMSException if a JMS exception occurs.
+ * @throws ConfigurationException If a message composer could not be created.
*/
@Initialize
- public final void initialize() throws JMSException
+ public final void initialize() throws JMSException, ConfigurationException
{
- Destination jmsDestination;
+ setupJmsSession();
+ setupMessageListener();
+ setupMessageComposer();
+ }
- jmsSession = new JMSSession(jmsProperties);
- jmsSession.setClassLoader(resourceLocator.getClassLoader());
-
- // set the context class loader to this classes classloader.
- jmsDestination = jmsSession.lookupDestination(destination);
-
- // Configure the session type based on the destination type, before we try to connect...
- if(jmsDestination instanceof Queue)
- {
- jmsSession.setSessionType(JMSSession.Type.QUEUE);
- }
- else
- {
- jmsSession.setSessionType(JMSSession.Type.TOPIC);
- }
-
- jmsSession.connect();
- try
- {
- messageListener = new JmsMessageListener(destination, jmsSession, jmsProperties, dispatcher);
- messageListener.connect();
- }
- catch (final JMSException e)
- {
- jmsSession.close();
- throw e;
- }
- catch (final Throwable t)
- {
- jmsSession.close();
- throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
- }
+ /**
+ * Set the dispatcher used by this instance.
+ *
+ * @param dispatcher - the dispatcher to use
+ */
+ public final void setDispatcher(final MessageDispatcher dispatcher)
+ {
+ this.dispatcher = dispatcher;
}
/**
@@ -166,45 +163,32 @@
}
finally
{
- if (jmsSession != null)
- {
- jmsSession.close();
- }
+ RouterUtil.closeJmsSession(jmsSession);
}
}
/**
- * Gets the JMS properties.
+ * Will display the dispatcher and the properties for this instance.
*
- * @return Properties - the properties used by this instance.
+ * @return String - string representation of this instance.
*/
- public final Properties getProperties()
+ @Override
+ public final String toString()
{
- return (Properties) jmsProperties.clone();
+ return "[dispatcher=" + dispatcher + ", extractProperties=" + extractJmsProperties + ", jmsProperties=" + configProperties + "]";
}
/**
- * Set the dispatcher used by this instance.
+ * Gets the JMS properties.
*
- * @param dispatcher - the dispatcher to use
+ * @return Properties - the properties used by this instance.
*/
- public final void setDispatcher(final MessageDispatcher dispatcher)
+ public final Properties getProperties()
{
- this.dispatcher = dispatcher;
+ return (Properties) configProperties.clone();
}
/**
- * Will display the dispatcher and the properties for this instance.
- *
- * @return String - string representation of this instance.
- */
- @Override
- public final String toString()
- {
- return "[dispatcher=" + dispatcher + ", extractProperties=" + extractProperties + ", jmsProperties=" + jmsProperties + "]";
- }
-
- /**
* Gets the jms destination(Topic or Queue).
*
* @return String the name of the destination.
@@ -214,18 +198,91 @@
return destination;
}
+ private void setupJmsSession() throws ConfigurationException
+ {
+ try
+ {
+ jmsSession = RouterUtil.createJMSSession(configProperties, resourceLocator);
+ RouterUtil.setDestinationTyp(destination, jmsSession);
+ jmsSession.connect();
+ }
+ catch (final JMSException e)
+ {
+ throw new ConfigurationException(e.getMessage(), e);
+ }
+ }
+
+ private void setupMessageListener() throws ConfigurationException
+ {
+ try
+ {
+ messageListener = createMessageListener(jmsSession);
+ connectMessageListener(messageListener);
+ }
+ catch (final JMSException e)
+ {
+ throw new ConfigurationException(e.getMessage(), e);
+ }
+ }
+
+ private void connectMessageListener(final JmsMessageListener listener) throws JMSException
+ {
+ try
+ {
+ listener.connect();
+ }
+ catch (final JMSException e)
+ {
+ RouterUtil.closeJmsSession(jmsSession);
+ throw e;
+ }
+ catch (final Exception t)
+ {
+ RouterUtil.closeJmsSession(jmsSession);
+ throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
+ }
+ }
+
+ private void setupMessageComposer() throws ConfigurationException
+ {
+ try
+ {
+ esbMessageComposer = (EsbMessageComposer) RouterUtil.createInstance(messageComposerClass);
+ esbMessageComposer.setConfiguration(configProperties);
+ }
+ catch (final ConfigurationException e)
+ {
+ uninitialize();
+ throw e;
+ }
+ }
+
/**
- * Returns the default JMS properties.
+ * Creates and connects a {@link MessageSender}.
*
- * @return Properties - the default JMS properties
+ * @param session The {@link JMSSession} to use for creating the MessageSender.
+ * @return MessageSender The newly create {@link MessageSender}.
+ * @throws JMSException If an error occurs while trying to create the MessageSender.
*/
- private static Properties getDefaultProperties()
+ private JmsMessageListener createMessageListener(final JMSSession session) throws JMSException
{
- final Properties defaults = new Properties();
- // Defaults for JNDI lookup
- defaults.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
- defaults.put(Context.PROVIDER_URL, "jnp://localhost:1099");
- return defaults;
+ JmsMessageListener listener = null;
+ try
+ {
+ listener = new JmsMessageListener(destination, jmsSession, configProperties, dispatcher);
+ listener.connect();
+ }
+ catch (final JMSException e)
+ {
+ RouterUtil.closeJmsSession(jmsSession);
+ throw e;
+ }
+ catch (final Exception t)
+ {
+ RouterUtil.closeJmsSession(jmsSession);
+ throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageListener.").initCause(t));
+ }
+ return listener;
}
/**
@@ -266,27 +323,23 @@
{
try
{
- final Message esbMessage = JmsInformationExtractor.extractPayload(jmsMessage);
+ final Message esbMessage = esbMessageComposer.composeEsbMessage(jmsMessage, InvocationContext.getContext());
log.info("Extracted Jms Payload -> " + esbMessage);
final InvocationContext context = new InvocationContext();
- if (extractProperties)
+ if (extractJmsProperties)
{
- context.setContextObject(JmsConstants.PROPERTIES, JmsInformationExtractor.extractJmsProperties(jmsMessage));
+ context.setContextObject(JmsConstants.PROPERTIES, esbMessageComposer.extractJmsProperties(jmsMessage));
log.debug(context.getContextObject(JmsConstants.PROPERTIES));
}
dispatcher.dispatch(esbMessage, context);
}
- catch (RoutingException e)
+ catch (MessageProcessingException e)
{
//TODO: Should errors be reported back to a caller. DLQ?
log.error("RoutingException in onMessage", e);
}
- catch (JMSException e)
- {
- log.error("JMSException in onMessage", e);
- }
}
}
}
Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInformationExtractor.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInformationExtractor.java 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInformationExtractor.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -1,269 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 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.esb.jms;
-
-import static org.jboss.esb.jms.JmsConstants.CORRELATION_ID;
-import static org.jboss.esb.jms.JmsConstants.DELIVERY_MODE;
-import static org.jboss.esb.jms.JmsConstants.EXPIRATION;
-import static org.jboss.esb.jms.JmsConstants.MESSAGE_ID;
-import static org.jboss.esb.jms.JmsConstants.PRIORITY;
-import static org.jboss.esb.jms.JmsConstants.REDELIVERED;
-import static org.jboss.esb.jms.JmsConstants.REPLY_TO;
-import static org.jboss.esb.jms.JmsConstants.TIMESTAMP;
-import org.jboss.esb.api.message.Message;
-import org.jboss.esb.api.routing.RoutingException;
-
-import javax.jms.BytesMessage;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-import javax.jms.MapMessage;
-import javax.jms.ObjectMessage;
-import javax.jms.StreamMessage;
-import javax.jms.TextMessage;
-import java.io.Serializable;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * JMS Information extractor.
- *
- * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
- */
-public final class JmsInformationExtractor
-{
- /**
- * Private constructor.
- */
- private JmsInformationExtractor()
- {
- throw new AssertionError("Private constructor should not be called. Not even reflectively");
- }
-
- /**
- * Extracts the content from the passed in JMSMessage object.
- * <br>
- * The following conversions are done bases on the message type:
- * <lu>
- * <li>TestMessage -> java.lang.String</li>
- * <li>ObjectMessage -> java.lang.Object</li>
- * <li>BytesMessage -> byte[]</li>
- * <li>MapMessage -> java.util.Map</li>
- * <li>StreamMessage -> org.jboss.esb.jms.StreamMessageInputStream</li>
- * </lu>
- *
- * @param jmsMessage the JMS Message object instance
- * @return Message the populated ESB Message object instance.
- * @throws RoutingException if an error occurs while trying to extract the JMS messages contents.
- */
- public static Message extractPayload(final javax.jms.Message jmsMessage) throws RoutingException
- {
- final Message esbMessage = new Message();
- try
- {
- if (jmsMessage instanceof TextMessage)
- {
- final String text = ((TextMessage) jmsMessage).getText();
- if (text == null)
- {
- throw new RoutingException("Content in JMSMessage [" + jmsMessage + "] was null");
- }
- esbMessage.setPayload(text);
- }
- else if (jmsMessage instanceof ObjectMessage)
- {
- final Serializable object = ((ObjectMessage) jmsMessage).getObject();
- if (object == null)
- {
- throw new RoutingException("Content in JMSMessage [" + jmsMessage + "] was null");
- }
- esbMessage.setPayload(object);
- }
- else if (jmsMessage instanceof BytesMessage)
- {
- byte[] content = readBytes((BytesMessage) jmsMessage);
- esbMessage.setPayload(content);
- }
- else if (jmsMessage instanceof MapMessage)
- {
- final MapMessage jmsMap = (MapMessage) jmsMessage;
- final Map<String, Object> esbMap = new HashMap<String, Object>();
-
- final Enumeration<?> mapNames = jmsMap.getMapNames();
- while (mapNames.hasMoreElements())
- {
- final String key = (String) mapNames.nextElement();
- final Object value = jmsMap.getObject(key);
- esbMap.put(key, value);
- }
- if (esbMap.isEmpty())
- {
- throw new RoutingException("Map in JMSMessage [" + jmsMessage + "] contained zero key value pairs.");
- }
- esbMessage.setPayload(esbMap);
- }
- else if (jmsMessage instanceof StreamMessage)
- {
- StreamMessage streamMessage = (StreamMessage) jmsMessage;
- esbMessage.setPayload(new StreamMessageInputStream(streamMessage));
- }
- else
- {
- throw new RoutingException("Could not determine the type of JMSMessage:" + jmsMessage);
- }
- }
- catch (final JMSException e)
- {
- throw new RoutingException("Could not extract content from JMSMessage: " + jmsMessage, e);
- }
- return esbMessage;
- }
-
- /**
- * Will extract all the properties that have been set on the JMS Message and
- * also extract all the set JMS Headers.
- * <p/>
- * The following JMS Headers are extracted:
- * <ul>
- * <li>JMSCorrelationID -> get(JmsConstants.CORRELATION_ID</li>
- * <li>JMSExpiration -> get(JmsConstants.EXPIRATOIN</li>
- * <li>JMSRedelivered -> get(JmsConstants.REDELIVERED</li>
- * <li>JMSMessageID -> get(JmsConstants.MESSAGE_ID</li>
- * <li>JMSTimestamp -> get(JmsConstants.TIMESTAMP</li>
- * <li>JMSReplyTo -> get(JmsConstants.REPLY_TO</li>
- * <li>JMSPriority -> get(JmsConstants.PRIORITY</li>
- * </ul>
- *
- * @param jmsMessage The JMS Message.
- * @return The JMS Properties.
- * @throws JMSException Error extracting properties.
- */
- public static Properties extractJmsProperties(final javax.jms.Message jmsMessage) throws JMSException
- {
- final Properties properties = new Properties();
-
- // extract properties
- final Enumeration<String> propertyNames = jmsMessage.getPropertyNames();
- while (propertyNames.hasMoreElements())
- {
- final String propertyName = propertyNames.nextElement();
- final Object value = jmsMessage.getObjectProperty(propertyName);
- properties.put(propertyName, value);
- }
-
- final String correlationID = jmsMessage.getJMSCorrelationID();
- if (correlationID != null)
- {
- properties.put(CORRELATION_ID, correlationID);
- }
-
- final long expiration = jmsMessage.getJMSExpiration();
- if (expiration > 0L)
- {
- properties.put(EXPIRATION, expiration);
- }
-
- final boolean redelivered = jmsMessage.getJMSRedelivered();
- properties.put(REDELIVERED, redelivered);
-
- /*
- * Extract messageId header. Need to check for null as a client
- * may have called MessageProducer.setDisableMessageID.
- */
- final String messageId = jmsMessage.getJMSMessageID();
- if (messageId != null)
- {
- properties.put(MESSAGE_ID, messageId);
- }
-
- /*
- * Extract redelivered header if one exist. The JMS client may
- * have called MessageProducer.setDisableMessageTimestamp, in which
- * case this timestamp might have been set to 0.
- */
- final long timestamp = jmsMessage.getJMSTimestamp();
- if (timestamp > 0L)
- {
- properties.put(TIMESTAMP, timestamp);
- }
-
- final Destination replyTo = jmsMessage.getJMSReplyTo();
- if (replyTo != null)
- {
- properties.put(REPLY_TO, replyTo);
- }
-
- int priority = jmsMessage.getJMSPriority();
- if (priority >= 0 && priority <= 9)
- {
- properties.put(PRIORITY, priority);
- }
-
- int deliveryMode = jmsMessage.getJMSDeliveryMode();
- properties.put(DELIVERY_MODE, deliveryMode);
-
- return properties;
- }
-
- /**
- * Read the bytes from the supplied JMS Message.
- * @param jmsMessage The JMS Message.
- * @return The message bytes.
- * @throws JMSException Error Access message bytes.
- */
- private static byte[] readBytes(final BytesMessage jmsMessage) throws JMSException
- {
- jmsMessage.reset();
- int msgLength = 0;
- final int buffSize = 50000;
- byte[] data = new byte[buffSize];
- // calculate the nr of bytes in the message
- while (true)
- {
- int len = jmsMessage.readBytes(data);
- if (len > 0)
- {
- msgLength += len;
- }
- else
- {
- break;
- }
- }
- if (msgLength == 0)
- {
- throw new JMSException("Content in JMSMessage [" + jmsMessage + "] was of zero length");
- }
- byte[] content = new byte[msgLength];
- if (msgLength <= buffSize)
- {
- System.arraycopy(data, 0, content, 0, msgLength);
- }
- else
- {
- jmsMessage.reset();
- jmsMessage.readBytes(content);
- }
- return content;
- }
-
-}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsOutboundRouter.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,273 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms;
+
+import static org.jboss.esb.jms.JmsConstants.PROPERTIES;
+
+import java.util.Properties;
+import javax.jms.JMSException;
+import org.jboss.esb.api.annotations.Initialize;
+import org.jboss.esb.api.annotations.Property;
+import org.jboss.esb.api.annotations.Uninitialize;
+import org.jboss.esb.api.annotations.Property.Use;
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.context.ResourceLocator;
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.api.routing.OutboundRouter;
+import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.jms.composers.JmsMessageComposer;
+import org.jboss.esb.jms.util.RouterUtil;
+
+/**
+ * JmsOutboundRouter is implmentation of {@link OutboundRouter} that uses the JMS transport.
+ * <br><br>
+ * Sample usage:
+ * <br>
+ * <pre>{@code
+ *
+ * <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
+ * <property name="jmsDestination">jbossesb.TestOutQueue</property>
+ * </outRouter>
+ *
+ * Optional properties (defaults shown):
+ * <property name="extractProperties">true</property>
+ * <property name="jmsMessageComposer">org.jboss.esb.jms.composers.JmsMessageComposerImpl</property>
+ * <property name="java.naming.provider.url">jnp://localhost:1099</property>
+ * <property name="java.naming.factory.initial">org.jnp.interfaces.NamingContextFactory</property>
+ * <property name="java.naming.factory.url.pkgs">org.jboss.naming,org.jnp.interfaces</property>
+ * <property name="org.jboss.esb.jms.connectionFactory">ConnectionFactory</property>
+ * }</pre>
+ * <br>
+ * Properties decription:
+ * <lu>
+ * <li>extractProperties true if JMS Headers and properties should be extracted and added to the invocation context</li>
+ * <li>jmsMessageComposer the class name of an concrete implementation of org.jboss.esb.jms.JmsMessageComposer.</li>
+ * </lu>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class JmsOutboundRouter implements OutboundRouter
+{
+ /**
+ * The jms destination name.
+ */
+ @Property(use = Use.REQUIRED, name = "jmsDestination")
+ private String destination;
+
+ /**
+ * Properties that are specified in the config but not actually fields on this class.
+ */
+ @org.jboss.esb.api.annotations.Properties
+ private final Properties configProperties = RouterUtil.getDefaultProperties();
+
+ /**
+ * The name of the {@link JmsMessageComposer} implementation to be used.
+ */
+ @Property(use = Use.OPTIONAL, name = "jmsMessageComposer", defaultVal = "org.jboss.esb.jms.composers.JmsMessageComposerImpl")
+ private String messageComposerClass;
+
+ /**
+ * Should ESB Properties from the ESB Message and added to the outgoing JMS Message.
+ */
+ @Property(use = Use.OPTIONAL, defaultVal = "true")
+ private boolean extractEsbProperties;
+
+ /**
+ * The {@link JMSSession}.
+ */
+ private JMSSession jmsSession;
+
+ /**
+ * The {@link ResourceLocator}.
+ */
+ private ResourceLocator resourceLocator;
+
+ /**
+ * The {@link MessageSender}.
+ */
+ private MessageSender messageSender;
+
+ /**
+ * The {@link JmsMessageComposer} strategy.
+ */
+ private JmsMessageComposer jmsMessageComposer;
+
+ /**
+ * Name of this router. Will be injected by the deployment runtime.
+ */
+ private Object objectName;
+
+ /**
+ * Will setup this Router so that it is ready to publish messages to
+ * the configured destination.
+ *
+ * @throws ConfigurationException If there is a configuration error.
+ */
+ @Initialize
+ public final void initialize() throws ConfigurationException
+ {
+ setupJmsSession();
+ setupMessageSender();
+ setupMessageComposer();
+ }
+
+ /**
+ * Send the contents of the ESB Message object to the configured
+ * JMS destination.
+ *
+ * @param message The ESB Message object
+ * @throws RoutingException If an error occurs while trying to send the JMS Message.
+ */
+ public final void route(final Message esbMessage) throws RoutingException
+ {
+ final javax.jms.Message jmsMessage = composeJmsMessage(esbMessage);
+ publishJmsMessage(jmsMessage);
+ }
+
+ /**
+ * Closes the underlying JMS connection.
+ * This method will be called by the runtime upon deployment.
+ */
+ @Uninitialize
+ public final void uninitialize()
+ {
+ try
+ {
+ if (messageSender != null)
+ {
+ messageSender.close();
+ }
+ }
+ finally
+ {
+ RouterUtil.closeJmsSession(jmsSession);
+ }
+ }
+
+ public String getDestination()
+ {
+ return destination;
+ }
+
+ public Properties getJmsProperties()
+ {
+ return (Properties) configProperties.clone();
+ }
+
+ @Override
+ public final String toString()
+ {
+ return "JMSOutboundRouter [name='" + objectName + "', destination='" + destination + "', jmsProperties='" + configProperties + "']";
+ }
+
+ private void setupJmsSession() throws ConfigurationException
+ {
+ try
+ {
+ jmsSession = RouterUtil.createJMSSession(configProperties, resourceLocator);
+ RouterUtil.setDestinationTyp(destination, jmsSession);
+ jmsSession.connect();
+ }
+ catch (final JMSException e)
+ {
+ throw new ConfigurationException(e.getMessage(), e);
+ }
+ }
+
+ private void setupMessageSender() throws ConfigurationException
+ {
+ try
+ {
+ messageSender = new MessageSender(destination, jmsSession);
+ connectMessageSender(messageSender);
+ }
+ catch (final JMSException e)
+ {
+ throw new ConfigurationException(e.getMessage(), e);
+ }
+ }
+
+ private void setupMessageComposer() throws ConfigurationException
+ {
+ try
+ {
+ jmsMessageComposer = (JmsMessageComposer) RouterUtil.createInstance(messageComposerClass);
+ jmsMessageComposer.setConfiguration(configProperties);
+ }
+ catch (final ConfigurationException e)
+ {
+ uninitialize();
+ throw e;
+ }
+ }
+
+ private javax.jms.Message composeJmsMessage(final Message esbMessage) throws RoutingException
+ {
+ try
+ {
+ javax.jms.Message jmsMessage = jmsMessageComposer.composeJmsMessage(esbMessage, jmsSession.getSession());
+ if (extractEsbProperties)
+ {
+ final Properties jmsProperties = (Properties) InvocationContext.getContext().getContextObject(PROPERTIES);
+ jmsMessageComposer.addEsbProperties(jmsProperties, jmsMessage);
+ }
+ return jmsMessage;
+ }
+ catch (final MessageProcessingException e)
+ {
+ throw new RoutingException(e.getMessage(), e);
+ }
+ }
+
+ private void publishJmsMessage(final javax.jms.Message jmsMessage) throws RoutingException
+ {
+ try
+ {
+ messageSender.send(jmsMessage);
+ }
+ catch (final JMSException e)
+ {
+ throw new RoutingException(e.getMessage(), e);
+ }
+ }
+
+ private void connectMessageSender(final MessageSender sender) throws JMSException
+ {
+ try
+ {
+ sender.connect();
+ }
+ catch (final JMSException e)
+ {
+ RouterUtil.closeJmsSession(jmsSession);
+ throw e;
+ }
+ catch (final Exception t)
+ {
+ RouterUtil.closeJmsSession(jmsSession);
+ throw (JMSException) (new JMSException("Unexpected exception while connecting JmsMesssageSender.").initCause(t));
+ }
+ }
+
+}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposer.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposer.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,67 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms.composers;
+
+import java.util.Properties;
+
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+
+/**
+ * JMS Message Composer.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public interface EsbMessageComposer
+{
+ /**
+ * Decompose the ESB Message object payload and uses the payload to create a
+ * new instance of T.
+ *
+ * @param message The ESB message object instance.
+ * @param t The class parameter
+ * @return Object Any Object.
+ *
+ * @throws MessageProcessingException If an error occurs while decomposeing.
+ */
+ Message composeEsbMessage(final javax.jms.Message message, final InvocationContext context) throws MessageProcessingException;
+
+ /**
+ * Can extract any of the properties that have been set on the JMS Message.
+ *
+ * @param jmsMessage The JMS Message.
+ * @return The JMS Properties.
+ * @throws JMSException Error extracting properties.
+ */
+ Properties extractJmsProperties(final javax.jms.Message jmsMessage) throws MessageProcessingException;
+
+ /**
+ * Allows a MessageComposer implementation receive configuration information.
+ *
+ * @param properties The properties.
+ */
+ void setConfiguration(final Properties properties);
+
+}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposerImpl.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposerImpl.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/EsbMessageComposerImpl.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,387 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms.composers;
+
+import static org.jboss.esb.jms.JmsConstants.CORRELATION_ID;
+import static org.jboss.esb.jms.JmsConstants.DELIVERY_MODE;
+import static org.jboss.esb.jms.JmsConstants.EXPIRATION;
+import static org.jboss.esb.jms.JmsConstants.MESSAGE_ID;
+import static org.jboss.esb.jms.JmsConstants.PRIORITY;
+import static org.jboss.esb.jms.JmsConstants.REDELIVERED;
+import static org.jboss.esb.jms.JmsConstants.REPLY_TO;
+import static org.jboss.esb.jms.JmsConstants.TIMESTAMP;
+
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jms.BytesMessage;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.ObjectMessage;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.jms.StreamMessageInputStream;
+
+/**
+ * JMS Message Composer implementation.
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ * @param <T extends javax.jms.Message>
+ */
+public final class EsbMessageComposerImpl implements EsbMessageComposer
+{
+ /**
+ * Extracts the content from the passed in JMS Message object.
+ * <br>
+ * The following conversions are done bases on the message type:
+ * <lu>
+ * <li>TestMessage -> java.lang.String</li>
+ * <li>ObjectMessage -> java.lang.Object</li>
+ * <li>BytesMessage -> byte[]</li>
+ * <li>MapMessage -> java.util.Map</li>
+ * <li>StreamMessage -> org.jboss.esb.jms.StreamMessageInputStream</li>
+ * </lu>
+ *
+ * @param jmsMessage the JMS Message object instance.
+ * @param invocationContext the ESB {@link InvocationContext}.
+ * @return Message the populated ESB Message object instance.
+ * @throws MessageProcessingException if an error occurs while trying to extract the JMS messages contents.
+ */
+ public Message composeEsbMessage(final javax.jms.Message jmsMessage, final InvocationContext invocationContext) throws MessageProcessingException
+ {
+ final Message esbMessage = new Message();
+ try
+ {
+ if (jmsMessage instanceof TextMessage)
+ {
+ setPayload(((TextMessage) jmsMessage).getText(), esbMessage);
+ }
+ else if (jmsMessage instanceof ObjectMessage)
+ {
+ setPayload(((ObjectMessage) jmsMessage).getObject(), esbMessage);
+ }
+ else if (jmsMessage instanceof BytesMessage)
+ {
+ setPayload(readBytes((BytesMessage) jmsMessage), esbMessage);
+ }
+ else if (jmsMessage instanceof MapMessage)
+ {
+ setPayload(getMap(jmsMessage), esbMessage);
+ }
+ else if (jmsMessage instanceof StreamMessage)
+ {
+ setPayload(new StreamMessageInputStream((StreamMessage) jmsMessage), esbMessage);
+ }
+ else
+ {
+ throw new MessageProcessingException("Could not determine the type of JMSMessage:" + jmsMessage);
+ }
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("Could not extract content from JMSMessage: " + jmsMessage, e);
+ }
+ return esbMessage;
+ }
+
+ /**
+ * Will extract all the properties that have been set on the JMS Message and
+ * also extract all the set JMS Headers.
+ * <p/>
+ * The following JMS Headers are extracted:
+ * <ul>
+ * <li>JMSCorrelationID -> get(JmsConstants.CORRELATION_ID</li>
+ * <li>JMSExpiration -> get(JmsConstants.EXPIRATOIN</li>
+ * <li>JMSRedelivered -> get(JmsConstants.REDELIVERED</li>
+ * <li>JMSMessageID -> get(JmsConstants.MESSAGE_ID</li>
+ * <li>JMSTimestamp -> get(JmsConstants.TIMESTAMP</li>
+ * <li>JMSReplyTo -> get(JmsConstants.REPLY_TO</li>
+ * <li>JMSPriority -> get(JmsConstants.PRIORITY</li>
+ * </ul>
+ *
+ * @param jmsMessage The JMS Message.
+ * @return The JMS Properties.
+ * @throws JMSException Error extracting properties.
+ */
+ public Properties extractJmsProperties(final javax.jms.Message jmsMessage) throws MessageProcessingException
+ {
+ final Properties properties = new Properties();
+ addUserDefinedProperties(jmsMessage, properties);
+ addCorrelationId(jmsMessage, properties);
+ addExpiration(jmsMessage, properties);
+ addRedelivered(jmsMessage, properties);
+ addMessageId(jmsMessage, properties);
+ addTimestamp(jmsMessage, properties);
+ addReplyTo(jmsMessage, properties);
+ addPriority(jmsMessage, properties);
+ addDeliveryMode(jmsMessage, properties);
+ return properties;
+ }
+
+ private void addDeliveryMode(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ int deliveryMode = jmsMessage.getJMSDeliveryMode();
+ properties.put(DELIVERY_MODE, deliveryMode);
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSDeliveredMode property from JMS Message:", e);
+ }
+ }
+
+ private void addPriority(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ int priority = jmsMessage.getJMSPriority();
+ if (priority >= 0 && priority <= 9)
+ {
+ properties.put(PRIORITY, Integer.valueOf(priority));
+ }
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSPriority property from JMS Message:", e);
+ }
+ }
+
+ private void addReplyTo(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ Destination replyTo = jmsMessage.getJMSReplyTo();
+ if (replyTo != null)
+ {
+ properties.put(REPLY_TO, replyTo);
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSReplyTo property from JMS Message:", e);
+ }
+ }
+
+ private void addTimestamp(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ final long timestamp = jmsMessage.getJMSTimestamp();
+ properties.put(TIMESTAMP, Long.valueOf(timestamp));
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSTimestamp property from JMS Message:", e);
+ }
+ }
+
+ private void addMessageId(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ final String messageId = jmsMessage.getJMSMessageID();
+ /*
+ * Need to check for null as a client may have called MessageProducer.setDisableMessageID.
+ */
+ if (messageId != null)
+ {
+ properties.put(MESSAGE_ID, messageId);
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSMessageId property from JMS Message:", e);
+ }
+
+ }
+
+ private void addRedelivered(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ final boolean redelivered = jmsMessage.getJMSRedelivered();
+ properties.put(REDELIVERED, redelivered);
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSRedelivered property from JMS Message:", e);
+ }
+ }
+
+ private void addExpiration(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ final long expiration = jmsMessage.getJMSExpiration();
+ if (expiration > 0L)
+ {
+ properties.put(EXPIRATION, Long.valueOf(expiration));
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSExpiration property from JMS Message:", e);
+ }
+
+ }
+
+ private void addCorrelationId(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ try
+ {
+ final String correlationID = jmsMessage.getJMSCorrelationID();
+ if (correlationID != null)
+ {
+ properties.put(CORRELATION_ID, correlationID);
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve JMSCorrelationID property from JMS Message:", e);
+ }
+ }
+
+ /**
+ * Note that JMS standard header fields are not considered properties and are not set by this method.
+ *
+ * @param jmsMessage The JMS Message.
+ * @param properties The properties object to add the properties to.
+ * @throws MessageProcessingException
+ * @throws JMSException
+ */
+ private void addUserDefinedProperties(final javax.jms.Message jmsMessage, final Properties properties) throws MessageProcessingException
+ {
+ String propertyName = null;
+ Object value = null;
+ try
+ {
+ final Enumeration<String> propertyNames = jmsMessage.getPropertyNames();
+ while (propertyNames.hasMoreElements())
+ {
+ propertyName = propertyNames.nextElement();
+ value = jmsMessage.getObjectProperty(propertyName);
+ properties.put(propertyName, value);
+ }
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to retrieve user defined property '" + propertyName + "' which had the value '" + value + "'", e);
+ }
+ }
+
+ /**
+ * Just sets the ESB Message payload.
+ *
+ * @param object The object to set as the payload
+ * @param esbMessage The ESB Message object instance.
+ * @throws MessageProcessingException The the object to set is null.
+ */
+ private void setPayload(final Object object, final Message esbMessage) throws MessageProcessingException
+ {
+ if (object == null)
+ {
+ throw new MessageProcessingException("Content in JMSMessage was null");
+ }
+ esbMessage.setPayload(object);
+ }
+
+ /**
+ * Gets the Map from a JMS MessageMap instance.
+ *
+ * @param jmsMessage The JMS Message Object instance.
+ * @return Map The extracted Map.
+ * @throws JMSException If an exception occurs during extraction.
+ * @throws MessageProcessingException If the map is empty.
+ */
+ private final Map<String, Object> getMap(final javax.jms.Message jmsMessage) throws JMSException, MessageProcessingException
+ {
+ final MapMessage jmsMap = (MapMessage) jmsMessage;
+ final Map<String, Object> esbMap = new HashMap<String, Object>();
+ final Enumeration<?> mapNames = jmsMap.getMapNames();
+ while (mapNames.hasMoreElements())
+ {
+ final String key = (String) mapNames.nextElement();
+ final Object value = jmsMap.getObject(key);
+ esbMap.put(key, value);
+ }
+ if (esbMap.isEmpty())
+ {
+ throw new MessageProcessingException("Map in JMSMessage [" + jmsMessage + "] contained zero key value pairs.");
+ }
+ return esbMap;
+ }
+
+ /**
+ * Read the bytes from the supplied JMS Message.
+ * @param jmsMessage The JMS Message.
+ * @return The message bytes.
+ * @throws JMSException Error Access message bytes.
+ */
+ private static byte[] readBytes(final BytesMessage jmsMessage) throws JMSException
+ {
+ jmsMessage.reset();
+ int msgLength = 0;
+ final int buffSize = 50000;
+ byte[] data = new byte[buffSize];
+ while (true)
+ {
+ int len = jmsMessage.readBytes(data);
+ if (len > 0)
+ {
+ msgLength += len;
+ }
+ else
+ {
+ break;
+ }
+ }
+ if (msgLength == 0)
+ {
+ throw new JMSException("Content in JMSMessage [" + jmsMessage + "] was of zero length");
+ }
+ byte[] content = new byte[msgLength];
+ if (msgLength <= buffSize)
+ {
+ System.arraycopy(data, 0, content, 0, msgLength);
+ }
+ else
+ {
+ jmsMessage.reset();
+ jmsMessage.readBytes(content);
+ }
+ return content;
+ }
+
+ public void setConfiguration(Properties properties)
+ {
+ //NoOp
+ }
+
+}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposer.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposer.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposer.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms.composers;
+
+import java.util.Properties;
+
+import javax.jms.JMSException;
+import javax.jms.Session;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+
+/**
+ * JMS Message Composer.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public interface JmsMessageComposer
+{
+ /**
+ * Decompose the ESB Message object payload and uses the payload to create a
+ * new instance of T.
+ *
+ * @param message The ESB message object instance.
+ * @param t The class parameter
+ * @return Object Any Object.
+ *
+ * @throws MessageProcessingException If an error occurs while decomposeing.
+ */
+ javax.jms.Message composeJmsMessage(final Message message, final Session session) throws MessageProcessingException;
+
+ /**
+ * Add all of the properties to the outbound JMS Message.
+ *
+ * @param esbMessage The ESB Message.
+ * @throws JMSException Error extracting properties.
+ */
+ void addEsbProperties(final Properties properties, final javax.jms.Message toJmsMessage) throws MessageProcessingException;
+
+ /**
+ * Allows a MessageComposer implementation receive configuration information.
+ *
+ * @param properties The properties.
+ */
+ void setConfiguration(final Properties properties);
+
+}
Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposerImpl.java (from rev 23851, labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/JmsInformationExtractor.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposerImpl.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposerImpl.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,290 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms.composers;
+
+import static org.jboss.esb.jms.JmsConstants.MESSAGE_ID;
+import static org.jboss.esb.jms.JmsConstants.REDELIVERED;
+import static org.jboss.esb.jms.JmsConstants.CORRELATION_ID;
+import static org.jboss.esb.jms.JmsConstants.REPLY_TO;
+import java.io.InputStream;
+import java.io.Serializable;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import javax.jms.BytesMessage;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.ObjectMessage;
+import javax.jms.Session;
+import javax.jms.StreamMessage;
+import javax.jms.TextMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+
+/**
+ * JMS Message Composer implementation.
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public final class JmsMessageComposerImpl implements JmsMessageComposer
+{
+ /**
+ * Extracts the payload from the ESB Message and creates a JMS Message.
+ * <p/>
+ * The type of the ESB Message payload will determine the type of the JMS Message instance:
+ * <pre>
+ * | Payload type | JMS Message Type |
+ * |----------------------------------------------------------------------------|
+ * | null | ObjectMessage with null retured from getObject()|
+ * | String | TextMessage |
+ * | byte[] | BytesMessage |
+ * | Map | MapMessage |
+ * | InputStream | StreamMessage |
+ * | Object(Serializable)| ObjectMessage |
+ * |----------------------------------------------------------------------------|
+ * </pre>
+ *
+ * @param esbMessage
+ * The ESB Message object.
+ * @param session
+ * The jms session that will be used to create the different types of JMS Message instances.
+ * @return javax.jms.jms.Message
+ * The newly created JMS Message with the type and contect of the passed-in ESB Message objects payload.
+ * @throws MessageProcessingException
+ * If an exception occurs while extracting the payload from the ESB Message.
+ */
+ public javax.jms.Message composeJmsMessage(Message esbMessage, Session session) throws MessageProcessingException
+ {
+ final Object payload = esbMessage.getPayload();
+ if (payload == null)
+ {
+ return createObjectMessage(null, session);
+ }
+ else if (payload instanceof String)
+ {
+ return createTextMessage((String)payload, session);
+ }
+ else if (payload instanceof byte[])
+ {
+ return createBytesMessage((byte[])payload, session);
+ }
+ else if (payload instanceof Map)
+ {
+ return createMapMessage((Map) payload, session);
+ }
+ else if (payload instanceof InputStream)
+ {
+ return createStreamMessage((InputStream) payload, session);
+ }
+ else if (payload instanceof Serializable)
+ {
+ return createObjectMessage((Serializable) payload, session);
+ }
+ else
+ {
+ throw new MessageProcessingException("Exception in decompose: Unsupported payload type '" + payload.getClass().getName() + "'");
+ }
+ }
+
+ private ObjectMessage createObjectMessage(final Serializable object, final Session session) throws MessageProcessingException
+ {
+ try
+ {
+ final ObjectMessage objectMessage = session.createObjectMessage();
+ objectMessage.setObject(object);
+ return objectMessage;
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("Could not create ObjectMessage with payload '" + object + "'", e);
+ }
+ }
+
+ private TextMessage createTextMessage(final String string, final Session session) throws MessageProcessingException
+ {
+ try
+ {
+ final TextMessage textMessage = session.createTextMessage();
+ textMessage.setText(string);
+ return textMessage;
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("Could not create TextMessage with payload '" + string + "'", e);
+ }
+ }
+
+ private BytesMessage createBytesMessage(final byte[] bytes, final Session session) throws MessageProcessingException
+ {
+ try
+ {
+ final BytesMessage bytesMessage = session.createBytesMessage();
+ bytesMessage.writeBytes(bytes);
+ return bytesMessage;
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("Could not create BytesMessage with payload '" + bytes + "'", e);
+ }
+ }
+
+ private MapMessage createMapMessage(final Map map, final Session session) throws MessageProcessingException
+ {
+ try
+ {
+ final MapMessage mapMessage = session.createMapMessage();
+ final Set<Map.Entry<String, ?>> entrySet = map.entrySet();
+ for (Map.Entry<String,?> me : entrySet)
+ {
+ mapMessage.setObject(me.getKey(), me.getValue());
+ }
+ return mapMessage;
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("Could not create MapMessage with payload '" + map + "'", e);
+ }
+ }
+
+ private StreamMessage createStreamMessage(final InputStream inputStream, final Session session) throws MessageProcessingException
+ {
+ try
+ {
+ final StreamMessage streamMessage = session.createStreamMessage();
+ return streamMessage;
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("Could not create StreamMessage with payload '" + inputStream + "'", e);
+ }
+ }
+
+ /**
+ * The following JMS Headers are set on the outbound JMS Message:
+ * <ul>
+ * <li>JMSCorrelationID -> get(JmsConstants.CORRELATION_ID) or get(JmsConstants.MESSAGE_ID)</li>
+ * <li>JMSRedelivered -> get(JmsConstants.REDELIVERED)</li>
+ * <li>JMSReplyTo -> get(JmsConstants.REPLY_TO)</li>
+ *
+ * @param jmsMessage The JMS Message.
+ * @throws JMSException Error extracting properties.
+ */
+ public void addEsbProperties(final Properties properties, javax.jms.Message toJmsMessage) throws MessageProcessingException
+ {
+ if (properties == null)
+ {
+ return;
+ }
+
+ setCorrelationId(properties, toJmsMessage);
+ setRedelivered(properties, toJmsMessage);
+ setReplyTo(properties, toJmsMessage);
+ }
+
+ private void setCorrelationId(final Properties properties, javax.jms.Message toJmsMessage) throws MessageProcessingException
+ {
+ final String correlationId = (String) properties.get(CORRELATION_ID);
+ if (correlationId != null)
+ {
+ try
+ {
+ toJmsMessage.setJMSCorrelationID(correlationId);
+ }
+ catch (final JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to set the JMSCorrelationID Header to '" + correlationId + "'", e);
+ }
+ }
+ else
+ {
+ setCorrelationIdToMessageId(properties, toJmsMessage);
+ }
+ }
+
+ /**
+ * Since the JMSMessageID header is set by the JMS Provider when sending there is no way for a
+ * producer to set the id prior to sending.
+ * We revert to setting the JMSMessageID as the JMSCorrelationID for the outbound JMS Message
+ * so messages can be correlated.
+ *
+ * @param properties The JMS Properites.
+ * @param toJmsMessage The outbound JMS Message.
+ *
+ * @throws MessageProcessingException If it was not possible to set the JMSCorrelationID.
+ */
+ private void setCorrelationIdToMessageId(final Properties properties, javax.jms.Message toJmsMessage) throws MessageProcessingException
+ {
+ final String messageId = (String) properties.get(MESSAGE_ID);
+ if (messageId != null)
+ {
+ try
+ {
+ toJmsMessage.setJMSCorrelationID(messageId);
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to set the JMSCorrelationID Header to '" + messageId + "'", e);
+ }
+ }
+ }
+
+ private void setRedelivered(final Properties properties, javax.jms.Message toJmsMessage) throws MessageProcessingException
+ {
+ final Boolean redelivered = (Boolean) properties.get(REDELIVERED);
+ if (redelivered != null)
+ {
+ try
+ {
+ toJmsMessage.setJMSRedelivered(redelivered.booleanValue());
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to set the JMSRedelivered Header to '" + redelivered + "'", e);
+ }
+ }
+ }
+
+ private void setReplyTo(final Properties properties, javax.jms.Message toJmsMessage) throws MessageProcessingException
+ {
+ final Destination replyTo = (Destination) properties.get(REPLY_TO);
+ if (replyTo != null)
+ {
+ try
+ {
+ toJmsMessage.setJMSReplyTo(replyTo);
+ }
+ catch (JMSException e)
+ {
+ throw new MessageProcessingException("JMSException while trying to set the JMSReplyTo Header to '" + replyTo + "'", e);
+ }
+ }
+ }
+
+ public void setConfiguration(Properties properties)
+ {
+ //NoOp
+ }
+
+}
Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/JmsMessageComposerImpl.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/composers/package.html 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+JMS Composers
+
+<h2>Package Specification</h2>
+</body>
+</html>
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/RouterUtil.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms.util;
+
+import java.util.Properties;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.Queue;
+import javax.naming.Context;
+
+import org.jboss.esb.api.context.ResourceLocator;
+import org.jboss.esb.api.exception.ConfigurationException;
+import org.jboss.esb.classpath.ClassUtil;
+import org.jboss.esb.jms.JMSSession;
+
+/**
+ * Simple methods common to both inbound and outbound JMSRouters.
+ * <p/>
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public final class RouterUtil
+{
+ private RouterUtil()
+ {
+ }
+
+ /**
+ * Creates a new instance of the passed in class name.
+ *
+ * @param className The name of the class to create. Must be an instance of FileWriter
+ * @return Object New instance of the class.
+ * @throws ConfigurationException If it was not able to create the class.
+ */
+ public static Object createInstance(final String className) throws ConfigurationException
+ {
+ try
+ {
+ final Class<?> forName = ClassUtil.forName(className, RouterUtil.class);
+ return forName.newInstance();
+ }
+ catch (final ClassNotFoundException e)
+ {
+ throw new ConfigurationException("Could not load class '" + className + "'. Exception was: " + e);
+ }
+ catch (final InstantiationException e)
+ {
+ throw new ConfigurationException("InstantiationException:" + e);
+ }
+ catch (final IllegalAccessException e)
+ {
+ throw new ConfigurationException("IllegalAccessException:" + e);
+ }
+ catch (final SecurityException e)
+ {
+ throw new ConfigurationException("SecurityException:" + e);
+ }
+ }
+
+ /**
+ * Create a new JMSSession.
+ *
+ * @return JMSSession The newly created connected session.
+ * @throws JMSException If and error occurs while trying to create or connect.
+ */
+ public static JMSSession createJMSSession(final Properties jmsProperties, final ResourceLocator resourceLocator) throws JMSException
+ {
+ final JMSSession session = new JMSSession(jmsProperties);
+ session.setClassLoader(resourceLocator.getClassLoader());
+ return session;
+ }
+
+ public static void setDestinationTyp(final String destinationName, final JMSSession session) throws JMSException
+ {
+ final Destination destination = session.lookupDestination(destinationName);
+ if (destination instanceof Queue)
+ {
+ session.setSessionType(JMSSession.Type.QUEUE);
+ }
+ else
+ {
+ session.setSessionType(JMSSession.Type.TOPIC);
+ }
+ }
+
+ public static Properties getDefaultProperties()
+ {
+ final Properties defaults = new Properties();
+ defaults.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
+ defaults.put(Context.PROVIDER_URL, "jnp://localhost:1099");
+ return defaults;
+ }
+
+ public static void closeJmsSession(final JMSSession session)
+ {
+ if (session != null)
+ {
+ session.close();
+ }
+ }
+
+}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/package.html
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/package.html (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/main/java/org/jboss/esb/jms/util/package.html 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,8 @@
+<html>
+<head></head>
+<body>
+JMS Router Utils
+
+<h2>Package Specification</h2>
+</body>
+</html>
Deleted: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInformationExtractorTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInformationExtractorTest.java 2008-11-18 11:08:34 UTC (rev 23918)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInformationExtractorTest.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -1,317 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source Copyright 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.esb.jms;
-
-import static org.jboss.esb.jms.JmsConstants.CORRELATION_ID;
-import static org.jboss.esb.jms.JmsConstants.EXPIRATION;
-import static org.jboss.esb.jms.JmsConstants.MESSAGE_ID;
-import static org.jboss.esb.jms.JmsConstants.PRIORITY;
-import static org.jboss.esb.jms.JmsConstants.REDELIVERED;
-import static org.jboss.esb.jms.JmsConstants.REPLY_TO;
-import static org.jboss.esb.jms.JmsConstants.TIMESTAMP;
-import static org.jboss.esb.jms.JmsConstants.DELIVERY_MODE;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.jms.DeliveryMode;
-import javax.jms.Destination;
-import javax.jms.JMSException;
-
-import org.jboss.esb.api.message.Message;
-import org.jboss.esb.api.routing.RoutingException;
-import org.junit.Test;
-
-import com.mockrunner.mock.jms.MockBytesMessage;
-import com.mockrunner.mock.jms.MockMapMessage;
-import com.mockrunner.mock.jms.MockObjectMessage;
-import com.mockrunner.mock.jms.MockQueue;
-import com.mockrunner.mock.jms.MockStreamMessage;
-import com.mockrunner.mock.jms.MockTextMessage;
-
-
-/**
- * Test for {@link JmsInformationExtractor}.
- *
- * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
- *
- */
-public class JmsInformationExtractorTest
-{
- @Test
- public void extractContentTextMessage() throws RoutingException, JMSException
- {
- final String content = "testing text message content";
- final MockTextMessage textMessage = new MockTextMessage();
- textMessage.setText(content);
- final Message esbMessage = JmsInformationExtractor.extractPayload(textMessage);
- assertEquals( content, esbMessage.getPayload());
- }
-
- @Test ( expected = RoutingException.class )
- public void shouldThrowIfTextMessageIsNull() throws RoutingException, JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- textMessage.setText(null);
- JmsInformationExtractor.extractPayload(textMessage);
- }
-
- @Test
- public void extractContentObjectMessage() throws RoutingException, JMSException
- {
- final String content = "testing text message content";
- final MockObjectMessage objectMessage = new MockObjectMessage();
- objectMessage.setObject(content);
- final Message esbMessage = JmsInformationExtractor.extractPayload(objectMessage);
- assertEquals( content, esbMessage.getPayload());
- }
-
- @Test ( expected = RoutingException.class )
- public void shouldThrowIfObjectMessagePayloadIsNull() throws RoutingException, JMSException
- {
- final MockObjectMessage objectMessage = new MockObjectMessage();
- objectMessage.setObject(null);
- JmsInformationExtractor.extractPayload(objectMessage);
- }
-
- @Test
- public void extractContentBytesMessage() throws RoutingException, JMSException
- {
- final byte[] content = "testing text message content".getBytes();
- final MockBytesMessage bytesMessage = new MockBytesMessage();
- bytesMessage.writeObject(content);
- final Message esbMessage = JmsInformationExtractor.extractPayload(bytesMessage);
- Object payload = esbMessage.getPayload();
- assertTrue(payload instanceof byte[]);
- assertEquals( new String(content), new String((byte[])esbMessage.getPayload()));
- }
-
- @Test ( expected = RoutingException.class )
- public void shouldThrowBytesMessagePayloadIsNull() throws RoutingException, JMSException
- {
- final MockBytesMessage bytesMessage = new MockBytesMessage();
- JmsInformationExtractor.extractPayload(bytesMessage);
- }
-
- @Test
- public void extractContentMapMessage() throws RoutingException, JMSException
- {
- final MockMapMessage mapMessage = new MockMapMessage();
- mapMessage.setObject("key1", "value1");
- mapMessage.setObject("key2", "value2");
- final Message esbMessage = JmsInformationExtractor.extractPayload(mapMessage);
- Object payload = esbMessage.getPayload();
- assertTrue(payload instanceof Map);
-
- Map esbMap = (Map)payload;
- assertTrue(esbMap.containsKey("key1"));
- assertTrue(esbMap.containsKey("key2"));
- assertEquals("value1", esbMap.get("key1"));
- assertEquals("value2", esbMap.get("key2"));
- }
-
- @Test ( expected = RoutingException.class )
- public void shouldThrowIfMapMessageIsEmptyMap() throws RoutingException, JMSException
- {
- final MockMapMessage mapMessage = new MockMapMessage();
- JmsInformationExtractor.extractPayload(mapMessage);
- }
-
- @Test
- public void extractContentStreamMessageStreamAdapter() throws RoutingException, JMSException, ClassNotFoundException, IOException
- {
- final byte[] content = "testing text message content".getBytes();
- final MockStreamMessage streamMessage = new MockStreamMessage();
- streamMessage.writeObject(content);
-
- final Message esbMessage = JmsInformationExtractor.extractPayload(streamMessage);
-
- final Object payload = esbMessage.getPayload();
- assertTrue(payload instanceof InputStream);
- final StreamMessageInputStream adapter = (StreamMessageInputStream)payload;
- adapter.reset();
- final Object readObject = adapter.getStreamMessage().readObject();
- assertTrue(readObject instanceof byte[]);
- assertEquals(new String(content), new String((byte[])readObject));
- }
-
- @Test
- public void extractContentStreamMessageInputStream() throws RoutingException, JMSException, ClassNotFoundException, IOException
- {
- final byte[] content = "testing text message content".getBytes();
- final MockStreamMessage streamMessage = new MockStreamMessage();
- streamMessage.writeObject(content);
-
- final Message esbMessage = JmsInformationExtractor.extractPayload(streamMessage);
-
- assertTrue(esbMessage.getPayload() instanceof InputStream);
- final InputStream in = (InputStream)esbMessage.getPayload();
- in.reset();
-
- // read from InputStream
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- final byte[] buf = new byte[1024];
- int len;
- while ((len = in.read(buf)) > 0)
- {
- bos.write(buf, 0, len);
- }
- byte[] data = bos.toByteArray();
- assertEquals(new String(content), new String(data));
- }
-
- @Test
- public void extractProperties() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- textMessage.setObjectProperty("testKey", "testValue");
- textMessage.setJMSCorrelationID("1234");
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("User property should have been set", jmsProperties.containsKey("testKey"));
- assertEquals("testValue", jmsProperties.get("testKey"));
- }
-
- @Test
- public void extractPropertiesJMSCorrelationID() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- textMessage.setJMSCorrelationID("1234");
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("CorrelationId property should have been set", jmsProperties.containsKey(CORRELATION_ID));
- assertEquals("1234", jmsProperties.get(CORRELATION_ID));
- }
-
- @Test
- public void extractPropertiesJMSExpiration() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- textMessage.setJMSExpiration(1000l);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("Expiration property should have been set", jmsProperties.containsKey(EXPIRATION));
- assertEquals(1000l, jmsProperties.get(EXPIRATION));
- }
-
- @Test
- public void extractPropertiesJMSMessageID() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- final String messageId = "jmsMessageID1133";
- textMessage.setJMSMessageID(messageId);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("MessageId property should have been set", jmsProperties.containsKey(MESSAGE_ID));
- assertEquals(messageId, jmsProperties.get(MESSAGE_ID));
- }
-
- @Test
- public void extractPropertiesJMSRedelivered() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- final boolean redelivered = true;
- textMessage.setJMSRedelivered(redelivered);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("Redelivered property should have been set", jmsProperties.containsKey(REDELIVERED));
- assertEquals(redelivered, jmsProperties.get(REDELIVERED));
- }
-
- @Test
- public void extractPropertiesJMSTimestamp() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- final long timestamp = System.currentTimeMillis();
- textMessage.setJMSTimestamp(timestamp);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("Timestamp property should have been set", jmsProperties.containsKey(TIMESTAMP));
- assertEquals(timestamp, jmsProperties.get(TIMESTAMP));
- }
-
- @Test
- public void extractPropertiesJMSReplyTo() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- final Destination destination = new MockQueue("testing");
- textMessage.setJMSReplyTo(destination);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("ReplyTo property should have been set", jmsProperties.containsKey(REPLY_TO));
- assertEquals(destination, jmsProperties.get(REPLY_TO));
- }
-
- @Test
- public void extractPropertiesJMSPriority() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- final int priority = 0;
- textMessage.setJMSPriority(priority);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertTrue("Priority property should have been set", jmsProperties.containsKey(PRIORITY));
- assertEquals(priority, jmsProperties.get(PRIORITY));
- }
-
- @Test
- public void extractPropertiesJMSPriorityNegative() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- final int priority = -1;
- textMessage.setJMSPriority(priority);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertFalse("Priority property should not have been set", jmsProperties.containsKey(PRIORITY));
- }
-
- @Test
- public void extractPropertiesJMSPriorityTooLarge() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- final int priority = 10;
- textMessage.setJMSPriority(priority);
-
- final Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertFalse("Priority property should not have been set", jmsProperties.containsKey(PRIORITY));
- }
-
- @Test
- public void extractPropertiesJMSDeliveryMode() throws JMSException
- {
- final MockTextMessage textMessage = new MockTextMessage();
- textMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
-
- Properties jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertEquals(DeliveryMode.NON_PERSISTENT, jmsProperties.get(DELIVERY_MODE));
-
- textMessage.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
- jmsProperties = JmsInformationExtractor.extractJmsProperties(textMessage);
- assertEquals(DeliveryMode.PERSISTENT, jmsProperties.get(DELIVERY_MODE));
- }
-
-}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsOutboundRouterTest.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,155 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.IOException;
+import java.util.Properties;
+import java.util.concurrent.TimeUnit;
+
+import javax.jms.Destination;
+import javax.jms.JMSException;
+import javax.jms.MessageConsumer;
+import javax.jms.QueueConnection;
+import javax.jms.QueueConnectionFactory;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+import org.jboss.esb.api.context.InvocationContext;
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.routing.OutboundRouter;
+import org.jboss.esb.api.routing.RoutingException;
+import org.jboss.esb.api.service.ServiceName;
+import org.jboss.esb.deploy.DeploymentException;
+import org.jboss.esb.deploy.DeploymentRuntime;
+import org.jboss.esb.deploy.DeploymentUtil;
+import org.jboss.esb.deploy.config.OutboundRouterConfig;
+import org.jboss.esb.test.JmsTestBusProvider;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Test for {@link JmsOutboundRouter}.
+ *
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ *
+ */
+public class JmsOutboundRouterTest
+{
+ private static JmsTestBusProvider jmsProvider;
+
+ @Test
+ public void route() throws DeploymentException, IOException, InterruptedException, RoutingException, JMSException, NamingException
+ {
+ final DeploymentRuntime runtime = getRuntime();
+ final JmsOutboundRouter router = (JmsOutboundRouter)getRouter(runtime);
+ InvocationContext.setContext(new InvocationContext());
+ assertNotNull(router);
+
+ try
+ {
+ runtime.deploy();
+ TimeUnit.SECONDS.sleep(3);
+
+ final String payload = "<message/>";
+ final Message message = new Message();
+ message.setPayload(payload);
+ router.route(message);
+
+ javax.jms.Message jmsMessage = recieveMessage(router.getDestination(), router.getJmsProperties(), 5000L);
+ assertTrue(jmsMessage instanceof TextMessage);
+ assertEquals(payload, ((TextMessage)jmsMessage).getText());
+ }
+ finally
+ {
+ runtime.undeploy();
+ }
+ }
+
+ @Test (expected = DeploymentException.class)
+ public void shouldThrowIfInvalidMessageComposerIsConfigured() throws DeploymentException, IOException, InterruptedException
+ {
+ DeploymentRuntime runtime = DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-outbound-router-invalid.xml"));
+ runtime.deploy();
+ }
+
+ @BeforeClass
+ public static void startProvider() throws Exception
+ {
+ jmsProvider = new JmsTestBusProvider();
+ jmsProvider.start();
+ }
+
+ @AfterClass
+ public static void stopProvider() throws Exception
+ {
+ jmsProvider.stop();
+ }
+
+ private DeploymentRuntime getRuntime() throws DeploymentException, IOException
+ {
+ return DeploymentUtil.createRuntime(getClass().getResourceAsStream("jms-outbound-router.xml"));
+ }
+
+ private OutboundRouter getRouter(final DeploymentRuntime runtime) throws DeploymentException
+ {
+ final OutboundRouterConfig routerConfig = DeploymentUtil.getOutboundRouter(new ServiceName("serviceCat", "serviceName"), "outrouter", runtime);
+ return routerConfig.getRouter();
+ }
+
+ private javax.jms.Message recieveMessage(String destinationName, Properties jndiProperties, long timeout) throws JMSException, NamingException
+ {
+ QueueConnection connection = null;
+ QueueSession session = null;
+ try
+ {
+ final InitialContext ctx = new InitialContext(jndiProperties);
+ QueueConnectionFactory factory = (QueueConnectionFactory) ctx.lookup("ConnectionFactory");
+ connection = factory.createQueueConnection();
+ connection.start();
+ session = connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageConsumer consumer = session.createConsumer((Destination)ctx.lookup(destinationName));
+ return consumer.receive(timeout);
+ }
+ finally
+ {
+ if (session != null)
+ {
+ session.close();
+ }
+ if (connection != null)
+ {
+ connection.close();
+ }
+ }
+ }
+
+ static class InvalidJmsMessageComposer
+ {
+ }
+}
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/EsbMessageComposerImplTest.java
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/EsbMessageComposerImplTest.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/EsbMessageComposerImplTest.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,326 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms.composers;
+
+import static org.jboss.esb.jms.JmsConstants.CORRELATION_ID;
+import static org.jboss.esb.jms.JmsConstants.DELIVERY_MODE;
+import static org.jboss.esb.jms.JmsConstants.EXPIRATION;
+import static org.jboss.esb.jms.JmsConstants.MESSAGE_ID;
+import static org.jboss.esb.jms.JmsConstants.PRIORITY;
+import static org.jboss.esb.jms.JmsConstants.REDELIVERED;
+import static org.jboss.esb.jms.JmsConstants.REPLY_TO;
+import static org.jboss.esb.jms.JmsConstants.TIMESTAMP;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jms.DeliveryMode;
+import javax.jms.Destination;
+import javax.jms.JMSException;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.jms.StreamMessageInputStream;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.mockrunner.mock.jms.MockBytesMessage;
+import com.mockrunner.mock.jms.MockMapMessage;
+import com.mockrunner.mock.jms.MockObjectMessage;
+import com.mockrunner.mock.jms.MockQueue;
+import com.mockrunner.mock.jms.MockStreamMessage;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test for {@link EsbMessageComposerImpl}.
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public class EsbMessageComposerImplTest
+{
+ private EsbMessageComposerImpl composer;
+
+ @Test
+ public void composeEsbMessageTextMessage() throws JMSException, MessageProcessingException
+ {
+ final String content = "testing text message content";
+ final MockTextMessage textMessage = new MockTextMessage();
+ textMessage.setText(content);
+ final Message esbMessage = composer.composeEsbMessage(textMessage, null);
+ assertEquals( content, esbMessage.getPayload());
+ }
+
+ @Test ( expected = MessageProcessingException.class )
+ public void shouldThrowIfTextMessageIsNull() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ textMessage.setText(null);
+ composer.composeEsbMessage(textMessage, null);
+ }
+
+ @Test
+ public void createEsbMessageObjectMessage() throws JMSException, MessageProcessingException
+ {
+ final String content = "testing text message content";
+ final MockObjectMessage objectMessage = new MockObjectMessage();
+ objectMessage.setObject(content);
+ final Message esbMessage = composer.composeEsbMessage(objectMessage, null);
+ assertEquals( content, esbMessage.getPayload());
+ }
+
+ @Test (expected = MessageProcessingException.class)
+ public void shouldThrowIfObjectMessagePayloadIsNull() throws JMSException, MessageProcessingException
+ {
+ final MockObjectMessage objectMessage = new MockObjectMessage();
+ objectMessage.setObject(null);
+ composer.composeEsbMessage(objectMessage, null);
+ }
+
+ @Test
+ public void createEsbMessageBytesMessage() throws JMSException, MessageProcessingException
+ {
+ final byte[] content = "testing text message content".getBytes();
+ final MockBytesMessage bytesMessage = new MockBytesMessage();
+ bytesMessage.writeObject(content);
+ final Message esbMessage = composer.composeEsbMessage(bytesMessage, null);
+ Object payload = esbMessage.getPayload();
+ assertTrue(payload instanceof byte[]);
+ assertEquals( new String(content), new String((byte[])esbMessage.getPayload()));
+ }
+
+ @Test (expected = MessageProcessingException.class)
+ public void shouldThrowBytesMessagePayloadIsNull() throws JMSException, MessageProcessingException
+ {
+ final MockBytesMessage bytesMessage = new MockBytesMessage();
+ composer.composeEsbMessage(bytesMessage, null);
+ }
+
+ @Test
+ public void createEsbMessageMapMessage() throws JMSException, MessageProcessingException
+ {
+ final MockMapMessage mapMessage = new MockMapMessage();
+ mapMessage.setObject("key1", "value1");
+ mapMessage.setObject("key2", "value2");
+ final Message esbMessage = composer.composeEsbMessage(mapMessage, null);
+ Object payload = esbMessage.getPayload();
+ assertTrue(payload instanceof Map);
+
+ Map esbMap = (Map)payload;
+ assertTrue(esbMap.containsKey("key1"));
+ assertTrue(esbMap.containsKey("key2"));
+ assertEquals("value1", esbMap.get("key1"));
+ assertEquals("value2", esbMap.get("key2"));
+ }
+
+ @Test (expected = MessageProcessingException.class)
+ public void shouldThrowIfMapMessageIsEmptyMap() throws JMSException, MessageProcessingException
+ {
+ final MockMapMessage mapMessage = new MockMapMessage();
+ composer.composeEsbMessage(mapMessage, null);
+ }
+
+ @Test
+ public void createEsbMessageStreamMessageStreamAdapter() throws JMSException, ClassNotFoundException, IOException, MessageProcessingException
+ {
+ final byte[] content = "testing text message content".getBytes();
+ final MockStreamMessage streamMessage = new MockStreamMessage();
+ streamMessage.writeObject(content);
+
+ final Message esbMessage = composer.composeEsbMessage(streamMessage, null);
+
+ final Object payload = esbMessage.getPayload();
+ assertTrue(payload instanceof InputStream);
+ final StreamMessageInputStream adapter = (StreamMessageInputStream)payload;
+ adapter.reset();
+ final Object readObject = adapter.getStreamMessage().readObject();
+ assertTrue(readObject instanceof byte[]);
+ assertEquals(new String(content), new String((byte[])readObject));
+ }
+
+ @Test
+ public void createEsbMessageStreamMessageInputStream() throws JMSException, ClassNotFoundException, IOException, MessageProcessingException
+ {
+ final byte[] content = "testing text message content".getBytes();
+ final MockStreamMessage streamMessage = new MockStreamMessage();
+ streamMessage.writeObject(content);
+
+ final Message esbMessage = composer.composeEsbMessage(streamMessage, null);
+
+ assertTrue(esbMessage.getPayload() instanceof InputStream);
+ final InputStream in = (InputStream)esbMessage.getPayload();
+ in.reset();
+
+ // read from InputStream
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ final byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0)
+ {
+ bos.write(buf, 0, len);
+ }
+ byte[] data = bos.toByteArray();
+ assertEquals(new String(content), new String(data));
+ }
+
+ @Test
+ public void extractProperties() throws MessageProcessingException, JMSException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ textMessage.setObjectProperty("testKey", "testValue");
+ textMessage.setJMSCorrelationID("1234");
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("User property should have been set", jmsProperties.containsKey("testKey"));
+ assertEquals("testValue", jmsProperties.get("testKey"));
+ }
+
+ @Test
+ public void extractPropertiesJMSCorrelationID() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ textMessage.setJMSCorrelationID("1234");
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("CorrelationId property should have been set", jmsProperties.containsKey(CORRELATION_ID));
+ assertEquals("1234", jmsProperties.get(CORRELATION_ID));
+ }
+
+ @Test
+ public void extractPropertiesJMSExpiration() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ textMessage.setJMSExpiration(1000l);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("Expiration property should have been set", jmsProperties.containsKey(EXPIRATION));
+ assertEquals(1000l, jmsProperties.get(EXPIRATION));
+ }
+
+ @Test
+ public void extractPropertiesJMSMessageID() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ final String messageId = "jmsMessageID1133";
+ textMessage.setJMSMessageID(messageId);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("MessageId property should have been set", jmsProperties.containsKey(MESSAGE_ID));
+ assertEquals(messageId, jmsProperties.get(MESSAGE_ID));
+ }
+
+ @Test
+ public void extractPropertiesJMSRedelivered() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ final boolean redelivered = true;
+ textMessage.setJMSRedelivered(redelivered);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("Redelivered property should have been set", jmsProperties.containsKey(REDELIVERED));
+ assertEquals(redelivered, jmsProperties.get(REDELIVERED));
+ }
+
+ @Test
+ public void extractPropertiesJMSTimestamp() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ final long timestamp = System.currentTimeMillis();
+ textMessage.setJMSTimestamp(timestamp);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("Timestamp property should have been set", jmsProperties.containsKey(TIMESTAMP));
+ assertEquals(timestamp, jmsProperties.get(TIMESTAMP));
+ }
+
+ @Test
+ public void extractPropertiesJMSReplyTo() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ final Destination destination = new MockQueue("testing");
+ textMessage.setJMSReplyTo(destination);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("ReplyTo property should have been set", jmsProperties.containsKey(REPLY_TO));
+ assertEquals(destination, jmsProperties.get(REPLY_TO));
+ }
+
+ @Test
+ public void extractPropertiesJMSPriority() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ final int priority = 0;
+ textMessage.setJMSPriority(priority);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertTrue("Priority property should have been set", jmsProperties.containsKey(PRIORITY));
+ assertEquals(priority, jmsProperties.get(PRIORITY));
+ }
+
+ @Test
+ public void extractPropertiesJMSPriorityNegative() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ final int priority = -1;
+ textMessage.setJMSPriority(priority);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertFalse("Priority property should not have been set", jmsProperties.containsKey(PRIORITY));
+ }
+
+ @Test
+ public void extractPropertiesJMSPriorityTooLarge() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ final int priority = 10;
+ textMessage.setJMSPriority(priority);
+
+ final Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertFalse("Priority property should not have been set", jmsProperties.containsKey(PRIORITY));
+ }
+
+ @Test
+ public void extractPropertiesJMSDeliveryMode() throws JMSException, MessageProcessingException
+ {
+ final MockTextMessage textMessage = new MockTextMessage();
+ textMessage.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+
+ Properties jmsProperties = composer.extractJmsProperties(textMessage);
+ assertEquals(DeliveryMode.NON_PERSISTENT, jmsProperties.get(DELIVERY_MODE));
+
+ textMessage.setJMSDeliveryMode(DeliveryMode.PERSISTENT);
+ jmsProperties = composer.extractJmsProperties(textMessage);
+ assertEquals(DeliveryMode.PERSISTENT, jmsProperties.get(DELIVERY_MODE));
+ }
+
+ @Before
+ public void setup()
+ {
+ composer = new EsbMessageComposerImpl();
+ }
+}
Copied: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/JmsMessageComposerImplTest.java (from rev 23851, labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/JmsInformationExtractorTest.java)
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/JmsMessageComposerImplTest.java (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/JmsMessageComposerImplTest.java 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,179 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 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.esb.jms.composers;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.jms.BytesMessage;
+import javax.jms.JMSException;
+import javax.jms.MapMessage;
+import javax.jms.ObjectMessage;
+import javax.jms.TextMessage;
+
+import org.jboss.esb.api.message.Message;
+import org.jboss.esb.api.message.MessageProcessingException;
+import org.jboss.esb.jms.JmsConstants;
+import org.junit.Before;
+import org.junit.Test;
+
+import com.mockrunner.jms.DestinationManager;
+import com.mockrunner.mock.jms.MockConnection;
+import com.mockrunner.mock.jms.MockQueue;
+import com.mockrunner.mock.jms.MockSession;
+import com.mockrunner.mock.jms.MockTextMessage;
+
+
+/**
+ * Test for {@link JmsMessageComposerImpl}.
+ *
+ * @author <a href="mailto:dbevenius at redhat.com">Daniel Bevenius</a>
+ *
+ */
+public class JmsMessageComposerImplTest
+{
+ private JmsMessageComposerImpl composer;
+ private MockSession mockSession;
+
+ @Test
+ public void decomposeNullPayload() throws MessageProcessingException, JMSException
+ {
+ final Message esbMessage = new Message();
+ esbMessage.setPayload(null);
+
+ javax.jms.Message jmsMessage = composer.composeJmsMessage(esbMessage, mockSession);
+
+ assertTrue(jmsMessage instanceof ObjectMessage);
+ ObjectMessage objectMessage = (ObjectMessage)jmsMessage;
+ assertNull(objectMessage.getObject());
+ }
+
+ @Test
+ public void decomposeStringPayload() throws MessageProcessingException, JMSException
+ {
+ final String payload = "ESB Message payload";
+ final Message esbMessage = new Message();
+ esbMessage.setPayload(payload);
+
+ javax.jms.Message jmsMessage = composer.composeJmsMessage(esbMessage, mockSession);
+
+ assertTrue(jmsMessage instanceof TextMessage);
+ TextMessage textMessage = (TextMessage)jmsMessage;
+ assertEquals(payload, textMessage.getText());
+ }
+
+ @Test
+ public void decomposeByteArrayPayload() throws MessageProcessingException, JMSException
+ {
+ final String payload = "ESB Message payload";
+ final Message esbMessage = new Message();
+ esbMessage.setPayload(payload.getBytes());
+
+ javax.jms.Message jmsMessage = composer.composeJmsMessage(esbMessage, mockSession);
+
+ assertTrue(jmsMessage instanceof BytesMessage);
+ }
+
+ @Test
+ public void decomposeMapPayload() throws MessageProcessingException, JMSException
+ {
+ final Map<String, Object> payload = new HashMap<String, Object>();
+ payload.put("key1", "value1");
+ payload.put("key2", "value2");
+
+ final Message esbMessage = new Message();
+ esbMessage.setPayload(payload);
+
+ javax.jms.Message jmsMessage = composer.composeJmsMessage(esbMessage, mockSession);
+
+ assertTrue(jmsMessage instanceof MapMessage);
+ MapMessage mapMessage = (MapMessage)jmsMessage;
+ assertEquals(payload.get("key1"), mapMessage.getObject("key1"));
+ assertEquals(payload.get("key2"), mapMessage.getObject("key2"));
+ }
+
+ @Test
+ public void addEsbPropertiesCorrelationId() throws MessageProcessingException, JMSException
+ {
+ final Properties properties = new Properties();
+ final String correlationId = "correlationId-1234";
+ properties.put(JmsConstants.CORRELATION_ID, correlationId);
+ MockTextMessage textMessage = new MockTextMessage();
+
+ composer.addEsbProperties(properties, textMessage);
+
+ assertEquals(correlationId, textMessage.getJMSCorrelationID());
+ }
+
+ @Test
+ public void addEsbPropertiesRedelivered() throws MessageProcessingException, JMSException
+ {
+ final Properties properties = new Properties();
+ final boolean redelivered = true;
+ properties.put(JmsConstants.REDELIVERED, redelivered);
+ MockTextMessage textMessage = new MockTextMessage();
+
+ composer.addEsbProperties(properties, textMessage);
+
+ assertEquals(redelivered, textMessage.getJMSRedelivered());
+ }
+
+ @Test
+ public void addEsbPropertiesMessageID() throws MessageProcessingException, JMSException
+ {
+ final Properties properties = new Properties();
+ final String messageId = "1234-32-22";
+ properties.put(JmsConstants.MESSAGE_ID, messageId);
+ MockTextMessage textMessage = new MockTextMessage();
+
+ composer.addEsbProperties(properties, textMessage);
+
+ assertEquals(messageId, textMessage.getJMSCorrelationID());
+ }
+
+ @Test
+ public void addEsbPropertiesReplyTo() throws MessageProcessingException, JMSException
+ {
+ final Properties properties = new Properties();
+ final MockQueue replyTo = new MockQueue("replyToQueue");
+ properties.put(JmsConstants.REPLY_TO, replyTo);
+ MockTextMessage textMessage = new MockTextMessage();
+
+ composer.addEsbProperties(properties, textMessage);
+
+ assertEquals(replyTo, textMessage.getJMSReplyTo());
+ }
+
+ @Before
+ public void setup()
+ {
+ DestinationManager destinationManager = new DestinationManager();
+ MockConnection connection = new MockConnection(destinationManager, null);
+ mockSession = new MockSession(connection, true, 0);
+ composer = new JmsMessageComposerImpl();
+ }
+
+}
Property changes on: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/composers/JmsMessageComposerImplTest.java
___________________________________________________________________
Name: svn:mergeinfo
+
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router-invalid.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,15 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+ <services>
+ <service serviceCategory="serviceCat2" serviceName="serviceName2" serviceDescription="TestService" class="org.jboss.esb.jms.MyTestService">
+ <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
+ <property name="java.naming.provider.url">tcp://localhost:61717</property>
+ <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
+ <property name="jmsDestination">jbossesb.TestOutQueue</property>
+ <property name="queue.jbossesb.TestOutQueue">jbossesb.TestOutQueue</property>
+ <property name="jmsMessageComposer">org.jboss.esb.jms.JmsOutboundRouterTest$InvalidJmsMessageComposer</property>
+ </outRouter>
+ </service>
+ </services>
+
+</jbossesb>
\ No newline at end of file
Added: labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml
===================================================================
--- labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml (rev 0)
+++ labs/jbossesb/workspace/skeagh/routing/jms/src/test/java/org/jboss/esb/jms/jms-outbound-router.xml 2008-11-18 12:13:26 UTC (rev 23919)
@@ -0,0 +1,14 @@
+<jbossesb xmlns="http://www.jboss.org/jbossesb/xsd/jbossesb-5.0.xsd">
+
+ <services>
+ <service serviceCategory="serviceCat" serviceName="serviceName" serviceDescription="TestService" class="org.jboss.esb.jms.MyTestService">
+ <outRouter name="outrouter" class="org.jboss.esb.jms.JmsOutboundRouter">
+ <property name="java.naming.provider.url">tcp://localhost:61717</property>
+ <property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
+ <property name="jmsDestination">jbossesb.TestOutQueue</property>
+ <property name="queue.jbossesb.TestOutQueue">jbossesb.TestOutQueue</property>
+ </outRouter>
+ </service>
+ </services>
+
+</jbossesb>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list