Skip to content

Commit

Permalink
Expose endpoint id as listener container name (for transaction/thread…
Browse files Browse the repository at this point in the history
… name)

Closes gh-26683
  • Loading branch information
jhoeller committed Mar 15, 2021
1 parent a8d5532 commit 7d3f42b
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@
import org.springframework.jms.listener.endpoint.JmsActivationSpecConfig;
import org.springframework.jms.listener.endpoint.JmsMessageEndpointManager;
import org.springframework.lang.Nullable;
import org.springframework.util.StringUtils;

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


/**
* Set a custom id for this endpoint.
*/
public void setId(String id) {
this.id = id;
}

/**
* Return the id of this endpoint (possibly generated).
*/
@Override
public String getId() {
return this.id;
Expand Down Expand Up @@ -136,6 +143,9 @@ public void setupListenerContainer(MessageListenerContainer listenerContainer) {
}

private void setupJmsListenerContainer(AbstractMessageListenerContainer listenerContainer) {
if (StringUtils.hasText(getId())) {
listenerContainer.setBeanName(getId());
}
if (getDestination() != null) {
listenerContainer.setDestinationName(getDestination());
}
Expand Down

0 comments on commit 7d3f42b

Please sign in to comment.