Search in sources :

Example 1 with DestinationResolver

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();
}
Also used : DestinationResolver(org.springframework.jms.support.destination.DestinationResolver)

Example 2 with DestinationResolver

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;
}
Also used : ConnectionFactory(javax.jms.ConnectionFactory) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver)

Example 3 with DestinationResolver

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();
}
Also used : Destination(javax.jms.Destination) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) QueueSender(javax.jms.QueueSender) StubTextMessage(org.springframework.jms.StubTextMessage) StubTextMessage(org.springframework.jms.StubTextMessage) TextMessage(javax.jms.TextMessage) Session(javax.jms.Session)

Example 4 with DestinationResolver

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);
}
Also used : Destination(javax.jms.Destination) DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) Session(javax.jms.Session) Test(org.junit.Test)

Example 5 with DestinationResolver

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"));
}
Also used : DestinationResolver(org.springframework.jms.support.destination.DestinationResolver) MessagingMessageListenerAdapter(org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) MessageConverter(org.springframework.jms.support.converter.MessageConverter) Test(org.junit.Test)

Aggregations

DestinationResolver (org.springframework.jms.support.destination.DestinationResolver)8 Destination (javax.jms.Destination)3 Test (org.junit.Test)3 Session (javax.jms.Session)2 MessagingMessageListenerAdapter (org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter)2 MessageConverter (org.springframework.jms.support.converter.MessageConverter)2 BigInteger (java.math.BigInteger)1 Random (java.util.Random)1 ConnectionFactory (javax.jms.ConnectionFactory)1 QueueSender (javax.jms.QueueSender)1 TextMessage (javax.jms.TextMessage)1 DefaultSpringErrorHandler (org.apache.camel.component.jms.DefaultSpringErrorHandler)1 ReplyToType (org.apache.camel.component.jms.ReplyToType)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 StubQueue (org.springframework.jms.StubQueue)1 StubTextMessage (org.springframework.jms.StubTextMessage)1 DefaultMessageListenerContainer (org.springframework.jms.listener.DefaultMessageListenerContainer)1 InvocableHandlerMethod (org.springframework.messaging.handler.invocation.InvocableHandlerMethod)1