activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r1420985 - in /activemq/activemq-apollo/trunk/apollo-openwire/src: main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
Date Wed, 12 Dec 2012 21:34:08 GMT
Author: chirino
Date: Wed Dec 12 21:34:07 2012
New Revision: 1420985

URL: http://svn.apache.org/viewvc?rev=1420985&view=rev
Log:
Support the JMS noLocal option.

Modified:
    activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
    activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala?rev=1420985&r1=1420984&r2=1420985&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/OpenwireProtocolHandler.scala
Wed Dec 12 21:34:07 2012
@@ -948,8 +948,14 @@ class OpenwireProtocolHandler extends Pr
     def is_persistent = false
     override def receive_buffer_size = buffer_size
 
-    def matches(delivery:Delivery) = {
+    def matches(delivery:Delivery):Boolean = {
       if( delivery.message.codec eq OpenwireMessageCodec ) {
+        val message = delivery.message.asInstanceOf[OpenwireMessage].message
+        if( info.isNoLocal ) {
+          if( message.getProducerId.getParentId.getConnectionId == connection_context.info.getConnectionId.getValue
) {
+            return false;
+          }
+        }
         if( selector_expression!=null ) {
           selector_expression.matches(delivery.message)
         } else {

Modified: activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala?rev=1420985&r1=1420984&r2=1420985&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
(original)
+++ activemq/activemq-apollo/trunk/apollo-openwire/src/test/scala/org/apache/activemq/apollo/openwire/test/OpenwireParallelTest.scala
Wed Dec 12 21:34:07 2012
@@ -733,4 +733,22 @@ class OpenwireParallelTest extends Openw
     }
  }
 
+  test("NoLocal Test") {
+    connect()
+    val destination = topic(next_id("NOLOCAL"))
+    val localSession = default_connection.createSession(false, Session.AUTO_ACKNOWLEDGE)
+    var localConsumer = localSession.createConsumer(destination, null, true)
+    var localProducer = localSession.createProducer(destination)
+
+    val remoteConnection = connect("")
+    val remoteSession = remoteConnection.createSession(false, Session.AUTO_ACKNOWLEDGE)
+    var remoteProducer = remoteSession.createProducer(destination)
+
+    remoteProducer.send(localSession.createTextMessage("1"))
+    localProducer.send(localSession.createTextMessage("2"))
+    remoteProducer.send(localSession.createTextMessage("3"))
+
+    receive_text(localConsumer) should equal("1")
+    receive_text(localConsumer) should equal("3")
+ }
 }
\ No newline at end of file



Mime
View raw message