[jboss-svn-commits] JBL Code SVN: r18467 - in labs/jbossesb/trunk/product: rosetta/tests/src/org/jboss/soa/esb/actions/routing and 11 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Feb 12 14:49:32 EST 2008
Author: beve
Date: 2008-02-12 14:49:32 -0500 (Tue, 12 Feb 2008)
New Revision: 18467
Added:
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/deployment.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbossesb-properties.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jndi.properties
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/juddi.properties
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/log4j.xml
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/readme.txt
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/
labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java
Modified:
labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java
Log:
Work for JBESB-768 "Quickstart that demos JMS custom_correlation"
Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java 2008-02-12 19:20:27 UTC (rev 18466)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/actions/routing/JMSRouter.java 2008-02-12 19:49:32 UTC (rev 18467)
@@ -62,23 +62,27 @@
* Sample Action Configuration:
* <pre>
* <action class="org.jboss.soa.esb.actions.routing.JMSRouter">
- * jndiName="queue/A"
- * message-prop-<i>>prop-name<</i>="<i>>prop-value<</i>" >!-- (Optional)--<
- * unwrap="true/false" >!-- (Optional - default false)--<
- * persistent="true/false" >!-- (Optional - default true)--<
- * priority="integer" >!-- (Optional - default Message.DEFAULT_PRIORITY)--<
- * time-to-live="long" >!-- (Optional - default Message.DEFAULT_TIME_TO_LIVE)--<
- * />
+ * <property name="jndiName" value="queue/A"/>
+ * </action>
+ *
+ * Option properties (default values shown):
+ * <property name="unwrap" value="false"/>
+ * <property name="jndi-context-factory" value="org.jnp.interfaces.NamingContextFactory"/>
+ * <property name="jndi-URL" value="127.0.0.1:1099"/>
+ * <property name="jndi-pkg-prefix" value="org.jboss.naming:org.jnp.interfaces"/>
+ * <property name="connection-factory" value="ConnectionFactory"/>
+ * <property name="persistent" value="true"/>
+ * <property name="priority" value="javax.jms.Message.DEFAULT_PRIORITY"/>
+ * <property name="time-to-live" value="javax.jms.Message.DEFAULT_TIME_TO_LIVE"/>
+ * <property name="message-prop-<i>>prop-name<</i>="<i>> value="prop-value<</i>" />
* </pre>
* Note how properties to be set on the message are prefixed with "message-prop-".
* <p/>
* <ul>
- * <li>'unwrap' true will extract the message payload from the Message object before sending</li>
- * <li>'unwrap' false false will send the serialized Message object</li>
+ * <li>'unwrap' true will extract the message payload from the ESB Message object before sending</li>
+ * <li>'unwrap' false will send the serialized ESB Message object</li>
* </ul>
- *
- * TODO: Add support for JMS Topic destinations.
- *
+ *
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
* @author <a href="mailto:daniel.bevenius at redpill.se">daniel.bevenius at redpill.se</a>
* @since Version 4.0
@@ -89,7 +93,7 @@
*/
private static Logger logger = Logger.getLogger(JMSRouter.class);
/**
- * Constant used in configuration
+ * Constant used in configuration
*/
public static final String PERSISTENT_ATTR = "persistent";
/**
@@ -130,7 +134,11 @@
* The time-to-live for messages sent with this router
*/
private long timeToLive = Message.DEFAULT_TIME_TO_LIVE;
-
+ private String jndiContextFactory;
+ private String jndiUrl;
+ private String jndiPkgPrefix;
+ private String connectionFactory;
+
/**
* Public constructor.
* @param propertiesTree Action properties.
@@ -141,28 +149,33 @@
public JMSRouter(ConfigTree propertiesTree) throws ConfigurationException, NamingException, JMSException {
super(propertiesTree);
- this.properties = propertiesTree;
+ this.properties = propertiesTree;
logger.debug(properties);
-
+
queueName = properties.getAttribute("jndiName");
if(queueName == null) {
throw new ConfigurationException("JMSRouter must specify a 'jndiName' property.");
}
-
+
boolean persistent = Boolean.parseBoolean( properties.getAttribute(PERSISTENT_ATTR, "true") );
deliveryMode = persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT;
-
+
String priorityStr = properties.getAttribute(PRIORITY_ATTR);
if ( priorityStr != null )
priority = Integer.parseInt( priorityStr );
-
+
final String ttlStr = properties.getAttribute(TIME_TO_LIVE_ATTR);
if ( ttlStr != null )
timeToLive = Long.parseLong( ttlStr );
-
- createQueueSetup( queueName );
+
+ jndiContextFactory = properties.getAttribute( JMSEpr.JNDI_CONTEXT_FACTORY_TAG );
+ jndiUrl = properties.getAttribute( JMSEpr.JNDI_URL_TAG );
+ jndiPkgPrefix = properties.getAttribute( JMSEpr.JNDI_PKG_PREFIX_TAG );
+ connectionFactory = properties.getAttribute( JMSEpr.CONNECTION_FACTORY_TAG );
+
+ createQueueSetup( queueName, jndiContextFactory, jndiUrl, jndiPkgPrefix, connectionFactory );
}
-
+
/**
* Will simply pass the message to the route method unmodified.
* @return <code>null</code> which will case the action pipeline processing to stop
@@ -171,7 +184,7 @@
public org.jboss.soa.esb.message.Message process( org.jboss.soa.esb.message.Message message ) throws ActionProcessingException
{
route ( message );
-
+
return null;
}
@@ -179,43 +192,43 @@
* @see org.jboss.soa.esb.actions.routing.AbstractRouter#route(java.lang.Object)
*/
public void route(Object message) throws ActionProcessingException {
-
+
if(!(message instanceof org.jboss.soa.esb.message.Message)) {
throw new ActionProcessingException("Cannot send Object [" + message.getClass().getName() + "] to destination [" + queueName + "]. Object must be an instance of org.jboss.soa.esb.message.Message) .");
}
-
+
final org.jboss.soa.esb.message.Message esbMessage = (org.jboss.soa.esb.message.Message)message;
-
+
try {
Message jmsMessage = null;
-
+
if ( unwrap ) {
Object objectFromBody = getPayloadProxy().getPayload(esbMessage);
jmsMessage = createJMSMessageWithObjectType( objectFromBody );
- }
+ }
else {
jmsMessage = createObjectMessage(Util.serialize(esbMessage));
}
-
+
setStringProperties(jmsMessage);
setJMSProperties( esbMessage, jmsMessage );
send( jmsMessage );
-
+
} catch(Exception e) {
StringBuilder sb = new StringBuilder();
sb.append("Exception while sending message [").append(message).append("] to destination [");
-
+
if (queueSetup != null)
sb.append(queueSetup.destinationName).append("].");
else
sb.append("null ].");
-
+
String errorMessage = sb.toString();
logger.error(errorMessage, e);
throw new ActionProcessingException(errorMessage, e);
}
}
-
+
protected Message createJMSMessageWithObjectType( Object objectFromBody ) throws JMSException
{
Message jmsMessage = null;
@@ -225,20 +238,20 @@
if(logger.isDebugEnabled()) {
logger.debug("Sending Text message: [" + objectFromBody + "] to destination [" + queueSetup.destinationName + "].");
}
-
+
((TextMessage)jmsMessage).setText((String)objectFromBody);
} else if(objectFromBody instanceof byte[]) {
jmsMessage = queueSetup.jmsSession.createBytesMessage();
-
+
if(logger.isDebugEnabled()) {
logger.debug("Sending byte[] message: [" + objectFromBody + "] to destination [" + queueSetup.destinationName + "].");
}
-
+
((BytesMessage)jmsMessage).writeBytes((byte[])objectFromBody);
} else {
jmsMessage = createObjectMessage(objectFromBody);
}
-
+
return jmsMessage;
}
@@ -246,23 +259,23 @@
{
queueSetup.jmsProducer.send(jmsMessage);
}
-
+
/**
* This method will set appropriate JMSProperties on the outgoing JMS Message instance.
* </p>
- * Sublclasses can either override this method to add a different behaviour, or they can
+ * Sublclasses can either override this method to add a different behaviour, or they can
* set the strategy by calling {@link #setJmsPropertiesStrategy(JMSPropertiesSetter)}.
- * </p>
+ * </p>
* See {@link org.jboss.soa.esb.notification.jms.JMSPropertiesSetter} for more info.
*/
- protected void setJMSProperties(org.jboss.soa.esb.message.Message fromESBMessage, Message toJMSMessage ) throws JMSException {
+ protected void setJMSProperties(org.jboss.soa.esb.message.Message fromESBMessage, Message toJMSMessage ) throws JMSException {
jmsPropertiesStrategy.setJMSProperties( fromESBMessage, toJMSMessage );
}
protected Message createObjectMessage(Object message) throws JMSException {
Message jmsMessage;
jmsMessage = queueSetup.jmsSession.createObjectMessage();
-
+
if(logger.isDebugEnabled()) {
logger.debug("Sending Object message: [" + message + "] to destination [" + queueSetup.destinationName + "].");
}
@@ -275,13 +288,13 @@
for(KeyValuePair property : properties.attributesAsList()) {
String key = property.getKey();
-
+
if(key.startsWith(messagePropPrefix) && key.length() > messagePropPrefix.length()) {
msg.setStringProperty(key.substring(messagePropPrefix.length()), property.getValue());
}
}
}
-
+
/* (non-Javadoc)
* @see org.jboss.soa.esb.actions.ActionProcessor#getOkNotification(java.lang.Object)
*/
@@ -301,11 +314,20 @@
queueSetup.close();
super.finalize();
}
-
+
protected void createQueueSetup( String queueName ) throws ConfigurationException
+ {
+ createQueueSetup( queueName, null, null, null, null );
+ }
+
+ protected void createQueueSetup( String queueName,
+ String jndiContextFactory,
+ String jndiUrl,
+ String jndiPkgPrefix,
+ String connectionFactory) throws ConfigurationException
{
try {
- queueSetup = new JMSSendQueueSetup(queueName);
+ queueSetup = new JMSSendQueueSetup(queueName, jndiContextFactory, jndiUrl, jndiPkgPrefix, connectionFactory);
queueSetup.setDeliveryMode( deliveryMode );
queueSetup.setPriority( priority );
queueSetup.setTimeToLive( timeToLive );
@@ -319,7 +341,7 @@
throw new ConfigurationException("Failed to configure JMS Queue for routing.", t);
}
}
-
+
private static class JMSSendQueueSetup {
Session jmsSession;
Destination jmsDestination;
@@ -327,19 +349,36 @@
String destinationName;
JmsConnectionPool pool;
Properties environment;
-
+
// TODO: Modify to support topic destinations too
+ private JMSSendQueueSetup(String destinationName) throws NamingException, JMSException, ConnectionException {
+ this( destinationName, null, null, null, null);
+ }
- private JMSSendQueueSetup(String destinationName) throws NamingException, JMSException, ConnectionException {
+ private JMSSendQueueSetup(String destinationName,
+ String jndiContextFactory,
+ String jndiUrl,
+ String jndiPkgPrefix,
+ String connectionFactoryName) throws NamingException, JMSException, ConnectionException {
+
+ if ( jndiContextFactory == null )
+ jndiContextFactory = Configuration.getJndiServerContextFactory();
+ if ( jndiUrl == null )
+ jndiUrl = Configuration.getJndiServerURL();
+ if ( jndiPkgPrefix == null )
+ jndiPkgPrefix = Configuration.getJndiServerPkgPrefix();
+ if ( connectionFactoryName == null )
+ connectionFactoryName = "ConnectionFactory";
+
environment = new Properties();
- environment.setProperty(Context.PROVIDER_URL, Configuration.getJndiServerURL());
- environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, Configuration.getJndiServerContextFactory());
- environment.setProperty(Context.URL_PKG_PREFIXES, Configuration.getJndiServerPkgPrefix());
+ environment.setProperty(Context.INITIAL_CONTEXT_FACTORY, jndiContextFactory);
+ environment.setProperty(Context.PROVIDER_URL, jndiUrl);
+ environment.setProperty(Context.URL_PKG_PREFIXES, jndiPkgPrefix);
Context oCtx = NamingContext.getServerContext(environment);
- pool = JmsConnectionPoolContainer.getPool(environment, "ConnectionFactory", JMSEpr.QUEUE_TYPE);
-
+ pool = JmsConnectionPoolContainer.getPool(environment, connectionFactoryName, JMSEpr.QUEUE_TYPE);
+
this.destinationName = destinationName;
-
+
jmsSession = pool.getQueueSession();
boolean clean = true ;
try {
@@ -361,31 +400,31 @@
pool.closeSession(jmsSession) ;
}
}
-
+
}
-
+
public void setDeliveryMode(final int deliveryMode ) throws JMSException
{
if ( jmsProducer != null )
jmsProducer.setDeliveryMode( deliveryMode );
}
-
+
public void setPriority(final int priority ) throws JMSException
{
if ( jmsProducer != null )
jmsProducer.setPriority( priority );
}
-
+
public void setTimeToLive(final long ttl ) throws JMSException
{
if ( jmsProducer != null )
jmsProducer.setTimeToLive( ttl );
}
-
+
private void close() {
try {
if (jmsProducer!=null) {
- jmsProducer.close();
+ jmsProducer.close();
}
} catch (Exception e) {
logger.error("Unable to close JMS Queue Setup.", e);
@@ -400,11 +439,11 @@
EPR replyToEpr = esbMessage.getHeader().getCall().getReplyTo();
if( !( replyToEpr instanceof JMSEpr) )
return;
-
+
JMSEpr jmsEpr = (JMSEpr) replyToEpr;
String destinationType = jmsEpr.getDestinationType();
Destination jmsDestination = null;
-
+
if ( destinationType.equals( JMSEpr.QUEUE_TYPE ))
{
jmsDestination = queueSetup.jmsSession.createQueue( jmsEpr.getDestinationName() );
@@ -416,10 +455,10 @@
jmsDestination = pool.getTopicSession().createTopic( jmsEpr.getDestinationName() );
*/
}
-
+
if ( jmsDestination != null )
jmsMessage.setJMSReplyTo( jmsDestination );
-
+
}
/**
@@ -430,20 +469,20 @@
{
return deliveryMode == DeliveryMode.PERSISTENT ;
}
-
+
/**
* The priority used when sending messages.
- *
+ *
* @return int the priorty
*/
public int getPriority()
{
return priority;
}
-
+
/**
* The time-to-live used when sending messages.
- *
+ *
* @return int the time-to-live for messages
*/
public long getTimeToLive()
@@ -451,4 +490,24 @@
return timeToLive;
}
+ public String getContextFactoryName()
+ {
+ return jndiContextFactory;
+ }
+
+ public String getJndiURL()
+ {
+ return jndiUrl;
+ }
+
+ public String getJndiPkgPrefix()
+ {
+ return jndiPkgPrefix;
+ }
+
+ public String getConnectionFactory()
+ {
+ return connectionFactory;
+ }
+
}
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java 2008-02-12 19:20:27 UTC (rev 18466)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/actions/routing/JmsRouterIntegrationTest.java 2008-02-12 19:49:32 UTC (rev 18467)
@@ -60,51 +60,51 @@
import org.mockejb.jms.TextMessageImpl;
/**
- *
+ *
* @author John Doe
- * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>
+ * @author <a href="daniel.bevenius at redpill.se">Daniel Bevenius</a>
*
*/
-public class JmsRouterIntegrationTest
+public class JmsRouterIntegrationTest
{
@SuppressWarnings ( "unused")
private Logger log = Logger.getLogger( JmsRouterIntegrationTest.class );
-
+
private final String messageID = "1234-junittest";
private final String bodyContent = "hello";
private Message msg;
private ConfigTree tree;
-
+
@Before
public void setup() throws URISyntaxException
{
msg = createESBMessageObject( messageID, bodyContent );
tree = createConfigTree();
}
-
+
@Test
public void process_unwrap_false() throws ConfigurationException, NamingException, JMSException, ActionProcessingException, URISyntaxException
{
MockJMSRouter router = new MockJMSRouter(tree);
router.route( msg );
-
+
assertProcessContract( messageID, msg, router );
}
-
+
@Test
public void process_unwrap_true() throws ConfigurationException, NamingException, JMSException, ActionProcessingException, URISyntaxException
{
tree.setAttribute( "unwrap", "true" );
MockJMSRouter router = new MockJMSRouter( tree );
-
+
router.route( msg );
-
+
assertProcessContract( messageID, msg, router );
final javax.jms.Message jmsMessage = ((MockJMSRouter) router).getJmsMessage();
-
+
assertTrue ( jmsMessage instanceof TextMessage );
final javax.jms.TextMessage textMessage = (TextMessage) jmsMessage;
-
+
assertEquals ( textMessage.getJMSCorrelationID(), messageID );
assertEquals ( textMessage.getText(), bodyContent );
}
@@ -116,47 +116,47 @@
JMSRouter router = new MockJMSRouter(tree);
router.route( "test" );
}
-
+
@Test
public void setJMSReplyTo_queue() throws JMSException, URISyntaxException, ConfigurationException, NamingException, ConnectionException
{
final String queueName = "testQueue";
-
+
TextMessageImpl jmsMessage = new TextMessageImpl();
-
+
JMSEpr jmsEpr = new JMSEpr( JMSEpr.QUEUE_TYPE, queueName , "ConnectionFactory" );
msg.getHeader().getCall().setReplyTo( jmsEpr );
JMSRouter router = new JMSRouter( createConfigTree() );
router.setJMSReplyTo( jmsMessage, msg );
-
+
Destination replyTo = jmsMessage.getJMSReplyTo();
assertTrue( replyTo instanceof Queue );
Queue replyToQueue = (Queue) replyTo;
assertEquals( queueName , replyToQueue.getQueueName() );
-
+
}
-
+
@Test
@Ignore
public void setJMSReplyTo_topic() throws JMSException, URISyntaxException, ConfigurationException, NamingException, ConnectionException
{
final String queueName = "testTopic";
-
+
TextMessageImpl jmsMessage = new TextMessageImpl();
-
+
JMSEpr jmsEpr = new JMSEpr( JMSEpr.TOPIC_TYPE, queueName , "ConnectionFactory" );
msg.getHeader().getCall().setReplyTo( jmsEpr );
JMSRouter router = new JMSRouter( createConfigTree() );
router.setJMSReplyTo( jmsMessage, msg );
-
+
Destination replyTo = jmsMessage.getJMSReplyTo();
assertTrue( replyTo instanceof Topic );
Topic replyToTopic = (Topic) replyTo;
assertEquals( queueName , replyToTopic.getTopicName() );
}
-
+
/*
- * Not quite sure that this is supposed to be testing.
+ * Not quite sure that this is supposed to be testing.
* Can we remove this test? /Daniel
*/
@Test
@@ -164,9 +164,9 @@
public void testRouter () throws Exception
{
boolean exception = false;
-
+
Message msg = MessageFactory.getInstance().getMessage();
-
+
msg.getBody().add("hello world".getBytes());
JMSRouter router = new JMSRouter( createConfigTree() );
try
@@ -177,12 +177,12 @@
{
exception = true;
}
-
+
if (!exception)
fail();
-
+
router.unwrap = true;
-
+
try
{
msg.getBody().add("hello world");
@@ -195,11 +195,11 @@
if (!exception)
fail();
-
+
router.getErrorNotification(null);
router.getOkNotification(null);
}
-
+
@Test
public void construct_with_default_persitent_attribute() throws ConfigurationException, NamingException, JMSException
{
@@ -207,17 +207,17 @@
JMSRouter router = new JMSRouter( config );
assertTrue( router.isDeliveryModePersistent() );
}
-
+
@Test
public void construct_with_persitent_attribute() throws ConfigurationException, NamingException, JMSException
{
ConfigTree config = createConfigTree();
config.setAttribute( JMSRouter.PERSISTENT_ATTR, "false" );
JMSRouter router = new JMSRouter( config );
-
+
assertFalse ( router.isDeliveryModePersistent() );
}
-
+
@Test
public void construct_with_default_priority_attribute() throws ConfigurationException, NamingException, JMSException
{
@@ -225,7 +225,7 @@
JMSRouter router = new JMSRouter( config );
assertEquals( javax.jms.Message.DEFAULT_PRIORITY, router.getPriority() );
}
-
+
@Test
public void construct_with_priority_attribute() throws ConfigurationException, NamingException, JMSException
{
@@ -233,10 +233,10 @@
ConfigTree config = createConfigTree();
config.setAttribute( JMSRouter.PRIORITY_ATTR, String.valueOf( expectedPriority ) );
JMSRouter router = new JMSRouter( config );
-
+
assertEquals ( expectedPriority, router.getPriority() );
}
-
+
@Test
public void construct_with_default_time_to_live_attribute() throws ConfigurationException, NamingException, JMSException
{
@@ -244,7 +244,7 @@
JMSRouter router = new JMSRouter( config );
assertEquals( javax.jms.Message.DEFAULT_TIME_TO_LIVE, router.getTimeToLive() );
}
-
+
@Test
public void construct_with_time_to_live_attribute() throws ConfigurationException, NamingException, JMSException
{
@@ -252,10 +252,32 @@
ConfigTree config = createConfigTree();
config.setAttribute( JMSRouter.TIME_TO_LIVE_ATTR, String.valueOf( ttl ) );
JMSRouter router = new JMSRouter( config );
-
+
assertEquals ( ttl, router.getTimeToLive() );
}
-
+
+ @Test
+ public void specifyJNDIPropertiesInConfig() throws JMSException, URISyntaxException, ConfigurationException, NamingException, ConnectionException
+ {
+ final String jndiContextFactoryName = "org.jnp.interfaces.NamingContextFactory";
+ final String jndiURL = "localhost:1099";
+ final String jndiPkgPrefix = "org.jboss.naming";
+ final String connectionFactory = "ConnectionFactory";
+
+ ConfigTree config = createConfigTree();
+ config.setAttribute( JMSEpr.JNDI_CONTEXT_FACTORY_TAG, jndiContextFactoryName );
+ config.setAttribute( JMSEpr.JNDI_URL_TAG, jndiURL );
+ config.setAttribute( JMSEpr.JNDI_PKG_PREFIX_TAG, jndiPkgPrefix );
+ config.setAttribute( JMSEpr.CONNECTION_FACTORY_TAG, connectionFactory );
+
+ JMSRouter router = new JMSRouter( config );
+ assertEquals( jndiContextFactoryName, router.getContextFactoryName() );
+ assertEquals( jndiURL, router.getJndiURL() );
+ assertEquals( jndiPkgPrefix, router.getJndiPkgPrefix() );
+ assertEquals( connectionFactory, router.getConnectionFactory() );
+
+ }
+
private void assertProcessContract( final String messageID, final Message msg, JMSRouter router ) throws ActionProcessingException, JMSException
{
final Message message = router.process ( msg );
@@ -263,12 +285,12 @@
final javax.jms.Message jmsMessage = ((MockJMSRouter) router).getJmsMessage();
assertEquals ( jmsMessage.getJMSCorrelationID(), messageID );
}
-
+
private static class MockJMSRouter extends JMSRouter
{
@SuppressWarnings ( "unused" )
private Logger log = Logger.getLogger( MockJMSRouter.class );
-
+
private javax.jms.Message jmsMessage;
public MockJMSRouter(ConfigTree propertiesTree) throws ConfigurationException, NamingException, JMSException
@@ -289,7 +311,7 @@
{
return jmsMessage;
}
-
+
@Override
protected javax.jms.Message createJMSMessageWithObjectType( Object objectFromBody ) throws JMSException
{
@@ -306,7 +328,7 @@
return impl;
}
}
-
+
private Message createESBMessageObject( final String messageID, final String body) throws URISyntaxException
{
Message msg = MessageFactory.getInstance().getMessage();
@@ -314,20 +336,20 @@
msg.getBody().add(body.getBytes());
return msg;
}
-
+
private static ConfigTree createConfigTree()
{
ConfigTree tree = new ConfigTree("test");
tree.setAttribute("jndiName", "/queue/A");
return tree;
}
-
+
/*
* Just here to help Ant to find annotated test.
*/
public static junit.framework.Test suite()
{
return new JUnit4TestAdapter( JmsRouterIntegrationTest.class );
- }
-
+ }
+
}
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/build.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/build.xml 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,21 @@
+<project name="Quickstart_JMS_Router" default="run" basedir=".">
+
+ <description>
+ ${ant.project.name}
+ ${line.separator}
+ </description>
+
+ <!-- Import the base Ant build script... -->
+ <import file="../conf/base-build.xml"/>
+
+ <target name="runtest" depends="compile"
+ description="sends a JMS message to queue/quickstart_jms_router_Request_gw">
+ <echo>Runs Test JMS Sender</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.jmsrouter.test.SendJMSMessage" failonerror="true">
+ <arg value="JMS Router Message dummy Content"/>
+ <arg value="queue/quickstart_jms_router_routeTo"/>
+ <classpath refid="exec-classpath"/>
+ </java>
+ </target>
+
+</project>
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/deployment.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/deployment.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/deployment.xml 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,5 @@
+<jbossesb-deployment>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_Request_esb</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_Request_gw</depends>
+ <depends>jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_routeTo</depends>
+</jbossesb-deployment>
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbm-queue-service.xml 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_Request_gw"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_Request_esb"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+ <mbean code="org.jboss.jms.server.destination.QueueService"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_routeTo"
+ xmbean-dd="xmdesc/Queue-xmbean.xml">
+ <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
+ <depends>jboss.messaging:service=PostOffice</depends>
+ </mbean>
+
+</server>
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbmq-queue-service.xml 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<server>
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_Request_gw">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_Request_esb">
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+
+ <mbean code="org.jboss.mq.server.jmx.Queue"
+ name="jboss.esb.quickstart.destination:service=Queue,name=quickstart_jms_router_routeTo"
+ <depends optional-attribute-name="DestinationManager">jboss.mq:service=DestinationManager</depends>
+ <depends optional-attribute-name="SecurityManager">jboss.mq:service=SecurityManager</depends>
+ </mbean>
+</server>
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jboss-esb.xml 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,59 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+
+ <providers>
+ <jms-provider name="JBossMessaging" connection-factory="ConnectionFactory"
+ jndi-URL="jnp://127.0.0.1:1099" jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
+ jndi-pkg-prefix="org.jboss.naming:org.jnp.interfaces">
+
+ <jms-bus busid="quickstartGwChannel">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/quickstart_jms_router_Request_gw"
+ />
+ </jms-bus>
+ <jms-bus busid="quickstartEsbChannel">
+ <jms-message-filter
+ dest-type="QUEUE"
+ dest-name="queue/quickstart_jms_router_Request_esb"
+ />
+ </jms-bus>
+
+ </jms-provider>
+ </providers>
+
+ <services>
+ <service
+ category="JMSSecuredESB"
+ name="SimpleListener"
+ description="JMS Secured quickstart sample">
+ <listeners>
+ <jms-listener name="JMS-Gateway"
+ busidref="quickstartGwChannel"
+ maxThreads="1"
+ is-gateway="true"
+ />
+ <jms-listener name="jmssecured"
+ busidref="quickstartEsbChannel"
+ maxThreads="1"/>
+ </listeners>
+ <actions mep="OneWay">
+
+ <action name="printMessage" class="org.jboss.soa.esb.actions.SystemPrintln">
+ <property name="message" value="JMS Secured Quickstart message"/>
+ <property name="printfull" value="false"/>
+ </action>
+ <action name="routeToReplyQueue" class="org.jboss.soa.esb.actions.routing.JMSRouter">
+ <property name="jndi-context-factory" value="org.jnp.interfaces.NamingContextFactory"/>
+ <property name="jndi-URL" value="127.0.0.1:1099"/>
+ <property name="jndi-pkg-prefix" value="org.jboss.naming:org.jnp.interfaces"/>
+ <property name="connection-factory" value="ConnectionFactory"/>
+ <property name="jndiName" value="queue/quickstart_jms_router_routeTo"/>
+ <property name="unwrap" value="true"/>
+ </action>
+
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbossesb-properties.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jbossesb-properties.xml 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,85 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ JBoss, Home of Professional Open Source
+ Copyright 2006, JBoss Inc., and others contributors as indicated
+ by the @authors tag. All rights reserved.
+ See the copyright.txt in the distribution for a
+ full listing of individual contributors.
+ This copyrighted material is made available to anyone wishing to use,
+ modify, copy, or redistribute it subject to the terms and conditions
+ of the GNU Lesser General Public License, v. 2.1.
+ This program is distributed in the hope that it will be useful, but WITHOUT A
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ You should have received a copy of the GNU Lesser General Public License,
+ v.2.1 along with this distribution; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ MA 02110-1301, USA.
+
+ (C) 2005-2006,
+ @author JBoss Inc.
+-->
+<!-- $Id: jbossesb-unittest-properties.xml $ -->
+<!--
+ These options are described in the JBossESB manual.
+ Defaults are provided here for convenience only.
+
+ Please read through this file prior to using the system, and consider
+ updating the specified entries.
+-->
+<esb
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:noNamespaceSchemaLocation="jbossesb-1_0.xsd">
+ <properties name="core">
+ <property name="org.jboss.soa.esb.jndi.server.type" value="jboss"/>
+ <property name="org.jboss.soa.esb.jndi.server.url" value="localhost"/>
+ <property name="org.jboss.soa.esb.persistence.connection.factory" value="org.jboss.internal.soa.esb.persistence.format.MessageStoreFactoryImpl"/>
+ </properties>
+ <properties name="registry">
+ <property name="org.jboss.soa.esb.registry.queryManagerURI"
+ value="jnp://localhost:1099/InquiryService?org.apache.juddi.registry.rmi.Inquiry#inquire"/>
+ <property name="org.jboss.soa.esb.registry.lifeCycleManagerURI"
+ value="jnp://localhost:1099/PublishService?org.apache.juddi.registry.rmi.Publish#publish" />
+ <property name="org.jboss.soa.esb.registry.implementationClass"
+ value="org.jboss.internal.soa.esb.services.registry.JAXRRegistryImpl"/>
+ <property name="org.jboss.soa.esb.registry.factoryClass"
+ value="org.apache.ws.scout.registry.ConnectionFactoryImpl"/>
+ <property name="org.jboss.soa.esb.registry.user"
+ value="jbossesb"/>
+ <property name="org.jboss.soa.esb.registry.password"
+ value="password"/>
+ <!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
+ <property name="org.jboss.soa.esb.scout.proxy.transportClass"
+ value="org.apache.ws.scout.transport.RMITransport"/>
+ </properties>
+ <properties name="transports" depends="core">
+ <property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>
+ <property name="org.jboss.soa.esb.mail.smtp.user" value="jbossesb"/>
+ <property name="org.jboss.soa.esb.mail.smtp.password" value=""/>
+ <property name="org.jboss.soa.esb.mail.smtp.port" value="25"/>
+ </properties>
+ <properties name="connection">
+ <property name="min-pool-size" value="5"/>
+ <property name="max-pool=size" value="10"/>
+ <property name="blocking-timeout-millis" value="5000"/>
+ <property name="abandoned-connection-timeout" value="10000"/>
+ <property name="abandoned-connection-time-interval" value="30000"/>
+ </properties>
+ <properties name="dbstore">
+ <property name="org.jboss.soa.esb.persistence.db.connection.url" value="jdbc:hsqldb:hsql://localhost:9001/"/>
+ <property name="org.jboss.soa.esb.persistence.db.jdbc.driver" value="org.hsqldb.jdbcDriver"/>
+ <property name="org.jboss.soa.esb.persistence.db.user" value="sa"/>
+ <property name="org.jboss.soa.esb.persistence.db.pwd" value=""/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.initial.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.min.size" value="2"/>
+ <property name="org.jboss.soa.esb.persistence.db.pool.max.size" value="5"/>
+ <!--table managed by pool to test for valid connections - created by pool automatically -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.test.table" value="pooltest"/>
+ <!-- # of milliseconds to timeout waiting for a connection from pool -->
+ <property name="org.jboss.soa.esb.persistence.db.pool.timeout.millis" value="5000"/>
+ <property name="org.jboss.soa.esb.persistence.db.conn.manager" value="org.jboss.internal.soa.esb.persistence.manager.StandaloneConnectionManager"/>
+ </properties>
+ <properties name="messagerouting">
+ <property name="org.jboss.soa.esb.routing.cbrClass" value="org.jboss.internal.soa.esb.services.routing.cbr.JBossRulesRouter"/>
+ </properties>
+</esb>
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jndi.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jndi.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/jndi.properties 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,5 @@
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+java.naming.factory.url.pkgs=org.jnp.interfaces
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/juddi.properties
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/juddi.properties (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/juddi.properties 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,69 @@
+# jUDDI Registry Properties (used by RegistryServer)
+# see http://www.juddi.org for more information
+
+# The UDDI Operator Name
+juddi.operatorName = jUDDI.org
+
+# The i18n locale default codes
+juddi.i18n.languageCode = en
+juddi.i18n.countryCode = US
+
+# The UDDI DiscoveryURL Prefix
+juddi.discoveryURL = http://localhost:8080/juddi/uddiget.jsp?
+
+# The UDDI Operator Contact Email Address
+juddi.operatorEmailAddress = admin at juddi.org
+
+# The maximum name size and maximum number
+# of name elements allows in several of the
+# FindXxxx and SaveXxxx UDDI functions.
+juddi.maxNameLength=255
+juddi.maxNameElementsAllowed=5
+
+# The maximum number of UDDI artifacts allowed
+# per publisher. A value of '-1' indicates any
+# number of artifacts is valid (These values can be
+# overridden at the individual publisher level).
+juddi.maxBusinessesPerPublisher=25
+juddi.maxServicesPerBusiness=20
+juddi.maxBindingsPerService=10
+juddi.maxTModelsPerPublisher=100
+
+# jUDDI Authentication module to use
+juddi.auth = org.apache.juddi.auth.DefaultAuthenticator
+
+# jUDDI DataStore module currently to use
+juddi.dataStore = org.apache.juddi.datastore.jdbc.JDBCDataStore
+
+# use a dataSource (if set to false a direct
+# jdbc connection will be used.
+juddi.isUseDataSource=false
+juddi.jdbcDriver=com.mysql.jdbc.Driver
+juddi.jdbcUrl=jdbc:mysql://localhost:3306/juddi
+juddi.jdbcUsername=root
+juddi.jdbcPassword=admin
+# jUDDI DataSource to use
+# juddi.dataSource=java:comp/env/jdbc/MySqlDS
+
+# jUDDI UUIDGen implementation to use
+juddi.uuidgen = org.apache.juddi.uuidgen.DefaultUUIDGen
+
+# jUDDI Cryptor implementation to use
+juddi.cryptor = org.apache.juddi.cryptor.DefaultCryptor
+
+# jUDDI Validator to use
+juddi.validator=org.apache.juddi.validator.DefaultValidator
+
+# jUDDI Proxy Properties (used by RegistryProxy)
+juddi.proxy.adminURL = http://localhost:8080/juddi/admin
+juddi.proxy.inquiryURL = http://localhost:8080/juddi/inquiry
+juddi.proxy.publishURL = http://localhost:8080/juddi/publish
+juddi.proxy.transportClass = org.apache.juddi.proxy.AxisTransport
+juddi.proxy.securityProvider = com.sun.net.ssl.internal.ssl.Provider
+juddi.proxy.protocolHandler = com.sun.net.ssl.internal.www.protocol
+
+# JNDI settings (used by RMITransport)
+java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
+java.naming.provider.url=jnp://localhost:1099
+java.naming.factory.url.pkgs=org.jboss.naming
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/log4j.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/log4j.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/log4j.xml 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<!-- ===================================================================== -->
+<!-- -->
+<!-- Log4j Configuration -->
+<!-- -->
+<!-- ===================================================================== -->
+
+<!-- $Id: log4j.xml,v 1.26.2.5 2005/09/15 09:31:02 dimitris Exp $ -->
+
+<!--
+ | 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">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="Target" value="System.out"/>
+ <param name="Threshold" value="INFO"/>
+
+ <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>
+
+ <!-- ================================= -->
+ <!-- Preserve messages in a local file -->
+ <!-- ================================= -->
+
+ <!-- A size based file rolling appender -->
+ <appender name="FILE" class="org.jboss.logging.appender.RollingFileAppender">
+ <errorHandler class="org.jboss.logging.util.OnlyOnceErrorHandler"/>
+ <param name="File" value="./listener.log"/>
+ <param name="Append" value="false"/>
+ <param name="MaxFileSize" value="500KB"/>
+ <param name="MaxBackupIndex" value="1"/>
+
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%d %-5p [%t][%c] %m%n"/>
+ </layout>
+ </appender>
+
+ <!-- ================ -->
+ <!-- Limit categories -->
+ <!-- ================ -->
+
+ <category name="org.jboss">
+ <priority value="WARN"/>
+ </category>
+ <category name="org.jboss.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.jboss.internal.soa.esb">
+ <priority value="ERROR"/>
+ </category>
+ <category name="org.apache">
+ <priority value="ERROR"/>
+ </category>
+ <category name="quickstart">
+ <priority value="DEBUG"/>
+ </category>
+ <!-- ======================= -->
+ <!-- Setup the Root category -->
+ <!-- ======================= -->
+
+ <root>
+ <appender-ref ref="CONSOLE"/>
+ <appender-ref ref="FILE"/>
+ </root>
+
+</log4j:configuration>
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/readme.txt
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/readme.txt (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/readme.txt 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,40 @@
+Overview:
+=========
+ The purpose of the jms_router quickstart is to show how the JMSRouter
+ action can be configured.
+ This quickstart also shows how a JMSCorrelationID can be used with the ESB.
+
+Running this quickstart:
+========================
+ Please refer to 'ant help-quickstarts' for prerequisites about the quickstarts
+ and a more detailed descripton of the different ways to run the quickstarts.
+
+To Run standalone mode:
+=======================
+ 1. In a command terminal window in the quickstart folder type
+ 'ant deploy-jms-dests'.
+ 2. In a command terminal window in this folder ("Window1"), type 'ant run'.
+ 3. Open another command terminal window in this folder ("Window2"), type
+ 'ant runtest'.
+ 4. Switch back to "Window1" to see the output from the ESB
+ 5. When finished, interrupt the ESB using Ctrl-C and, in this folder
+ ("Window1"), type 'ant undeploy-jms-dests'.
+
+To Run '.esb' archive mode:
+===========================
+ 1. In a command terminal window in this folder ("Window1"), type 'ant deploy'.
+ 2. Open another command terminal window in this folder ("Window2"), type
+ 'ant runtest'.
+ 3. Switch back to Application Server console to see the output from the ESB
+ 4. In this folder ("Window1"), type 'ant undeploy'.
+
+What to look at in this Quickstart:
+===================================
+ 1. src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage
+ Notice how the JMS Message is set with a correlationID.
+ Notice how the receive from the response destination uses the
+ correlation id.
+ 2. jboss-esb.xml
+ Take a look at how the JMSRouter can be configured.
+
+
Added: labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java 2008-02-12 19:49:32 UTC (rev 18467)
@@ -0,0 +1,117 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2006,
+ * @author JBoss Inc.
+ */
+package org.jboss.soa.esb.samples.quickstart.jmsrouter.test;
+
+import java.util.Properties;
+import javax.jms.JMSException;
+import javax.jms.ObjectMessage;
+import javax.jms.Message;
+import javax.jms.ObjectMessage;
+import javax.jms.TextMessage;
+import javax.jms.Destination;
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageProducer;
+import javax.jms.MessageConsumer;
+import javax.jms.QueueSession;
+import javax.jms.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+
+/**
+ *
+ * @author <a href="mailto:daniel.bevenius at gmail.com">Daniel Bevenius</a>
+ *
+ */
+public class SendJMSMessage
+{
+ private Connection connection;
+ private Session session;
+ private Destination gatewayDestination;
+ private Destination responseDestination;
+ private String correlationId;
+
+ public void setupConnection(String destination) throws JMSException, NamingException
+ {
+ InitialContext iniCtx = new InitialContext();
+
+ ConnectionFactory connectionFactory = (ConnectionFactory) iniCtx.lookup("ConnectionFactory");
+
+ connection = connectionFactory.createConnection();
+
+ gatewayDestination = (Destination) iniCtx.lookup("queue/quickstart_jms_router_Request_gw");
+ responseDestination = (Destination)iniCtx.lookup(destination);
+ session = connection.createSession(false, QueueSession.AUTO_ACKNOWLEDGE);
+ connection.start();
+ System.out.println("Connection Started");
+ }
+
+ public void stop() throws JMSException
+ {
+ session.close();
+ connection.stop();
+ connection.close();
+ }
+
+ public void sendAMessage(String msg) throws JMSException {
+ correlationId = "QuickstartId[" + java.util.Calendar.getInstance().get( java.util.Calendar.SECOND ) + "]";
+ MessageProducer producer = session.createProducer(gatewayDestination);
+ ObjectMessage objectMsg = session.createObjectMessage(msg);
+ objectMsg.setJMSCorrelationID( correlationId );
+
+ producer.send(objectMsg);
+ System.out.println("Sent message with CorrelationID : " + correlationId );
+ System.out.println("");
+ producer.close();
+ }
+
+ public void receiveAMessage() throws JMSException {
+
+ MessageConsumer consumer = session.createConsumer(responseDestination, "JMSCorrelationID = '" + correlationId + "'");
+ Message jmsMsg = consumer.receive();
+ System.out.println("Received from " + responseDestination + ":");
+ System.out.println("\t[JMSMessageID : " + jmsMsg.getJMSMessageID() + "]" );
+ System.out.println("\t[JMSCorrelelationID : " + jmsMsg.getJMSCorrelationID() + "]" );
+ if ( jmsMsg instanceof ObjectMessage )
+ {
+ System.out.println("\t[MessageType : ObjectMessage]");
+ System.out.println( "\t[Object : " + ((ObjectMessage)jmsMsg).getObject() + "]" );
+ }
+ else if ( jmsMsg instanceof TextMessage )
+ {
+ System.out.println("\t[MessageType : TextMessage]");
+ System.out.println( "\t[Text : " + ((TextMessage)jmsMsg).getText() + "]" );
+ }
+
+ consumer.close();
+ }
+
+
+ public static void main(String args[]) throws Exception
+ {
+ SendJMSMessage sm = new SendJMSMessage();
+ sm.setupConnection(args[1]);
+ sm.sendAMessage(args[0]);
+ sm.receiveAMessage();
+ sm.stop();
+ }
+
+}
More information about the jboss-svn-commits
mailing list