-
Notifications
You must be signed in to change notification settings - Fork 912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ARTEMIS-4649 Use unique STOMP message ID per subscription #4825
Conversation
The tests you added don't actually fail without the fix. This
However, the test succeeds. The tests should fail without the fix. |
Fixed tests to fail without the fix and removed accidentally included logging in unrelated tests. |
Can you squash your commits? |
@@ -344,7 +348,8 @@ public StompFrame createMessageFrame(ICoreMessage serverMessage, StompSubscripti | |||
} | |||
frame.setByteBody(data); | |||
|
|||
StompUtils.copyStandardHeadersFromMessageToFrame((serverMessage), frame, deliveryCount); | |||
frame.addHeader(Stomp.Headers.Message.MESSAGE_ID, String.valueOf(consumer.getID()) + StompSession.MESSAGE_ID_SEPARATOR + String.valueOf(serverMessage.getMessageID())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is going to be done for every message dispatched from the broker so it would be worth making this is as fast as possible. Perhaps something like:
frame.addHeader(Stomp.Headers.Message.MESSAGE_ID, new StringBuilder(32).append(consumer.getID()).append(StompSession.MESSAGE_ID_SEPARATOR).append(serverMessage.getMessageID()).toString());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, but I set initial StringBuilder capacity to 41 to fit two long values and separator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How did you arrive at the 41
value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minimum long value is 20 characters (-9223372036854775808), so two long values and separator could require 41 characters total.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Message and consumer IDs should never be < 0 so the potential values are 0 (1 character) through 9223372036854775807 (19 characters). Since these characters are just digits (i.e. part of ISO-8859-1) then they will be represented by a single byte in the byte[]
that backs the String
. We want to avoid expanding the backing array but we also want to avoid over-allocating (and therefore wasting) space. Ten characters for each long seems like a fair middle ground.
Use combined consumer and message ID as STOMP message ID.
51d7cc9
to
6163466
Compare
@thezbyg, thanks for the contribution! |
Use combined consumer and message ID as STOMP message ID.