Apply DestinationResolver to listener container
Previously, a custom `DestinationResolver` was not made available to the underlying `MessageListener`: if a reply needs to be sent, the default `DestinationResolver` was used. This commit ensures that if a custom `DestinationResolver` has been set, it is also configured accordingly for replies. Issue: SPR-12927
This commit is contained in:
@@ -27,6 +27,7 @@ import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.jms.listener.MessageListenerContainer;
|
||||
import org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.messaging.handler.annotation.support.MessageHandlerMethodFactory;
|
||||
import org.springframework.messaging.handler.invocation.InvocableHandlerMethod;
|
||||
@@ -110,6 +111,10 @@ public class MethodJmsListenerEndpoint extends AbstractJmsListenerEndpoint {
|
||||
if (messageConverter != null) {
|
||||
messageListener.setMessageConverter(messageConverter);
|
||||
}
|
||||
DestinationResolver destinationResolver = container.getDestinationResolver();
|
||||
if (destinationResolver != null) {
|
||||
messageListener.setDestinationResolver(destinationResolver);
|
||||
}
|
||||
return messageListener;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.jms.listener;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.jms.support.converter.MessageConverter;
|
||||
import org.springframework.jms.support.destination.DestinationResolver;
|
||||
|
||||
/**
|
||||
* Internal abstraction used by the framework representing a message
|
||||
@@ -41,6 +42,12 @@ public interface MessageListenerContainer extends SmartLifecycle {
|
||||
*/
|
||||
MessageConverter getMessageConverter();
|
||||
|
||||
/**
|
||||
* Return the {@link DestinationResolver} to use to resolve
|
||||
* destinations by names.
|
||||
*/
|
||||
DestinationResolver getDestinationResolver();
|
||||
|
||||
/**
|
||||
* 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.
|
||||
|
||||
@@ -191,6 +191,14 @@ public class JmsMessageEndpointManager extends GenericMessageEndpointManager
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DestinationResolver getDestinationResolver() {
|
||||
if (this.activationSpecFactory instanceof StandardJmsActivationSpecFactory) {
|
||||
return ((StandardJmsActivationSpecFactory) this.activationSpecFactory).getDestinationResolver();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPubSubDomain() {
|
||||
JmsActivationSpecConfig config = getActivationSpecConfig();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2015 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.
|
||||
@@ -90,6 +90,12 @@ public class StandardJmsActivationSpecFactory implements JmsActivationSpecFactor
|
||||
this.destinationResolver = destinationResolver;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the {@link DestinationResolver} to use for resolving destinations names.
|
||||
*/
|
||||
public DestinationResolver getDestinationResolver() {
|
||||
return destinationResolver;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActivationSpec createActivationSpec(ResourceAdapter adapter, JmsActivationSpecConfig config) {
|
||||
|
||||
Reference in New Issue
Block a user