rxm
rxm

Reputation: 53

Restrict the size of message in ActiveMQ Artemis

I want to restrict the size of message to 800 KB for users trying to publish mqtt message in the artemis topic and for that I have updated address-settings in theetc/broker.xml with

<max-size-bytes>800</max-size-bytes>
<page-size-bytes>800</page-size-bytes>

This seems not working and I am able to publish 1 MB message through MQTT client.

Upvotes: 0

Views: 808

Answers (1)

Justin Bertram
Justin Bertram

Reputation: 34998

The max-size-bytes setting applies to an address, not a message. Also, this setting without notation is interpreted as bytes (although other byte notations can be used, e.g. MB, kb, etc.). Therefore, setting <max-size-bytes>800</max-size-bytes> will tell the broker to enforce the corresponding address-full-policy (which is PAGE by default) when the total number of bytes in the matching address is 800. As the documentation states, max-size-bytes is:

...the max memory the address could have before entering on page mode.

Several different policies/modes are supported here. Aside from PAGE the broker supports FAIL, DROP, and BLOCK. See the documentation for more details on these.

If you want to exclude messages based strictly on their size I recommend you implement an MQTT interceptor. Ensure you're using at least 2.12.0 so that you have the fix for this issue.

Upvotes: 1

Related Questions