Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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 header.
*/
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
4 changes: 4 additions & 0 deletions docs/user-manual/filter-expressions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ AMQSize::
The size of a message in bytes.
The value is an integer.

AMQFullSize::
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

The whole size of a message in bytes.
The value is a long integer.

Any other identifiers used in core filter expressions will be assumed to be properties of the message.

== Property Identifier Constraints
Expand Down