You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ri...@apache.org on 2006/12/06 16:55:12 UTC

svn commit: r483127 [3/3] - in /incubator/qpid/branches/jmsselectors: java/broker/ java/broker/src/main/grammar/ java/broker/src/main/java/org/apache/qpid/server/ java/broker/src/main/java/org/apache/qpid/server/filter/ java/broker/src/main/java/org/ap...

Added: incubator/qpid/branches/jmsselectors/java/client/src/test/java/org/apache/qpid/test/unit/basic/SelectorTest.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/jmsselectors/java/client/src/test/java/org/apache/qpid/test/unit/basic/SelectorTest.java?view=auto&rev=483127
==============================================================================
--- incubator/qpid/branches/jmsselectors/java/client/src/test/java/org/apache/qpid/test/unit/basic/SelectorTest.java (added)
+++ incubator/qpid/branches/jmsselectors/java/client/src/test/java/org/apache/qpid/test/unit/basic/SelectorTest.java Wed Dec  6 07:55:10 2006
@@ -0,0 +1,140 @@
+/*
+ *
+ * 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.
+ *
+ */
+package org.apache.qpid.test.unit.basic;
+
+import org.apache.qpid.client.AMQConnection;
+import org.apache.qpid.client.AMQDestination;
+import org.apache.qpid.client.AMQQueue;
+import org.apache.qpid.client.AMQSession;
+import org.apache.qpid.client.BasicMessageProducer;
+import org.apache.qpid.client.transport.TransportConnection;
+import org.apache.qpid.test.VMBrokerSetup;
+import org.apache.log4j.Logger;
+
+import javax.jms.JMSException;
+import javax.jms.Message;
+import javax.jms.MessageListener;
+import javax.jms.DeliveryMode;
+
+import junit.framework.TestCase;
+
+public class SelectorTest extends TestCase implements MessageListener
+{
+
+    private final static Logger _logger = org.apache.log4j.Logger.getLogger(SelectorTest.class);
+
+    private AMQConnection _connection;
+    private AMQDestination _destination;
+    private AMQSession _session;
+    private int count;
+    public String _connectionString = "vm://:1";
+
+    protected void setUp() throws Exception
+    {
+        super.setUp();
+        TransportConnection.createVMBroker(1);
+        init(new AMQConnection(_connectionString, "guest", "guest", randomize("Client"), "/test_path"));
+    }
+
+    protected void tearDown() throws Exception
+    {
+        super.tearDown();
+    }
+
+    private void init(AMQConnection connection) throws Exception
+    {
+        init(connection, new AMQQueue(randomize("SessionStartTest"), true));
+    }
+
+    private void init(AMQConnection connection, AMQDestination destination) throws Exception
+    {
+        _connection = connection;
+        _destination = destination;
+        connection.start();
+
+
+        String selector= null;
+//        selector = "Cost = 2 AND JMSDeliveryMode=" + DeliveryMode.NON_PERSISTENT;
+//        selector = "JMSType = Special AND Cost = 2 AND AMQMessageID > 0 AND JMSDeliveryMode=" + DeliveryMode.NON_PERSISTENT;
+
+        _session = (AMQSession) connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
+        //_session.createConsumer(destination).setMessageListener(this);
+        _session.createConsumer(destination, selector).setMessageListener(this);
+    }
+
+    public synchronized void test() throws JMSException, InterruptedException
+    {
+        try
+        {
+            Message msg = _session.createTextMessage("Message");
+            msg.setJMSPriority(1);
+            msg.setIntProperty("Cost", 2);
+            msg.setJMSType("Special");
+
+            _logger.info("Sending Message:" + msg);
+
+            ((BasicMessageProducer) _session.createProducer(_destination)).send(msg, DeliveryMode.NON_PERSISTENT);
+            System.out.println("Message sent, waiting for response...");
+            wait(1000);
+
+            if (count > 0)
+            {
+                _logger.info("Got message");
+            }
+
+            if (count == 0)
+            {
+                fail("Did not get message!");
+                //throw new RuntimeException("Did not get message!");
+            }
+        }
+        finally
+        {
+            _session.close();
+            _connection.close();
+        }
+    }
+
+    public synchronized void onMessage(Message message)
+    {
+        count++;
+        _logger.info("Got Message:" + message);
+        notify();
+    }
+
+    private static String randomize(String in)
+    {
+        return in + System.currentTimeMillis();
+    }
+
+    public static void main(String[] argv) throws Exception
+    {
+        SelectorTest test = new SelectorTest();
+        test._connectionString = argv.length == 0 ? "localhost:5672" : argv[0];
+        test.setUp();
+        test.test();
+    }
+
+    public static junit.framework.Test suite()
+    {
+        return new VMBrokerSetup(new junit.framework.TestSuite(SelectorTest.class));
+    }
+}

Propchange: incubator/qpid/branches/jmsselectors/java/client/src/test/java/org/apache/qpid/test/unit/basic/SelectorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/qpid/branches/jmsselectors/java/client/src/test/java/org/apache/qpid/test/unit/basic/SelectorTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/qpid/branches/jmsselectors/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteSubscriptionImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/jmsselectors/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteSubscriptionImpl.java?view=diff&rev=483127&r1=483126&r2=483127
==============================================================================
--- incubator/qpid/branches/jmsselectors/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteSubscriptionImpl.java (original)
+++ incubator/qpid/branches/jmsselectors/java/cluster/src/main/java/org/apache/qpid/server/queue/RemoteSubscriptionImpl.java Wed Dec  6 07:55:10 2006
@@ -88,9 +88,19 @@
 
     public void queueDeleted(AMQQueue queue)
     {
-        if(queue instanceof ClusteredQueue)
+        if (queue instanceof ClusteredQueue)
         {
             ((ClusteredQueue) queue).removeAllRemoteSubscriber(_peer);
         }
+    }
+
+    public boolean hasFilters()
+    {
+        return false;
+    }
+
+    public boolean hasInterest(AMQMessage msg)
+    {
+        return true;
     }
 }

Modified: incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLHelper.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLHelper.java?view=diff&rev=483127&r1=483126&r2=483127
==============================================================================
--- incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLHelper.java (original)
+++ incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLHelper.java Wed Dec  6 07:55:10 2006
@@ -64,9 +64,9 @@
                 if (valueIndex + 1 < options.length())
                 {
                     if (options.charAt(valueIndex + 1) == DEFAULT_OPTION_SEPERATOR ||
-                            options.charAt(valueIndex + 1) == ALTERNATIVE_OPTION_SEPARATOR ||
-                            options.charAt(valueIndex + 1) == BROKER_SEPARATOR ||
-                            options.charAt(valueIndex + 1) == '\'')
+                        options.charAt(valueIndex + 1) == ALTERNATIVE_OPTION_SEPARATOR ||
+                        options.charAt(valueIndex + 1) == BROKER_SEPARATOR ||
+                        options.charAt(valueIndex + 1) == '\'')
                     {
                         nestedQuotes--;
 //                        System.out.println(
@@ -119,7 +119,7 @@
             else
             {
                 parseError(sepIndex, "Unterminated option. Possible illegal option separator:'" +
-                        options.charAt(sepIndex) + "'", options);
+                                     options.charAt(sepIndex) + "'", options);
             }
         }
 

Modified: incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLSyntaxException.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLSyntaxException.java?view=diff&rev=483127&r1=483126&r2=483127
==============================================================================
--- incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLSyntaxException.java (original)
+++ incubator/qpid/branches/jmsselectors/java/common/src/main/java/org/apache/qpid/url/URLSyntaxException.java Wed Dec  6 07:55:10 2006
@@ -62,12 +62,12 @@
 
         if (getIndex() > -1)
         {
-            if (_length != -1)
+            if (_length > 1)
             {
                 sb.append(" between indicies ");
                 sb.append(getIndex());
                 sb.append(" and ");
-                sb.append(_length);
+                sb.append(getIndex() + _length);
             }
             else
             {

Propchange: incubator/qpid/branches/jmsselectors/java/distribution/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Dec  6 07:55:10 2006
@@ -0,0 +1 @@
+target

Modified: incubator/qpid/branches/jmsselectors/java/systests/src/test/java/org/apache/qpid/server/queue/TestSubscription.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/jmsselectors/java/systests/src/test/java/org/apache/qpid/server/queue/TestSubscription.java?view=diff&rev=483127&r1=483126&r2=483127
==============================================================================
--- incubator/qpid/branches/jmsselectors/java/systests/src/test/java/org/apache/qpid/server/queue/TestSubscription.java (original)
+++ incubator/qpid/branches/jmsselectors/java/systests/src/test/java/org/apache/qpid/server/queue/TestSubscription.java Wed Dec  6 07:55:10 2006
@@ -70,6 +70,16 @@
     {
     }
 
+    public boolean hasFilters()
+    {
+        return false;
+    }
+
+    public boolean hasInterest(AMQMessage msg)
+    {
+        return true;
+    }
+
     public int hashCode()
     {
         return key.hashCode();

Modified: incubator/qpid/branches/jmsselectors/specs/amqp-8.0.xml
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/jmsselectors/specs/amqp-8.0.xml?view=diff&rev=483127&r1=483126&r2=483127
==============================================================================
--- incubator/qpid/branches/jmsselectors/specs/amqp-8.0.xml (original)
+++ incubator/qpid/branches/jmsselectors/specs/amqp-8.0.xml Wed Dec  6 07:55:10 2006
@@ -2085,6 +2085,13 @@
     method it will raise a channel or connection exception.
     </doc>
   </field>
+
+    <field name="filter" type="table" label="arguments for consuming">
+        <doc>
+            A set of filters for the consume. The syntax and semantics
+            of these filters depends on the providers implementation.
+        </doc>
+    </field>
 </method>
 
 <method name = "consume-ok" synchronous = "1" index = "21">
@@ -2446,9 +2453,9 @@
     A client MUST NOT use this method as a means of selecting messages
     to process.  A rejected message MAY be discarded or dead-lettered,
     not necessarily passed to another client.
-  </doc>      
+  </doc>
   <chassis name = "server" implement = "MUST" />
-    
+
   <field name = "delivery tag" domain = "delivery tag" />
 
   <field name = "requeue" type = "bit">
@@ -2490,7 +2497,7 @@
     The server MUST set the redelivered flag on all messages that are resent.
   </doc>
   <doc name="rule">
-    The server MUST raise a channel exception if this is called on a 
+    The server MUST raise a channel exception if this is called on a
     transacted channel.
   </doc>
 </method>
@@ -2792,7 +2799,7 @@
   <response name = "open-ok" />
   <chassis name = "server" implement = "MUST" />
   <chassis name = "client" implement = "MUST" />
-  
+
   <field name = "identifier" type = "shortstr">
     staging identifier
     <doc>
@@ -2829,7 +2836,7 @@
   <response name = "stage" />
   <chassis name = "server" implement = "MUST" />
   <chassis name = "client" implement = "MUST" />
-  
+
   <field name = "staged size" type = "longlong">
     already staged amount
     <doc>
@@ -3045,7 +3052,7 @@
   </doc>
   <chassis name = "server" implement = "MUST" />
   <field name = "delivery tag" domain = "delivery tag" />
-      
+
   <field name = "multiple" type = "bit">
     acknowledge multiple messages
     <doc>
@@ -3084,7 +3091,7 @@
     not necessarily passed to another client.
   </doc>
   <chassis name = "server" implement = "MUST" />
-    
+
   <field name = "delivery tag" domain = "delivery tag" />
 
   <field name = "requeue" type = "bit">
@@ -3483,7 +3490,7 @@
     <doc>
       Specifies the routing key name specified when the message was
       published.
-    </doc>     
+    </doc>
   </field>
 </method>