-
Notifications
You must be signed in to change notification settings - Fork 628
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
MessageListenerAdapter improve #990
Conversation
you can get channel by extends protected method repackArgument
sorry for skipping formation
This change is reasonable; I am not keen on the method name "repack...", though. How about "enhanceListenerArguments"? Also, a test case would be good, together with some documentation on how a user might subclass the adapter to use this. Finally, I am curious as to why you can't use the new-style adapter.
doesn't make sense to me. |
...t/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapter.java
Outdated
Show resolved
Hide resolved
thx for your reply and method name suggests, but I don't think MessagingMessageListenerAdapter could meet my needs. about use case ... public class YourMessageListenerAdapter extends MessageListenerAdapter {
@Override
protected Object[] repackArgument(Object[] listenerArguments, Channel channel, Message message) {
if (listenerArguments != null) {
List<Object> resList = new LinkedList<Object>(Arrays.asList(listenerArguments));
// put anything u want
resList.add(channel);
resList.add(message);
return resList.toArray();
}
return listenerArguments;
}
} I think change parameters of buildListenerArguments is not good for the older version, because the method is protected, may in use by extends |
That's not correct. See Re. This way I would suggest then to deprecate a With two methods from API you are going to confuse end-users what and how to implement/override. However we still can just break that API in the current version and change a Let's hear what @garyrussell thinks on the matter and then ,please, also share some test-case and some docs are needed for this any way. Thanks |
I have no real problems with a breaking change to that method in 2.2. We don't hear much about this old adapter these days anyway. However, why not simply add protected Object[] buildListenerArguments(Object extractedMessage, Channel channel, Message message) {
return buildListenerArguments(extractedMessage);
} ?? |
Doh! Of course! We can rely on the polymorphism! I just don't see reason in confusing API... |
OK, I have pushed test case, but I do not know where should i submit documents, or u mean comment? |
thx, good suggestion |
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.
Re. Doc:
There is an amqp.adoc
file in the project and you can find there a message-listener-adapter
section.
So, your change should be reflected there with mentioning in what version we have introduced it.
Then there is a whats-new.adoc
. You can add a simple paragraph there to mention this change with a link to the target section.
Thanks
...t/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapter.java
Show resolved
Hide resolved
doc uploaded |
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.
Thank you for update.
Please, consider my nit-picks in the review.
...t/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapter.java
Show resolved
Hide resolved
...t/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapter.java
Outdated
Show resolved
Hide resolved
.../test/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapterTests.java
Outdated
Show resolved
Hide resolved
.../test/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapterTests.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapter.java
Outdated
Show resolved
Hide resolved
...t/src/main/java/org/springframework/amqp/rabbit/listener/adapter/MessageListenerAdapter.java
Outdated
Show resolved
Hide resolved
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.
Your name to all the affected classes, please.
@artembilan OK, I'm trying to make the doc simple and supply sample code |
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.
LGTM.
Merging with minor code style and wording polishing.
about closed #972
I must use ->
so I try to extend MessageListenerAdapter, but that is not so convenient, i must copy all code from method onMessage, if this pull request pass, i could finish former biz by override repackArgument with code ->