[jboss-cvs] JBoss Messaging SVN: r3010 - in trunk: src/main/org/jboss/jms/server/endpoint and 3 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Aug 14 10:51:55 EDT 2007


Author: timfox
Date: 2007-08-14 10:51:55 -0400 (Tue, 14 Aug 2007)
New Revision: 3010

Modified:
   trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java
   trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
   trunk/tests/build.xml
   trunk/tests/src/org/jboss/test/messaging/jms/MessageProducerTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java
   trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java
Log:
http://jira.jboss.com/jira/browse/JBMESSAGING-1042


Modified: trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java
===================================================================
--- trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java	2007-08-14 10:28:48 UTC (rev 3009)
+++ trunk/src/main/org/jboss/jms/client/container/ProducerAspect.java	2007-08-14 14:51:55 UTC (rev 3010)
@@ -159,8 +159,6 @@
                                                     "these destinations must be equal");
          }
       }
-
-      m.setJMSDestination(destination);
       
       SessionState sessionState = (SessionState)producerState.getParent();
                   
@@ -176,7 +174,7 @@
       if (!(m instanceof MessageProxy))
       {
          // it's a foreign message
-
+      	
          foreign = true;
          
          // JMS 1.1 Sect. 3.11.4: A provider must be prepared to accept, from a client,
@@ -209,11 +207,16 @@
          }
          
          messageToSend.setJMSMessageID(null);
+         
+         //We must set the destination *after* converting from foreign message
+         messageToSend.setJMSDestination(destination);              
       }
       else
       {
          // get the actual message
          MessageProxy proxy = (MessageProxy)m;
+         
+         m.setJMSDestination(destination);
                                     
          //The following line executed on the proxy should cause a copy to occur
          //if it is necessary
@@ -224,7 +227,7 @@
          
          proxy.beforeSend();
       }
-      
+          
       // Set the new id
       
       messageToSend.setMessageId(id);

Modified: trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java
===================================================================
--- trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-08-14 10:28:48 UTC (rev 3009)
+++ trunk/src/main/org/jboss/jms/server/endpoint/ServerConnectionEndpoint.java	2007-08-14 14:51:55 UTC (rev 3010)
@@ -645,7 +645,7 @@
    
    void sendMessage(JBossMessage msg, Transaction tx, boolean checkForDuplicates) throws Exception
    {
-      if (trace) { log.trace(this + " sending " + msg + (tx == null ? " non-transactionally" : " in " + tx)); }
+      if (trace) { log.trace(this + " sending message " + msg + (tx == null ? " non-transactionally" : " in " + tx)); }
 
       JBossDestination dest = (JBossDestination)msg.getJMSDestination();
       

Modified: trunk/tests/build.xml
===================================================================
--- trunk/tests/build.xml	2007-08-14 10:28:48 UTC (rev 3009)
+++ trunk/tests/build.xml	2007-08-14 14:51:55 UTC (rev 3010)
@@ -458,6 +458,7 @@
 
             <fileset dir="${build.tests.classes}">
 
+               <include name="**/jms/*Test.class"/>
                <include name="**/jms/message/**/*Test.class"/>
                <include name="**/jms/selector/*Test.class"/>
                <include name="**/jms/crash/*Test.class"/>

Modified: trunk/tests/src/org/jboss/test/messaging/jms/MessageProducerTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/MessageProducerTest.java	2007-08-14 10:28:48 UTC (rev 3009)
+++ trunk/tests/src/org/jboss/test/messaging/jms/MessageProducerTest.java	2007-08-14 14:51:55 UTC (rev 3010)
@@ -21,6 +21,8 @@
   */
 package org.jboss.test.messaging.jms;
 
+import java.io.Serializable;
+
 import javax.jms.Connection;
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
@@ -30,6 +32,7 @@
 import javax.jms.Session;
 import javax.jms.TextMessage;
 
+import org.jboss.test.messaging.jms.message.SimpleJMSMessage;
 import org.jboss.test.messaging.jms.message.SimpleJMSTextMessage;
 
 /**
@@ -56,6 +59,45 @@
 
    // Public --------------------------------------------------------
 
+   public void testSendForeignWithForeignDestinationSet() throws Exception
+   {   	   	
+      Connection conn = null;      
+ 
+      try
+      {
+      	conn = cf.createConnection();
+
+         Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+         
+         MessageProducer p = sess.createProducer(queue1);
+         
+         MessageConsumer c = sess.createConsumer(queue1);
+
+         conn.start();
+        
+         Message foreign = new SimpleJMSMessage(new SimpleDestination());
+         
+         foreign.setJMSDestination(new SimpleDestination());
+         
+         //the producer destination should override the foreign destination and the send should succeed
+         
+         p.send(foreign);
+
+         Message m = c.receive(1000);
+         
+         assertNotNull(m);
+         
+      }
+      finally
+      {
+         conn.close();
+      }
+   }
+   
+   private static class SimpleDestination implements Destination, Serializable
+   {
+   }
+   
    /**
     * The simplest possible non-transacted test.
     */
@@ -716,5 +758,7 @@
    // Private -------------------------------------------------------
    
    // Inner classes -------------------------------------------------
+   
+   
 
 }

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java	2007-08-14 10:28:48 UTC (rev 3009)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/MessageHeaderTest.java	2007-08-14 14:51:55 UTC (rev 3010)
@@ -837,13 +837,15 @@
    
    public void testForeignJMSReplyTo() throws JMSException
    {
-      JBossMessage jbossMessage = ((MessageProxy) queueProducerSession.createTextMessage()).getMessage();
+   	Message msg = queueProducerSession.createTextMessage();
+   	
+      JBossMessage jbossMessage = ((MessageProxy) msg).getMessage();
       
       Destination foreignDestination = new ForeignDestination();
       
       jbossMessage.setJMSReplyTo(foreignDestination);
       
-      queueProducer.send(jbossMessage);
+      queueProducer.send(msg);
       
       Message receivedMessage = queueConsumer.receive(2000);
 

Modified: trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java
===================================================================
--- trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java	2007-08-14 10:28:48 UTC (rev 3009)
+++ trunk/tests/src/org/jboss/test/messaging/jms/message/SimpleJMSMessage.java	2007-08-14 14:51:55 UTC (rev 3010)
@@ -25,6 +25,7 @@
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.Map;
+import org.jboss.logging.Logger;
 
 import javax.jms.DeliveryMode;
 import javax.jms.Destination;
@@ -42,17 +43,32 @@
 public class SimpleJMSMessage implements Message
 {
    // Constants -----------------------------------------------------
-
+	
+   private static final Logger log = Logger.getLogger(SimpleJMSMessage.class);
+   
    // Static --------------------------------------------------------
    
    // Attributes ----------------------------------------------------
    
+   private boolean ignoreSetDestination;
+   
    // Constructors --------------------------------------------------
    
    public SimpleJMSMessage()
    {
       properties.put("JMSXDeliveryCount", new Integer(0));
    }
+   
+   /*
+    * This constructor is used to simulate an activemq message in which the set of the destination is ignored after receipt.
+    */
+   public SimpleJMSMessage(Destination dest)
+   {
+   	this();
+   	this.ignoreSetDestination = true;
+   	this.destination = dest;
+   }
+      
 
    // Message implementation ----------------------------------------
 
@@ -150,7 +166,11 @@
 
    public void setJMSDestination(Destination destination) throws JMSException
    {
-      this.destination = destination;
+   	if (!this.ignoreSetDestination)
+   	{
+   		log.info("*********** setting destination to: " + destination);
+   		this.destination = destination;
+   	}
    }
 
 




More information about the jboss-cvs-commits mailing list