org.springframework.jms.support.destination.DestinationResolver Java Examples
The following examples show how to use
org.springframework.jms.support.destination.DestinationResolver.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
private void processAndReplyWithSendTo(MessagingMessageListenerAdapter listener, 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, "replyDestination", 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, "replyDestination", pubSubDomain); verify(reply).setJMSCorrelationID(correlationId); verify(queueSender).send(reply); verify(queueSender).close(); }
Example #2
Source File: DefaultJmsActivationSpecFactoryTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void webSphereResourceAdapterSetup() throws Exception { Destination destination = new StubQueue(); DestinationResolver destinationResolver = mock(DestinationResolver.class); given(destinationResolver.resolveDestinationName(null, "destinationname", false)).willReturn(destination); DefaultJmsActivationSpecFactory activationSpecFactory = new DefaultJmsActivationSpecFactory(); activationSpecFactory.setDestinationResolver(destinationResolver); StubWebSphereActivationSpecImpl spec = (StubWebSphereActivationSpecImpl) activationSpecFactory .createActivationSpec(new StubWebSphereResourceAdapterImpl(), activationSpecConfig); assertEquals(destination, spec.getDestination()); assertEquals(5, spec.getMaxConcurrency()); assertEquals(3, spec.getMaxBatchSize()); }
Example #3
Source File: DefaultJmsActivationSpecFactoryTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void webSphereResourceAdapterSetup() throws Exception { Destination destination = new StubQueue(); DestinationResolver destinationResolver = mock(DestinationResolver.class); given(destinationResolver.resolveDestinationName(null, "destinationname", false)).willReturn(destination); DefaultJmsActivationSpecFactory activationSpecFactory = new DefaultJmsActivationSpecFactory(); activationSpecFactory.setDestinationResolver(destinationResolver); StubWebSphereActivationSpecImpl spec = (StubWebSphereActivationSpecImpl) activationSpecFactory .createActivationSpec(new StubWebSphereResourceAdapterImpl(), activationSpecConfig); assertEquals(destination, spec.getDestination()); assertEquals(5, spec.getMaxConcurrency()); assertEquals(3, spec.getMaxBatchSize()); }
Example #4
Source File: DefaultJmsActivationSpecFactoryTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void webSphereResourceAdapterSetup() throws Exception { Destination destination = new StubQueue(); DestinationResolver destinationResolver = mock(DestinationResolver.class); given(destinationResolver.resolveDestinationName(null, "destinationname", false)).willReturn(destination); DefaultJmsActivationSpecFactory activationSpecFactory = new DefaultJmsActivationSpecFactory(); activationSpecFactory.setDestinationResolver(destinationResolver); StubWebSphereActivationSpecImpl spec = (StubWebSphereActivationSpecImpl) activationSpecFactory .createActivationSpec(new StubWebSphereResourceAdapterImpl(), activationSpecConfig); assertEquals(destination, spec.getDestination()); assertEquals(5, spec.getMaxConcurrency()); assertEquals(3, spec.getMaxBatchSize()); }
Example #5
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
@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), this.container); DirectFieldAccessor accessor = new DirectFieldAccessor(listener); assertSame(messageConverter, accessor.getPropertyValue("messageConverter")); assertSame(destinationResolver, accessor.getPropertyValue("destinationResolver")); }
Example #6
Source File: MethodJmsListenerEndpoint.java From java-technology-stack with MIT License | 5 votes |
@Override protected MessagingMessageListenerAdapter createMessageListener(MessageListenerContainer container) { Assert.state(this.messageHandlerMethodFactory != null, "Could not create message listener - MessageHandlerMethodFactory not set"); MessagingMessageListenerAdapter messageListener = createMessageListenerInstance(); InvocableHandlerMethod invocableHandlerMethod = this.messageHandlerMethodFactory.createInvocableHandlerMethod(getBean(), getMethod()); messageListener.setHandlerMethod(invocableHandlerMethod); String responseDestination = getDefaultResponseDestination(); if (StringUtils.hasText(responseDestination)) { if (container.isReplyPubSubDomain()) { messageListener.setDefaultResponseTopicName(responseDestination); } else { messageListener.setDefaultResponseQueueName(responseDestination); } } QosSettings responseQosSettings = container.getReplyQosSettings(); if (responseQosSettings != null) { messageListener.setResponseQosSettings(responseQosSettings); } MessageConverter messageConverter = container.getMessageConverter(); if (messageConverter != null) { messageListener.setMessageConverter(messageConverter); } DestinationResolver destinationResolver = container.getDestinationResolver(); if (destinationResolver != null) { messageListener.setDestinationResolver(destinationResolver); } return messageListener; }
Example #7
Source File: JmsResponseTests.java From java-technology-stack with MIT License | 5 votes |
@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); }
Example #8
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
@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), this.container); DirectFieldAccessor accessor = new DirectFieldAccessor(listener); assertSame(messageConverter, accessor.getPropertyValue("messageConverter")); assertSame(destinationResolver, accessor.getPropertyValue("destinationResolver")); }
Example #9
Source File: MethodJmsListenerEndpointTests.java From java-technology-stack with MIT License | 5 votes |
private void processAndReplyWithSendTo(MessagingMessageListenerAdapter listener, String replyDestinationName, boolean pubSubDomain, QosSettings replyQosSettings) 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); if (replyQosSettings != null) { verify(queueSender).send(reply, replyQosSettings.getDeliveryMode(), replyQosSettings.getPriority(), replyQosSettings.getTimeToLive()); } else { verify(queueSender).send(reply); } verify(queueSender).close(); }
Example #10
Source File: JmsMessageEndpointManager.java From java-technology-stack with MIT License | 5 votes |
@Override @Nullable public DestinationResolver getDestinationResolver() { if (this.activationSpecFactory instanceof StandardJmsActivationSpecFactory) { return ((StandardJmsActivationSpecFactory) this.activationSpecFactory).getDestinationResolver(); } return null; }
Example #11
Source File: DefaultMessageListenerContainer.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Refresh the JMS destination that this listener container operates on. * <p>Called after listener setup failure, assuming that a cached Destination * object might have become invalid (a typical case on WebLogic JMS). * <p>The default implementation removes the destination from a * DestinationResolver's cache, in case of a CachingDestinationResolver. * @see #setDestinationName * @see org.springframework.jms.support.destination.CachingDestinationResolver */ protected void refreshDestination() { String destName = getDestinationName(); if (destName != null) { DestinationResolver destResolver = getDestinationResolver(); if (destResolver instanceof CachingDestinationResolver) { ((CachingDestinationResolver) destResolver).removeFromCache(destName); } } }
Example #12
Source File: JmsResponse.java From spring4-understanding with Apache License 2.0 | 5 votes |
/** * Resolve the {@link Destination} to use for this instance. The {@link DestinationResolver} * and {@link Session} can be used to resolve a destination at runtime. * @param destinationResolver the destination resolver to use if necessary * @param session the session to use, if necessary * @return the {@link Destination} to use * @throws JMSException if the DestinationResolver failed to resolve the destination */ public Destination resolveDestination(DestinationResolver destinationResolver, Session session) throws JMSException { if (this.destination instanceof Destination) { return (Destination) this.destination; } if (this.destination instanceof DestinationNameHolder) { DestinationNameHolder nameHolder = (DestinationNameHolder) this.destination; return destinationResolver.resolveDestinationName(session, nameHolder.destinationName, nameHolder.pubSubDomain); } return null; }
Example #13
Source File: JmsResponse.java From java-technology-stack with MIT License | 5 votes |
/** * Resolve the {@link Destination} to use for this instance. The {@link DestinationResolver} * and {@link Session} can be used to resolve a destination at runtime. * @param destinationResolver the destination resolver to use if necessary * @param session the session to use, if necessary * @return the {@link Destination} to use * @throws JMSException if the DestinationResolver failed to resolve the destination */ @Nullable public Destination resolveDestination(DestinationResolver destinationResolver, Session session) throws JMSException { if (this.destination instanceof Destination) { return (Destination) this.destination; } if (this.destination instanceof DestinationNameHolder) { DestinationNameHolder nameHolder = (DestinationNameHolder) this.destination; return destinationResolver.resolveDestinationName(session, nameHolder.destinationName, nameHolder.pubSubDomain); } return null; }
Example #14
Source File: DefaultMessageListenerContainer.java From java-technology-stack with MIT License | 5 votes |
/** * Refresh the JMS destination that this listener container operates on. * <p>Called after listener setup failure, assuming that a cached Destination * object might have become invalid (a typical case on WebLogic JMS). * <p>The default implementation removes the destination from a * DestinationResolver's cache, in case of a CachingDestinationResolver. * @see #setDestinationName * @see org.springframework.jms.support.destination.CachingDestinationResolver */ protected void refreshDestination() { String destName = getDestinationName(); if (destName != null) { DestinationResolver destResolver = getDestinationResolver(); if (destResolver instanceof CachingDestinationResolver) { ((CachingDestinationResolver) destResolver).removeFromCache(destName); } } }
Example #15
Source File: JmsMessageEndpointManager.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public DestinationResolver getDestinationResolver() { if (this.activationSpecFactory instanceof StandardJmsActivationSpecFactory) { return ((StandardJmsActivationSpecFactory) this.activationSpecFactory).getDestinationResolver(); } return null; }
Example #16
Source File: MethodJmsListenerEndpointTests.java From spring-analysis-note with MIT License | 5 votes |
private void processAndReplyWithSendTo(MessagingMessageListenerAdapter listener, String replyDestinationName, boolean pubSubDomain, QosSettings replyQosSettings) 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); if (replyQosSettings != null) { verify(queueSender).send(reply, replyQosSettings.getDeliveryMode(), replyQosSettings.getPriority(), replyQosSettings.getTimeToLive()); } else { verify(queueSender).send(reply); } verify(queueSender).close(); }
Example #17
Source File: JmsResponseTests.java From spring-analysis-note with MIT License | 5 votes |
@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); }
Example #18
Source File: MethodJmsListenerEndpoint.java From spring-analysis-note with MIT License | 5 votes |
@Override protected MessagingMessageListenerAdapter createMessageListener(MessageListenerContainer container) { Assert.state(this.messageHandlerMethodFactory != null, "Could not create message listener - MessageHandlerMethodFactory not set"); MessagingMessageListenerAdapter messageListener = createMessageListenerInstance(); Object bean = getBean(); Method method = getMethod(); Assert.state(bean != null && method != null, "No bean+method set on endpoint"); InvocableHandlerMethod invocableHandlerMethod = this.messageHandlerMethodFactory.createInvocableHandlerMethod(bean, method); messageListener.setHandlerMethod(invocableHandlerMethod); String responseDestination = getDefaultResponseDestination(); if (StringUtils.hasText(responseDestination)) { if (container.isReplyPubSubDomain()) { messageListener.setDefaultResponseTopicName(responseDestination); } else { messageListener.setDefaultResponseQueueName(responseDestination); } } QosSettings responseQosSettings = container.getReplyQosSettings(); if (responseQosSettings != null) { messageListener.setResponseQosSettings(responseQosSettings); } MessageConverter messageConverter = container.getMessageConverter(); if (messageConverter != null) { messageListener.setMessageConverter(messageConverter); } DestinationResolver destinationResolver = container.getDestinationResolver(); if (destinationResolver != null) { messageListener.setDestinationResolver(destinationResolver); } return messageListener; }
Example #19
Source File: MethodJmsListenerEndpoint.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override protected MessagingMessageListenerAdapter createMessageListener(MessageListenerContainer container) { Assert.state(this.messageHandlerMethodFactory != null, "Could not create message listener - MessageHandlerMethodFactory not set"); MessagingMessageListenerAdapter messageListener = createMessageListenerInstance(); InvocableHandlerMethod invocableHandlerMethod = this.messageHandlerMethodFactory.createInvocableHandlerMethod(getBean(), getMethod()); messageListener.setHandlerMethod(invocableHandlerMethod); String responseDestination = getDefaultResponseDestination(); if (StringUtils.hasText(responseDestination)) { if (container.isReplyPubSubDomain()) { messageListener.setDefaultResponseTopicName(responseDestination); } else { messageListener.setDefaultResponseQueueName(responseDestination); } } MessageConverter messageConverter = container.getMessageConverter(); if (messageConverter != null) { messageListener.setMessageConverter(messageConverter); } DestinationResolver destinationResolver = container.getDestinationResolver(); if (destinationResolver != null) { messageListener.setDestinationResolver(destinationResolver); } return messageListener; }
Example #20
Source File: JmsResponseTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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); }
Example #21
Source File: JmsMessageEndpointManager.java From spring-analysis-note with MIT License | 5 votes |
@Override @Nullable public DestinationResolver getDestinationResolver() { if (this.activationSpecFactory instanceof StandardJmsActivationSpecFactory) { return ((StandardJmsActivationSpecFactory) this.activationSpecFactory).getDestinationResolver(); } return null; }
Example #22
Source File: MethodJmsListenerEndpointTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@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")); }
Example #23
Source File: DefaultMessageListenerContainer.java From spring-analysis-note with MIT License | 5 votes |
/** * Refresh the JMS destination that this listener container operates on. * <p>Called after listener setup failure, assuming that a cached Destination * object might have become invalid (a typical case on WebLogic JMS). * <p>The default implementation removes the destination from a * DestinationResolver's cache, in case of a CachingDestinationResolver. * @see #setDestinationName * @see org.springframework.jms.support.destination.CachingDestinationResolver */ protected void refreshDestination() { String destName = getDestinationName(); if (destName != null) { DestinationResolver destResolver = getDestinationResolver(); if (destResolver instanceof CachingDestinationResolver) { ((CachingDestinationResolver) destResolver).removeFromCache(destName); } } }
Example #24
Source File: JmsResponse.java From spring-analysis-note with MIT License | 5 votes |
/** * Resolve the {@link Destination} to use for this instance. The {@link DestinationResolver} * and {@link Session} can be used to resolve a destination at runtime. * @param destinationResolver the destination resolver to use if necessary * @param session the session to use, if necessary * @return the {@link Destination} to use * @throws JMSException if the DestinationResolver failed to resolve the destination */ @Nullable public Destination resolveDestination(DestinationResolver destinationResolver, Session session) throws JMSException { if (this.destination instanceof Destination) { return (Destination) this.destination; } if (this.destination instanceof DestinationNameHolder) { DestinationNameHolder nameHolder = (DestinationNameHolder) this.destination; return destinationResolver.resolveDestinationName(session, nameHolder.destinationName, nameHolder.pubSubDomain); } return null; }
Example #25
Source File: MessageListenerTestContainer.java From spring4-understanding with Apache License 2.0 | 4 votes |
@Override public DestinationResolver getDestinationResolver() { return null; }
Example #26
Source File: StandardJmsActivationSpecFactory.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Return the {@link DestinationResolver} to use for resolving destinations names. */ public DestinationResolver getDestinationResolver() { return destinationResolver; }
Example #27
Source File: AbstractAdaptableMessageListener.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * Return the DestinationResolver for this adapter. */ protected DestinationResolver getDestinationResolver() { return this.destinationResolver; }
Example #28
Source File: DefaultJcaListenerContainerFactory.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * @see JmsMessageEndpointManager#setDestinationResolver(DestinationResolver) */ public void setDestinationResolver(DestinationResolver destinationResolver) { this.destinationResolver = destinationResolver; }
Example #29
Source File: AbstractJmsListenerContainerFactory.java From spring4-understanding with Apache License 2.0 | 4 votes |
/** * @see AbstractMessageListenerContainer#setDestinationResolver(DestinationResolver) */ public void setDestinationResolver(DestinationResolver destinationResolver) { this.destinationResolver = destinationResolver; }
Example #30
Source File: MessageListenerTestContainer.java From java-technology-stack with MIT License | 4 votes |
@Override public DestinationResolver getDestinationResolver() { return null; }