Search in sources :

Example 1 with PollableJmsChannel

use of org.springframework.integration.jms.PollableJmsChannel 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;
}
Also used : SubscribableJmsChannel(org.springframework.integration.jms.SubscribableJmsChannel) PollableJmsChannel(org.springframework.integration.jms.PollableJmsChannel)

Example 2 with PollableJmsChannel

use of org.springframework.integration.jms.PollableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method selectorPollableChannel.

@Test
public void selectorPollableChannel() {
    assertEquals(PollableJmsChannel.class, pollableWithSelectorChannel.getClass());
    PollableJmsChannel channel = (PollableJmsChannel) pollableWithSelectorChannel;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
    assertEquals(queue, jmsTemplate.getDefaultDestination());
    assertEquals("foo='bar'", accessor.getPropertyValue("messageSelector"));
}
Also used : PollableJmsChannel(org.springframework.integration.jms.PollableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Example 3 with PollableJmsChannel

use of org.springframework.integration.jms.PollableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method queueReferencePollableChannel.

@Test
public void queueReferencePollableChannel() {
    assertEquals(PollableJmsChannel.class, pollableQueueReferenceChannel.getClass());
    PollableJmsChannel channel = (PollableJmsChannel) pollableQueueReferenceChannel;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
    assertEquals(queue, jmsTemplate.getDefaultDestination());
}
Also used : PollableJmsChannel(org.springframework.integration.jms.PollableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Example 4 with PollableJmsChannel

use of org.springframework.integration.jms.PollableJmsChannel in project spring-integration by spring-projects.

the class JmsChannelParserTests method queueNamePollableChannel.

@Test
public void queueNamePollableChannel() {
    assertEquals(PollableJmsChannel.class, pollableQueueNameChannel.getClass());
    PollableJmsChannel channel = (PollableJmsChannel) pollableQueueNameChannel;
    DirectFieldAccessor accessor = new DirectFieldAccessor(channel);
    JmsTemplate jmsTemplate = (JmsTemplate) accessor.getPropertyValue("jmsTemplate");
    assertEquals("foo", jmsTemplate.getDefaultDestinationName());
}
Also used : PollableJmsChannel(org.springframework.integration.jms.PollableJmsChannel) DirectFieldAccessor(org.springframework.beans.DirectFieldAccessor) JmsTemplate(org.springframework.jms.core.JmsTemplate) Test(org.junit.Test)

Aggregations

PollableJmsChannel (org.springframework.integration.jms.PollableJmsChannel)4 Test (org.junit.Test)3 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)3 JmsTemplate (org.springframework.jms.core.JmsTemplate)3 SubscribableJmsChannel (org.springframework.integration.jms.SubscribableJmsChannel)1