Skip to content

Commit 7d3f42b

Browse files
committed
Expose endpoint id as listener container name (for transaction/thread name)
Closes gh-26683
1 parent a8d5532 commit 7d3f42b

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

spring-jms/src/main/java/org/springframework/jms/config/AbstractJmsListenerEndpoint.java

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@
2323
import org.springframework.jms.listener.endpoint.JmsActivationSpecConfig;
2424
import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager;
2525
import org.springframework.lang.Nullable;
26+
import org.springframework.util.StringUtils;
2627

2728
/**
2829
* Base model for a JMS listener endpoint.
@@ -50,10 +51,16 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
5051
private String concurrency;
5152

5253

54+
/**
55+
* Set a custom id for this endpoint.
56+
*/
5357
public void setId(String id) {
5458
this.id = id;
5559
}
5660

61+
/**
62+
* Return the id of this endpoint (possibly generated).
63+
*/
5764
@Override
5865
public String getId() {
5966
return this.id;
@@ -136,6 +143,9 @@ public void setupListenerContainer(MessageListenerContainer listenerContainer) {
136143
}
137144

138145
private void setupJmsListenerContainer(AbstractMessageListenerContainer listenerContainer) {
146+
if (StringUtils.hasText(getId())) {
147+
listenerContainer.setBeanName(getId());
148+
}
139149
if (getDestination() != null) {
140150
listenerContainer.setDestinationName(getDestination());
141151
}

0 commit comments

Comments
 (0)