You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by cshannon <gi...@git.apache.org> on 2018/04/10 19:58:59 UTC
[GitHub] activemq-artemis pull request #2009: ARTEMIS-1800 - Fix metrics decrement on...
GitHub user cshannon opened a pull request:
https://github.com/apache/activemq-artemis/pull/2009
ARTEMIS-1800 - Fix metrics decrement on scheduled message cancel
The queue metrics were being decremented improperly because on iteration
over the cancelled scheduled messages because the flag for fromMessageReferences was not
set to false. Setting the flag to false skips over the metrics update
which is what we want as the scheduled messages were never added to the
message references in the first place so the metrics don't need updating
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/cshannon/activemq-artemis ARTEMIS-1800
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/activemq-artemis/pull/2009.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2009
----
commit 70f0908b4ee64e68059a21009db9dd3236c26732
Author: Christopher L. Shannon (cshannon) <ch...@...>
Date: 2018-04-10T19:54:29Z
ARTEMIS-1800 - Fix metrics decrement on scheduled message cancel
The queue metrics were being decremented improperly because on iteration
over the cancelled scheduled messages because the flag for fromMessageReferences was not
set to false. Setting the flag to false skips over the metrics update
which is what we want as the scheduled messages were never added to the
message references in the first place so the metrics don't need updating
----
---
[GitHub] activemq-artemis pull request #2009: ARTEMIS-1800 - Fix metrics decrement on...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/activemq-artemis/pull/2009
---
[GitHub] activemq-artemis pull request #2009: ARTEMIS-1800 - Fix metrics decrement on...
Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/2009#discussion_r180773234
--- Diff: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java ---
@@ -2510,6 +2510,39 @@ public void testSendMessage() throws Exception {
Assert.assertEquals(new String(body), "theBody");
}
+ @Test
+ public void testGetScheduledCountOnRemove() throws Exception {
+ long delay = Integer.MAX_VALUE;
+ SimpleString address = RandomUtil.randomSimpleString();
+ SimpleString queue = RandomUtil.randomSimpleString();
+
+ session.createQueue(address, RoutingType.MULTICAST, queue, null, durable);
+
+ QueueControl queueControl = createManagementControl(address, queue);
+ Assert.assertEquals(0, queueControl.getScheduledCount());
+
+ Field queueMemorySizeField = QueueImpl.class.getDeclaredField("queueMemorySize");
+ queueMemorySizeField.setAccessible(true);
+ final LocalQueueBinding binding = (LocalQueueBinding) server.getPostOffice().getBinding(queue);
+ Queue q = binding.getQueue();
+ AtomicInteger queueMemorySize1 = (AtomicInteger) queueMemorySizeField.get(q);
+ assertTrue(queueMemorySize1.get() == 0);
+
+ ClientProducer producer = session.createProducer(address);
+ ClientMessage message = session.createMessage(durable);
+ message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + delay);
+ producer.send(message);
+
+ queueControl.removeAllMessages();
+
+ Assert.assertEquals(0, queueControl.getMessageCount());
--- End diff --
in a lot of cases, I have had to change this to:
Wait.assertEquals(0, queueuControl::getMessageCount);
Are you sure this is reliable, non asynchronous?
---
[GitHub] activemq-artemis pull request #2009: ARTEMIS-1800 - Fix metrics decrement on...
Posted by clebertsuconic <gi...@git.apache.org>.
Github user clebertsuconic commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/2009#discussion_r180777030
--- Diff: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java ---
@@ -2510,6 +2510,39 @@ public void testSendMessage() throws Exception {
Assert.assertEquals(new String(body), "theBody");
}
+ @Test
+ public void testGetScheduledCountOnRemove() throws Exception {
+ long delay = Integer.MAX_VALUE;
+ SimpleString address = RandomUtil.randomSimpleString();
+ SimpleString queue = RandomUtil.randomSimpleString();
+
+ session.createQueue(address, RoutingType.MULTICAST, queue, null, durable);
+
+ QueueControl queueControl = createManagementControl(address, queue);
+ Assert.assertEquals(0, queueControl.getScheduledCount());
+
+ Field queueMemorySizeField = QueueImpl.class.getDeclaredField("queueMemorySize");
+ queueMemorySizeField.setAccessible(true);
+ final LocalQueueBinding binding = (LocalQueueBinding) server.getPostOffice().getBinding(queue);
+ Queue q = binding.getQueue();
+ AtomicInteger queueMemorySize1 = (AtomicInteger) queueMemorySizeField.get(q);
+ assertTrue(queueMemorySize1.get() == 0);
+
+ ClientProducer producer = session.createProducer(address);
+ ClientMessage message = session.createMessage(durable);
+ message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + delay);
+ producer.send(message);
+
+ queueControl.removeAllMessages();
+
+ Assert.assertEquals(0, queueControl.getMessageCount());
--- End diff --
ok.. I will just merge it
---
[GitHub] activemq-artemis pull request #2009: ARTEMIS-1800 - Fix metrics decrement on...
Posted by cshannon <gi...@git.apache.org>.
Github user cshannon commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/2009#discussion_r180774964
--- Diff: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/management/QueueControlTest.java ---
@@ -2510,6 +2510,39 @@ public void testSendMessage() throws Exception {
Assert.assertEquals(new String(body), "theBody");
}
+ @Test
+ public void testGetScheduledCountOnRemove() throws Exception {
+ long delay = Integer.MAX_VALUE;
+ SimpleString address = RandomUtil.randomSimpleString();
+ SimpleString queue = RandomUtil.randomSimpleString();
+
+ session.createQueue(address, RoutingType.MULTICAST, queue, null, durable);
+
+ QueueControl queueControl = createManagementControl(address, queue);
+ Assert.assertEquals(0, queueControl.getScheduledCount());
+
+ Field queueMemorySizeField = QueueImpl.class.getDeclaredField("queueMemorySize");
+ queueMemorySizeField.setAccessible(true);
+ final LocalQueueBinding binding = (LocalQueueBinding) server.getPostOffice().getBinding(queue);
+ Queue q = binding.getQueue();
+ AtomicInteger queueMemorySize1 = (AtomicInteger) queueMemorySizeField.get(q);
+ assertTrue(queueMemorySize1.get() == 0);
+
+ ClientProducer producer = session.createProducer(address);
+ ClientMessage message = session.createMessage(durable);
+ message.putLongProperty(Message.HDR_SCHEDULED_DELIVERY_TIME, System.currentTimeMillis() + delay);
+ producer.send(message);
+
+ queueControl.removeAllMessages();
+
+ Assert.assertEquals(0, queueControl.getMessageCount());
--- End diff --
I think the removeAllMessages() call is synchronous but if it's an issue it's easy enough to switch out the assertion in the test
---