[jboss-svn-commits] JBL Code SVN: r26697 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product: rosetta/tests/src/org/jboss/soa/esb/notification/jms and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Fri May 22 10:19:51 EDT 2009


Author: kevin.conner at jboss.com
Date: 2009-05-22 10:19:50 -0400 (Fri, 22 May 2009)
New Revision: 26697

Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/jboss-esb.xml
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/readme.txt
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java
Log:
Filter out JMS_ properties: JBESB-2586

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java	2009-05-22 13:52:14 UTC (rev 26696)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetter.java	2009-05-22 14:19:50 UTC (rev 26697)
@@ -23,11 +23,8 @@
 
 import java.net.URI;
 
-import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
-import javax.naming.Context;
-import javax.naming.NamingException;
 
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.message.Properties;
@@ -128,6 +125,10 @@
 	 * The following expression in a message selector would evaluate to false,
 	 * because a string cannot be used in an arithmetic expression:
 	 *     "NumberOfOrders > 1"
+     * <p/>
+     * Note that this method does not allow the setting of JMS Header properties, that is
+     * properites that start with 'JMSX', nor does it allow JMS Vendor specific properties, those
+     * that start with 'JMS_' to be set.
 	 * 
 	 * @param fromESBMessage	ESB Message object instance from which properties will be retrevied
 	 * @param toJMSMessage		JMS Message object instance upon which the properties will be set
@@ -142,13 +143,18 @@
 			if ( !Strings.isValidJavaIdentifier( key ))
 				continue;
 			
-                        if (key.startsWith("JMSX"))
-                        {
-                            if (!JMSX_GROUP_ID.equals(key) && !JMSX_GROUP_SEQ.equals(key))
-                            {
-                                continue ;
-                            }
-                        }
+            if (key.startsWith("JMSX"))
+            {
+                if (!JMSX_GROUP_ID.equals(key) && !JMSX_GROUP_SEQ.equals(key))
+                {
+                    continue ;
+                }
+            }
+            else if (key.startsWith("JMS_"))
+            {
+                continue ;
+            }
+            
 			Object value = properties.getProperty( key );
 			log.debug( "Setting outgoing JMSProperty, key : " + key + ", value : " + value );
 			if ( value instanceof String  ) 

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java	2009-05-22 13:52:14 UTC (rev 26696)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/rosetta/tests/src/org/jboss/soa/esb/notification/jms/DefaultJMSPropertiesSetterUnitTest.java	2009-05-22 14:19:50 UTC (rev 26697)
@@ -42,7 +42,6 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
-import org.mockejb.jms.MockQueue;
 import org.mockejb.jms.TextMessageImpl;
 import org.mockejb.jndi.MockContextFactory;
 
@@ -212,6 +211,16 @@
 		assertEquals ( expectedMessageID, toJMSMessage.getJMSCorrelationID() );
 	}
 	
+	@Test
+	public void setJMSProperties_JMSVendorProperty() throws JMSException, URISyntaxException
+    {
+        final String propertyKey = "JMS_SomeVendorName";
+        fromESBMessage.getProperties().setProperty( propertyKey, "bogus" );
+        
+        strategy.setJMSProperties( fromESBMessage, toJMSMessage );
+        assertNull(toJMSMessage.getStringProperty(propertyKey) );
+    }
+	
 	@Before
 	public void before() throws JMSException, NamingException
 	{

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/jboss-esb.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/jboss-esb.xml	2009-05-22 13:52:14 UTC (rev 26696)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/jboss-esb.xml	2009-05-22 14:19:50 UTC (rev 26697)
@@ -27,8 +27,6 @@
         	description="JMS Secured quickstart sample">
             <listeners>
                 <jms-listener name="JMS-Gateway" busidref="quickstartGwChannel" is-gateway="true" >
-					<!-- Comment out to exclude properties that are vendor specific. -->
-					<property name="excludeProperties" value="[JMS_].*"/>
 				</jms-listener>
                 <jms-listener name="jmssecured"
                               busidref="quickstartEsbChannel"/>

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/readme.txt
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/readme.txt	2009-05-22 13:52:14 UTC (rev 26696)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/readme.txt	2009-05-22 14:19:50 UTC (rev 26697)
@@ -2,8 +2,7 @@
 =========
   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, and
-  how JMS properties can be excluded at the JMS gateway by setting the 'excludeProperties'.
+  This quickstart also shows how a JMSCorrelationID can be used with the ESB.
   
 Running this quickstart:
 ========================
@@ -39,18 +38,3 @@
   2. jboss-esb.xml
 	 Take a look at how the JMSRouter can be configured.
 
-  3. 'excludeProperties' property.
-	 This propery can be used to filter out unwanted properties that exist in 
-	 the JMS message arriving at the gateway. 
-
-	 Usually there is no problem simply letting properties flow through but some 
-	 JMS Provider do not excepts JMS vendor specific properties that are not there 
-	 own and will throw an exception. This property was added to avoid this. 
-
-	 As you can see in the configuration that we specifying a regular expression to filter
-	 out all properties that start with 'JMS_' but this regular expression could be 
-	 used to filter out other properties too.
-
-	 Try uncommenting the 'excludeProperties' property in jboss-esb.xml and you will see
-	 that this property is no longer passed through and will be null in "Window2"
-  	 

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java	2009-05-22 13:52:14 UTC (rev 26696)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/samples/quickstarts/jms_router/src/org/jboss/soa/esb/samples/quickstart/jmsrouter/test/SendJMSMessage.java	2009-05-22 14:19:50 UTC (rev 26697)
@@ -50,7 +50,7 @@
     private Destination replyToDestination;
     private String correlationId;
 
-	private String vendorSpecificPropertyName = "JMS_IBMQ_Property";
+	private String propertyKey = "MyProperty";
 
     public void setupConnection(String destination) throws JMSException, NamingException
     {
@@ -81,7 +81,7 @@
         ObjectMessage objectMsg = session.createObjectMessage(msg);
         objectMsg.setJMSCorrelationID( correlationId );
 		objectMsg.setJMSReplyTo( replyToDestination );
-		objectMsg.setStringProperty(vendorSpecificPropertyName, "Vendor specific property value");
+		objectMsg.setStringProperty(propertyKey, "My property value");
 
         producer.send(objectMsg);
     	System.out.println("Sent message with CorrelationID : " + correlationId );
@@ -107,7 +107,7 @@
     		System.out.println("\t[MessageType : TextMessage]");
     		System.out.println( "\t[Text : " +  ((TextMessage)jmsMsg).getText() + "]" );
 		}
-		System.out.println("\t[Property: "+ vendorSpecificPropertyName + " : " +  jmsMsg.getStringProperty(vendorSpecificPropertyName) + "]" );
+		System.out.println("\t[Property: "+ propertyKey + " : " +  jmsMsg.getStringProperty(propertyKey) + "]" );
 
         consumer.close();
     }




More information about the jboss-svn-commits mailing list