polishing
This commit removes the queue attribute of the JmsListener annotation as this information should be provided by the container factory and not by each individual listener endpoints. There was a side effect that an annotation value cannot be null, which was forcing the container to be a queue-based container by default. Issue: SPR-9882
This commit is contained in:
@@ -96,12 +96,6 @@ public @interface JmsListener {
|
||||
*/
|
||||
String destination();
|
||||
|
||||
/**
|
||||
* Specify if the {@link #destination()} refers to a queue or not. Refer to a
|
||||
* queue by default.
|
||||
*/
|
||||
boolean queue() default true;
|
||||
|
||||
/**
|
||||
* The name for the durable subscription, if any.
|
||||
*/
|
||||
|
||||
@@ -175,7 +175,6 @@ public class JmsListenerAnnotationBeanPostProcessor implements BeanPostProcessor
|
||||
endpoint.setJmsHandlerMethodFactory(jmsHandlerMethodFactory);
|
||||
endpoint.setId(getEndpointId(jmsListener));
|
||||
endpoint.setDestination(jmsListener.destination());
|
||||
endpoint.setQueue(jmsListener.queue());
|
||||
if (StringUtils.hasText(jmsListener.selector())) {
|
||||
endpoint.setSelector(jmsListener.selector());
|
||||
}
|
||||
|
||||
@@ -38,8 +38,6 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
|
||||
|
||||
private String destination;
|
||||
|
||||
private boolean queue = true;
|
||||
|
||||
private String subscription;
|
||||
|
||||
private String selector;
|
||||
@@ -68,20 +66,6 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
|
||||
this.destination = destination;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return {@code true} if the destination is a queue.
|
||||
*/
|
||||
public boolean isQueue() {
|
||||
return queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify if the destination is a queue.
|
||||
*/
|
||||
public void setQueue(boolean queue) {
|
||||
this.queue = queue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name for the durable subscription, if any.
|
||||
*/
|
||||
@@ -136,7 +120,6 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
|
||||
if (getSelector() != null) {
|
||||
container.setMessageSelector(getSelector());
|
||||
}
|
||||
container.setPubSubDomain(!isQueue());
|
||||
setupMessageListener(container);
|
||||
}
|
||||
|
||||
@@ -156,7 +139,6 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
|
||||
if (getSelector() != null) {
|
||||
activationSpecConfig.setMessageSelector(getSelector());
|
||||
}
|
||||
activationSpecConfig.setPubSubDomain(!isQueue());
|
||||
setupMessageListener(container);
|
||||
}
|
||||
|
||||
@@ -183,8 +165,6 @@ public abstract class AbstractJmsListenerEndpoint implements JmsListenerEndpoint
|
||||
.append(this.id)
|
||||
.append("] destination=")
|
||||
.append(this.destination)
|
||||
.append(" | queue='")
|
||||
.append(this.queue)
|
||||
.append("' | subscription='")
|
||||
.append(this.subscription)
|
||||
.append(" | selector='")
|
||||
|
||||
@@ -85,11 +85,11 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint {
|
||||
messageListener.setHandlerMethod(invocableHandlerMethod);
|
||||
String responseDestination = getDefaultResponseDestination();
|
||||
if (StringUtils.hasText(responseDestination)) {
|
||||
if (isQueue()) {
|
||||
messageListener.setDefaultResponseQueueName(responseDestination);
|
||||
if (container.isPubSubDomain()) {
|
||||
messageListener.setDefaultResponseTopicName(responseDestination);
|
||||
}
|
||||
else {
|
||||
messageListener.setDefaultResponseTopicName(responseDestination);
|
||||
messageListener.setDefaultResponseQueueName(responseDestination);
|
||||
}
|
||||
}
|
||||
MessageConverter messageConverter = container.getMessageConverter();
|
||||
|
||||
@@ -41,4 +41,10 @@ public interface MessageListenerContainer extends Lifecycle {
|
||||
*/
|
||||
MessageConverter getMessageConverter();
|
||||
|
||||
/**
|
||||
* Return whether the Publish/Subscribe domain ({@link javax.jms.Topic Topics}) is used.
|
||||
* Otherwise, the Point-to-Point domain ({@link javax.jms.Queue Queues}) is used.
|
||||
*/
|
||||
boolean isPubSubDomain();
|
||||
|
||||
}
|
||||
|
||||
@@ -156,6 +156,15 @@ public class JmsMessageEndpointManager extends GenericMessageEndpointManager
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPubSubDomain() {
|
||||
JmsActivationSpecConfig config = getActivationSpecConfig();
|
||||
if (config != null) {
|
||||
return config.isPubSubDomain();
|
||||
}
|
||||
throw new IllegalStateException("could not determine pubSubDomain, no activation spec config is set");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of this message endpoint. Populated with the bean name
|
||||
* automatically when defined within Spring's bean factory.
|
||||
|
||||
Reference in New Issue
Block a user