-
Notifications
You must be signed in to change notification settings - Fork 37.7k
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
Improve generated default name for @JmsListener
subscription
#29790
Conversation
Could this also be backported to the 5.x line? |
The previous commit changed the generated default name for a JMS subscription to <FQCN>#<method name> -- for example: - org.example.MyListener#myListenerMethod In order to generate unique subscription names for overloaded listener methods within a class, this commit retains the <FQCN>#<method name> format for a method that declares zero parameters but changes the format to <FQCN>#<method name>(<parameter list>) for methods that declare parameters, where the parameter list is a comma-separated list of the canonical names of the parameter types -- for example: - org.example.MyListener#myListenerMethod - org.example.MyListener#myListenerMethod(java.lang.String) - org.example.MyListener#myListenerMethod(byte[]) - org.example.MyListener#myListenerMethod(byte[],java.lang.String) See spring-projectsgh-29790
@JmsListener
subscription
As a proof of concept, I pushed changes to main...sbrannen:spring-framework:issues/gh-29790-default-jms-subscription-name that include the method signature in the generated subscription name (in order to generate unique subscription names for overloaded However, before pushing those changes I decided to verify the requirements of a subscription name in the JMS 3.0 spec. That points out that characters such as In light of that, I have decided to use a |
The previous commit changed the generated default name for a JMS subscription to <FQCN>#<method name> -- for example: - org.example.MyListener#myListenerMethod However, the JMS spec does not guarantee that '#' is a supported character. This commit therefore changes '#' to '.' as the separator between the class name and method name -- for example: - org.example.MyListener.myListenerMethod This commit also introduces tests and documentation for these changes. See gh-29790
Yes, we will backport this to |
This is perfectly OK for me. The main thing is that the name is meaningful and not fixed and is equal to the name of a rather internal Spring class. |
Prior to this commit, when using durable subscribers with @JmsListener methods that do not specify a custom subscription name the generated default subscription name was always org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter. Consequently, multiple such @JmsListener methods were assigned the same subscription name which violates the uniqueness requirement. To address this, MessagingMessageListenerAdapter now implements SubscriptionNameProvider and generates the subscription name based on the following rules. - if the InvocableHandlerMethod is present, the subscription name will take the form of handlerMethod.getBeanType().getName() + "#" + handlerMethod.getMethod().getName(). - otherwise, getClass().getName() is used, which is analogous to the previous behavior. Closes spring-projectsgh-29790
The previous commit changed the generated default name for a JMS subscription to <FQCN>#<method name> -- for example: - org.example.MyListener#myListenerMethod However, the JMS spec does not guarantee that '#' is a supported character. This commit therefore changes '#' to '.' as the separator between the class name and method name -- for example: - org.example.MyListener.myListenerMethod This commit also introduces tests and documentation for these changes. See spring-projectsgh-29790
This should fix #29763.