Author: clebert.suconic(a)jboss.com
Date: 2012-02-29 23:55:36 -0500 (Wed, 29 Feb 2012)
New Revision: 12217
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
branches/Branch_2_2_AS7/src/main/org/hornetq/utils/LinkedListImpl.java
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/ConsumerFilterTest.java
Log:
JBPAPP-8282 - Fixing remove element case
Modified:
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java
===================================================================
---
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2012-02-28
16:44:34 UTC (rev 12216)
+++
branches/Branch_2_2_AS7/src/main/org/hornetq/core/server/impl/ServerConsumerImpl.java 2012-03-01
04:55:36 UTC (rev 12217)
@@ -251,19 +251,20 @@
}
return HandleStatus.BUSY;
}
+ final ServerMessage message = ref.getMessage();
+ if (filter != null && !filter.match(message))
+ {
+ log.trace("Reference " + ref + " is a noMatch on consumer
" + this);
+ return HandleStatus.NO_MATCH;
+ }
+
if (log.isTraceEnabled())
{
log.trace("Handling reference " + ref);
}
- final ServerMessage message = ref.getMessage();
- if (filter != null && !filter.match(message))
- {
- return HandleStatus.NO_MATCH;
- }
-
if (!browseOnly)
{
if (!preAcknowledge)
Modified: branches/Branch_2_2_AS7/src/main/org/hornetq/utils/LinkedListImpl.java
===================================================================
--- branches/Branch_2_2_AS7/src/main/org/hornetq/utils/LinkedListImpl.java 2012-02-28
16:44:34 UTC (rev 12216)
+++ branches/Branch_2_2_AS7/src/main/org/hornetq/utils/LinkedListImpl.java 2012-03-01
04:55:36 UTC (rev 12217)
@@ -65,6 +65,10 @@
if (size == 0)
{
tail = node;
+ }
+ else
+ {
+ tail.prev = node;
}
size++;
Modified:
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/ConsumerFilterTest.java
===================================================================
---
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/ConsumerFilterTest.java 2012-02-28
16:44:34 UTC (rev 12216)
+++
branches/Branch_2_2_AS7/tests/src/org/hornetq/tests/integration/client/ConsumerFilterTest.java 2012-03-01
04:55:36 UTC (rev 12217)
@@ -249,4 +249,86 @@
locator.close();
}
+
+ public void testLinkedListOrder() throws Exception
+ {
+ ServerLocator locator = createInVMNonHALocator();
+
+ ClientSessionFactory sf = locator.createSessionFactory();
+
+ ClientSession session = sf.createSession();
+
+ session.start();
+
+ session.createQueue("foo", "foo", true);
+
+ ClientProducer producer = session.createProducer("foo");
+
+ ClientConsumer redConsumer = session.createConsumer("foo",
"color='red'");
+
+ ClientConsumer anyConsumer = session.createConsumer("foo");
+
+ sendMessage(session, producer, "any", "msg1");
+
+ sendMessage(session, producer, "any", "msg2");
+
+ sendMessage(session, producer, "any", "msg3");
+
+ sendMessage(session, producer, "red", "msgRed4");
+
+ sendMessage(session, producer, "red", "msgRed5");
+
+ readConsumer("anyConsumer", anyConsumer);
+
+ readConsumer("anyConsumer", anyConsumer);
+
+ log.info("### closing consumer ###");
+
+ anyConsumer.close();
+
+ readConsumer("redConsumer", redConsumer);
+
+ readConsumer("redConsumer", redConsumer);
+
+ log.info("### recreating consumer ###");
+
+ anyConsumer = session.createConsumer("foo");
+
+ session.start();
+
+ readConsumer("anyConsumer", anyConsumer);
+
+ session.close();
+
+ sf.close();
+
+ locator.close();
+ }
+
+ /**
+ * @param consumer
+ * @throws HornetQException
+ */
+ private void readConsumer(String consumerName, ClientConsumer consumer) throws
Exception
+ {
+ ClientMessage message = consumer.receive(5000);
+ assertNotNull(message);
+ System.out.println("consumer = " + consumerName + " message,
color=" + message.getStringProperty("color") + ", msg = " +
message.getStringProperty("value"));
+ message.acknowledge();
+ }
+
+ /**
+ * @param session
+ * @param producer
+ * @return
+ * @throws HornetQException
+ */
+ private void sendMessage(ClientSession session, ClientProducer producer, String color,
String msg) throws Exception
+ {
+ ClientMessage anyMessage = session.createMessage(true);
+ anyMessage.putStringProperty("color", color);
+ anyMessage.putStringProperty("value", msg);
+ producer.send(anyMessage);
+ session.commit();
+ }
}
Show replies by date