use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.
the class JmsChannelFactoryBean method createInstance.
@Override
protected AbstractJmsChannel createInstance() throws Exception {
this.initializeJmsTemplate();
if (this.messageDriven) {
this.container = createContainer();
SubscribableJmsChannel subscribableJmsChannel = new SubscribableJmsChannel(this.container, this.jmsTemplate);
subscribableJmsChannel.setMaxSubscribers(this.maxSubscribers);
this.channel = subscribableJmsChannel;
} else {
Assert.isTrue(!Boolean.TRUE.equals(this.pubSubDomain), "A JMS Topic-backed 'publish-subscribe-channel' must be message-driven.");
PollableJmsChannel pollableJmschannel = new PollableJmsChannel(this.jmsTemplate);
if (this.messageSelector != null) {
pollableJmschannel.setMessageSelector(this.messageSelector);
}
this.channel = pollableJmschannel;
}
if (!CollectionUtils.isEmpty(this.interceptors)) {
this.channel.setInterceptors(this.interceptors);
}
this.channel.setBeanName(this.beanName);
if (this.getBeanFactory() != null) {
this.channel.setBeanFactory(this.getBeanFactory());
}
this.channel.afterPropertiesSet();
return this.channel;
}
use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.
the class JmsChannelParserTests method channelWithConcurrencySettings.
@Test
public void channelWithConcurrencySettings() {
assertEquals(SubscribableJmsChannel.class, channelWithConcurrencySettings.getClass());
SubscribableJmsChannel channel = (SubscribableJmsChannel) channelWithConcurrencySettings;
DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
DefaultMessageListenerContainer container = (DefaultMessageListenerContainer) accessor.getPropertyValue("container");
assertEquals(11, container.getConcurrentConsumers());
assertEquals(55, container.getMaxConcurrentConsumers());
}
use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.
the class JmsChannelParserTests method queueNameWithResolverChannel.
@Test
public void queueNameWithResolverChannel() {
assertEquals(SubscribableJmsChannel.class, queueNameWithResolverChannel.getClass());
SubscribableJmsChannel channel = (SubscribableJmsChannel) queueNameWithResolverChannel;
DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
assertEquals("foo", jmsTemplate.getDefaultDestinationName());
assertEquals("foo", container.getDestinationName());
}
use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.
the class JmsChannelParserTests method queueReferenceChannel.
@Test
public void queueReferenceChannel() {
assertEquals(SubscribableJmsChannel.class, queueReferenceChannel.getClass());
SubscribableJmsChannel channel = (SubscribableJmsChannel) queueReferenceChannel;
DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer) accessor.getPropertyValue("container");
assertEquals(queue, jmsTemplate.getDefaultDestination());
assertEquals(queue, container.getDestination());
assertEquals(true, TestUtils.getPropertyValue(jmsTemplate, "explicitQosEnabled"));
assertEquals(DeliveryMode.PERSISTENT, TestUtils.getPropertyValue(jmsTemplate, "deliveryMode"));
assertEquals(123L, TestUtils.getPropertyValue(jmsTemplate, "timeToLive"));
assertEquals(12, TestUtils.getPropertyValue(jmsTemplate, "priority"));
assertEquals(Integer.MAX_VALUE, TestUtils.getPropertyValue(TestUtils.getPropertyValue(channel, "dispatcher"), "maxSubscribers", Integer.class).intValue());
}
use of org.springframework.integration.jms.SubscribableJmsChannel in project spring-integration by spring-projects.
the class JmsChannelHistoryTests method testMessageHistory.
@Test
public void testMessageHistory() throws Exception {
AbstractMessageListenerContainer mlContainer = mock(AbstractMessageListenerContainer.class);
JmsTemplate template = mock(JmsTemplate.class);
SubscribableJmsChannel channel = new SubscribableJmsChannel(mlContainer, template);
channel.setShouldTrack(true);
channel.setBeanName("jmsChannel");
Message<String> message = new GenericMessage<String>("hello");
doAnswer(invocation -> {
@SuppressWarnings("unchecked") Message<String> msg = invocation.getArgument(0);
MessageHistory history = MessageHistory.read(msg);
assertTrue(history.get(0).contains("jmsChannel"));
return null;
}).when(template).convertAndSend(Mockito.any(Message.class));
channel.send(message);
verify(template, times(1)).convertAndSend(Mockito.any(Message.class));
channel.stop();
}
Aggregations