use of org.springframework.jms.support.destination.DestinationResolver in project camel by apache.
the class JmsEndpoint method createEndpointUri.
// Implementation methods
//-------------------------------------------------------------------------
@Override
protected String createEndpointUri() {
String scheme = "jms";
if (destination != null) {
return scheme + ":" + destination;
} else if (destinationName != null) {
return scheme + ":" + destinationName;
}
DestinationResolver resolver = getDestinationResolver();
if (resolver != null) {
return scheme + ":" + resolver;
}
return super.createEndpointUri();
}
use of org.springframework.jms.support.destination.DestinationResolver in project camel by apache.
the class JmsComponent method getConfiguration.
// Properties
// -------------------------------------------------------------------------
public JmsConfiguration getConfiguration() {
if (configuration == null) {
configuration = createConfiguration();
// If we are being configured with spring...
if (applicationContext != null) {
if (isAllowAutoWiredConnectionFactory()) {
Map<String, ConnectionFactory> beansOfTypeConnectionFactory = applicationContext.getBeansOfType(ConnectionFactory.class);
if (!beansOfTypeConnectionFactory.isEmpty()) {
ConnectionFactory cf = beansOfTypeConnectionFactory.values().iterator().next();
configuration.setConnectionFactory(cf);
}
}
if (isAllowAutoWiredDestinationResolver()) {
Map<String, DestinationResolver> beansOfTypeDestinationResolver = applicationContext.getBeansOfType(DestinationResolver.class);
if (!beansOfTypeDestinationResolver.isEmpty()) {
DestinationResolver destinationResolver = beansOfTypeDestinationResolver.values().iterator().next();
configuration.setDestinationResolver(destinationResolver);
}
}
}
}
return configuration;
}
use of org.springframework.jms.support.destination.DestinationResolver in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method processAndReplyWithSendTo.
private void processAndReplyWithSendTo(MessagingMessageListenerAdapter listener, String replyDestinationName, boolean pubSubDomain) throws JMSException {
String body = "echo text";
String correlationId = "link-1234";
Destination replyDestination = new Destination() {
};
DestinationResolver destinationResolver = mock(DestinationResolver.class);
TextMessage reply = mock(TextMessage.class);
QueueSender queueSender = mock(QueueSender.class);
Session session = mock(Session.class);
given(destinationResolver.resolveDestinationName(session, replyDestinationName, pubSubDomain)).willReturn(replyDestination);
given(session.createTextMessage(body)).willReturn(reply);
given(session.createProducer(replyDestination)).willReturn(queueSender);
listener.setDestinationResolver(destinationResolver);
StubTextMessage inputMessage = createSimpleJmsTextMessage(body);
inputMessage.setJMSCorrelationID(correlationId);
listener.onMessage(inputMessage, session);
verify(destinationResolver).resolveDestinationName(session, replyDestinationName, pubSubDomain);
verify(reply).setJMSCorrelationID(correlationId);
verify(queueSender).send(reply);
verify(queueSender).close();
}
use of org.springframework.jms.support.destination.DestinationResolver in project spring-framework by spring-projects.
the class JmsResponseTests method resolveDestinationForQueue.
@Test
public void resolveDestinationForQueue() throws JMSException {
Session session = mock(Session.class);
DestinationResolver destinationResolver = mock(DestinationResolver.class);
Destination destination = mock(Destination.class);
given(destinationResolver.resolveDestinationName(session, "myQueue", false)).willReturn(destination);
JmsResponse<String> jmsResponse = JmsResponse.forQueue("foo", "myQueue");
Destination actual = jmsResponse.resolveDestination(destinationResolver, session);
assertSame(destination, actual);
}
use of org.springframework.jms.support.destination.DestinationResolver in project spring-framework by spring-projects.
the class MethodJmsListenerEndpointTests method setExtraCollaborators.
@Test
public void setExtraCollaborators() {
MessageConverter messageConverter = mock(MessageConverter.class);
DestinationResolver destinationResolver = mock(DestinationResolver.class);
this.container.setMessageConverter(messageConverter);
this.container.setDestinationResolver(destinationResolver);
MessagingMessageListenerAdapter listener = createInstance(this.factory, getListenerMethod("resolveObjectPayload", MyBean.class), container);
DirectFieldAccessor accessor = new DirectFieldAccessor(listener);
assertSame(messageConverter, accessor.getPropertyValue("messageConverter"));
assertSame(destinationResolver, accessor.getPropertyValue("destinationResolver"));
}
Aggregations