-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Add preserveDeliveryMode to deadLetterStrategy #1354
base: main
Are you sure you want to change the base?
Conversation
@@ -60,6 +71,16 @@ public interface DeadLetterStrategy { | |||
*/ | |||
public void setProcessNonPersistent(boolean processNonPersistent); | |||
|
|||
/** | |||
* @return the PreserveDeliveryMode |
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.
The comment needs to be updated.
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.
@return the PreserveDeliveryMode
This is a new method which does return PreserveDeliveryMode
. What exactly would you like to update?
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.
Ah, I guess just the name is a bit confusing to me. Because it starts with "is" and return a boolean, if it returns the PreserveDeliveryMode it should be "get" imo.
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.
Yeah, I noticed the "is" style is used for boolean methods in a number of places so I chose to be consistent.
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.
yeah, is for boolean is the convention
@pa-deasy I assume the code that actually calls "setPreserveDeliveryMode" which is read from destination configuration will come later? |
I sort of see the points of moving the code to Hence I vote -1 on "move dead letter queue message preparation logic to the AbstractDeadLetterStrategy class" part of this PR. The getter and setter of perserveDeliveryMode on the |
I'm not in favor of refactoring RegionBroker in a point release. Ultimately, the DeadLetterStrategy should re-use the MessageInterceptorStrategy interface to it so admins can configure or change anything about the message on the way to the DLQ. All these one-off config params and methods creates bloat and all this logic should be pushed off into a handler. |
Thanks folks for your feedback on "move dead letter queue message preparation logic to the AbstractDeadLetterStrategy class". Those are great points. I will update my PR appropriately and add tests. Thank you. |
36ba737
to
7e810c4
Compare
7e810c4
to
05facc8
Compare
05facc8
to
92ac5e2
Compare
/** | ||
* @param PreserveDeliveryMode the PreserveDeliveryMode to set | ||
*/ | ||
public void setPreserveDeliveryMode(boolean PreserveDeliveryMode); |
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.
preserveDeliveryMode
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.
Good spot, not sure how I made this mistake.
@@ -60,6 +71,16 @@ public interface DeadLetterStrategy { | |||
*/ | |||
public void setProcessNonPersistent(boolean processNonPersistent); | |||
|
|||
/** | |||
* @return the PreserveDeliveryMode |
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.
yeah, is for boolean is the convention
AMQ-7397 Move Message preparation back to RegionBroker. AMQ-7397 Add message persistence tests for dead letter strategy.
92ac5e2
to
4d1160e
Compare
message.setProperty(ActiveMQMessage.DLQ_DELIVERY_FAILURE_CAUSE_PROPERTY, | ||
poisonCause.toString()); | ||
} | ||
message = prepareMessageForDeadLetterQueue(message, deadLetterStrategy, poisonCause); |
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.
I don't think we need/should create a new method here. This method is only used one time so I don't see the benefit of refactoring this unless you are planning to call prepareMessageForDeadLetterQueue()
in more than one spot or make it protected/package scope to override it or be accessible in tests so I would just leave things inline.
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.
I thought refactoring out made the prepareMessageForDeadLetterQueue
method made the sendToDeadLetterQueue
method easier to read and understand.
If folks don't agree I can revert the change?
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.
Well, while the method is in fact descriptive about what it is doing, it actually makes it harder to understand what you changed because by copying it all to a new method it's not clear what exactly the difference is from the old code. You have to look at it carefully as the entire method shows up as a new change which is the biggest reason why I made the comment because i as staring at it for a while to even figure out what was different.
That being said it's not the biggest deal obviously, the compiler may end up inlining the method anyways.
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.
Makes sense, I've removed the prepareMessageForDeadLetterQueue
method.
@@ -91,6 +129,14 @@ public void setProcessNonPersistent(boolean processNonPersistent) { | |||
this.processNonPersistent = processNonPersistent; | |||
} | |||
|
|||
@Override | |||
public boolean isPreserveDeliveryMode() { return this.preserveDeliveryMode; } |
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.
It should have the same format as other getter for consistency. So return at new new line
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.
Strange, my IDE(ItelliJ) made the other getters in AbstractDeadLetterStrategy
appear to be single line.
I'll update this.
@mattrpav - Do you have any issues with the changes here? It seems ok to me, it preserves the previous behavior by default and I could see a use case for this. |
What problems does this PR solve?
By default non persistent messages are set to persistent when being sent to a dead letter queue. This improvement adds
preserveDeliveryMode
to deadLetterStrategy which allows the original non-persistent delivery mode to be preserved.Why is it beneficial to merge into ActiveMQ?
Users are able to take advantage of using non persistent messages on a dead letter queue.
How do you make sure this PR is well tested?
I ran the following tests locally on a build of this branch.
Test A
deadLetterStrategy
to process non persistent messages.Persistence
set toPersistent
.Test B
deadLetterStrategy
from Test A.Persistence
set toPersistent
andoriginalDeliveryMode
set toNON_PERSISTENT
.Test C
deadLetterStrategy
to preserve the delivery mode.Persistence
set toNon Persistent
.