Skip to content
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 #29902

Closed
sbrannen opened this issue Jan 30, 2023 · 1 comment
Closed

Improve generated default name for @JmsListener subscription #29902

sbrannen opened this issue Jan 30, 2023 · 1 comment
Assignees
Labels
in: messaging Issues in messaging modules (jms, messaging) type: backport An issue that is a backport of another issue to a maintenance branch type: enhancement A general enhancement
Milestone

Comments

@sbrannen
Copy link
Member

sbrannen commented Jan 30, 2023

@sbrannen sbrannen added in: messaging Issues in messaging modules (jms, messaging) type: enhancement A general enhancement type: backport An issue that is a backport of another issue to a maintenance branch labels Jan 30, 2023
@sbrannen sbrannen added this to the 5.3.26 milestone Jan 30, 2023
@sbrannen sbrannen self-assigned this Jan 30, 2023
@sbrannen sbrannen changed the title Improve generated default name for @JmsListener subscription Improve generated default name for @JmsListener subscription Jan 30, 2023
sbrannen pushed a commit that referenced this issue Jan 30, 2023
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 gh-29902
sbrannen added a commit to sbrannen/spring-framework that referenced this issue Jan 30, 2023
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-29902
sbrannen added a commit that referenced this issue Jan 31, 2023
@sbrannen
Copy link
Member Author

This has been merged into 5.3.x in 07fd760 and revised in 6bd7a73.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging Issues in messaging modules (jms, messaging) type: backport An issue that is a backport of another issue to a maintenance branch type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant