[ 
https://issues.apache.org/jira/browse/ARTEMIS-4673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17868482#comment-17868482
 ] 

Timothy A. Bish commented on ARTEMIS-4673:
------------------------------------------

This is true of modifications of outgoing Core messages as well.  I'd say in 
general modifying an outgoing message content is a dangerous and not 
recommended action on the face of it given the affect it has on the in memory 
version of a message.  

> Calling removeAnnotation() in a outgoing AMQP interceptor doesn't recalculate 
> message size
> ------------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-4673
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4673
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>          Components: AMQP
>    Affects Versions: 2.31.2
>            Reporter: Tobias Månsson
>            Priority: Major
>
>  
> The follwoing code is run on outgoing messages, to remove annotations used 
> for internal routing.
> {code:java}
> public class Scrub implements InterceptorFunction {
>     protected List<String> attributes;
>     Scrub(ScrubType scrub) {
>         attributes = new ArrayList<>(scrub.getAttributes());
>     }
>     @Override
>     public boolean apply(AMQPMessage amqpMessage) {
>         if (amqpMessage.getMessageAnnotations() == null || attributes == 
> null) {
>             return;
>         }
>         attributes.forEach(attribute -> {
>             if (amqpMessage.removeAnnotation(new 
> SimpleString(Annotator.ANNOTATION_PREFIX + attribute)) != null) {
>                 amqpMessage.messageChanged();
>             }
>         });
>         return true;
>     }
> } {code}
> After this is done, and the message reencoded, delivering size grows with 
> each message on the address.
> Some analysis shows that the message size calculation is done before the 
> interceptor is done, and that message size then has the wrong value.
> I assume that the deducted value when a message is removed from the 
> delivering queue is lower than the previous calculated, leading to the 
> growing delivering size metric.
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to