Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ public final class FilterConstants {
*/
public static final SimpleString ACTIVEMQ_SIZE = SimpleString.of("AMQSize");

/**
* Name of the Apache Artemis Message full size filter property.
*/
public static final SimpleString ACTIVEMQ_FULL_SIZE = SimpleString.of("AMQFullSize");

/**
* Name of the Apache Artemis Address header
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
* <li>{@code AMQDurable} - "DURABLE" or "NON_DURABLE"
* <li>{@code AMQExpiration} - the expiration of the message
* <li>{@code AMQSize} - the encoded size of the full message in bytes
* <li>{@code AMQFullSize} - the whole size of the full message in bytes
* <li>{@code AMQUserID} - the user specified ID string (if any)
* <li>Any other identifiers that appear in a filter expression represent header values for the message
* </ul>
Expand Down Expand Up @@ -177,6 +178,8 @@ private static Object getHeaderFieldValue(final Message msg, final SimpleString
return msg.getExpiration();
} else if (FilterConstants.ACTIVEMQ_SIZE.equals(fieldName)) {
return msg.getEncodeSize();
} else if (FilterConstants.ACTIVEMQ_FULL_SIZE.equals(fieldName)) {
return msg.getWholeMessageSize();
} else if (FilterConstants.ACTIVEMQ_ADDRESS.equals(fieldName)) {
return msg.getAddress();
} else if (FilterConstants.ACTIVEMQ_GROUP_ID.equals(fieldName)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,25 @@ public void testStringLikePunctuation() throws Exception {
assertTrue(filter.match(message));
}

@Test
public void testAMQFullSize() throws Exception {
message.setAddress(RandomUtil.randomUUIDSimpleString());

long wholeSize = message.getWholeMessageSize();

Filter moreThanSmall = FilterImpl.createFilter(SimpleString.of("AMQFullSize > " + (wholeSize - 1)));
Filter lessThanLarge = FilterImpl.createFilter(SimpleString.of("AMQFullSize < " + (wholeSize + 1)));

Filter lessThanSmall = FilterImpl.createFilter(SimpleString.of("AMQFullSize < " + wholeSize));
Filter moreThanLarge = FilterImpl.createFilter(SimpleString.of("AMQFullSize > " + wholeSize));

assertTrue(moreThanSmall.match(message));
assertTrue(lessThanLarge.match(message));

assertFalse(lessThanSmall.match(message));
assertFalse(moreThanLarge.match(message));
}

// TODO: re-implement this.
//
// @Test
Expand Down
7 changes: 5 additions & 2 deletions docs/user-manual/filter-expressions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ The timestamp of when the message was created.
The value is a long integer.

AMQSize::
The size of a message in bytes.
Broker calculated size of a message in bytes. For large messages, the body size may not be fully included.
The value is an integer.

Any other identifiers used in core filter expressions will be assumed to be properties of the message.
AMQFullSize::
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having both AMQSize and AMQFullSize is likely going to be confusing to some users without a further elaboration in the docs about what makes them distinct and why you would use one over the other when using them to filter messages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @tabish121.

@AlexejTimonin, if you don't make the doc changes I'll do it myself in a few days.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's a good point. I will get to it tomorrow.

Total size of the encoded message in bytes as it would be transmitted over the wire, including headers, properties, and the full body.
Can be used in filters to select messages based on their size.
The value is a long integer.

== Property Identifier Constraints

Expand Down