org.springframework.jms.listener.AbstractMessageListenerContainer Java Examples

The following examples show how to use org.springframework.jms.listener.AbstractMessageListenerContainer. 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: JmsSourceTests.java    From spring-cloud-stream-app-starters with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws Exception {
	AbstractMessageListenerContainer container = TestUtils.getPropertyValue(this.endpoint, "listenerContainer",
			AbstractMessageListenerContainer.class);
	assertThat(container, instanceOf(DefaultMessageListenerContainer.class));
	assertEquals(Session.AUTO_ACKNOWLEDGE, TestUtils.getPropertyValue(container, "sessionAcknowledgeMode"));
	assertTrue(TestUtils.getPropertyValue(container, "sessionTransacted", Boolean.class));
	assertEquals("client", TestUtils.getPropertyValue(container, "clientId"));
	assertEquals("topic", TestUtils.getPropertyValue(container, "destination"));
	assertTrue(TestUtils.getPropertyValue(container, "subscriptionDurable", Boolean.class));
	assertEquals("subName", TestUtils.getPropertyValue(container, "subscriptionName"));
	assertFalse(TestUtils.getPropertyValue(container, "subscriptionShared", Boolean.class));
	assertEquals(3, TestUtils.getPropertyValue(container, "concurrentConsumers"));
	assertEquals(4, TestUtils.getPropertyValue(container, "maxConcurrentConsumers"));
	assertTrue(TestUtils.getPropertyValue(container, "pubSubDomain", Boolean.class));
}
 
Example #2
Source File: JmsSourceTests.java    From spring-cloud-stream-app-starters with Apache License 2.0 6 votes vote down vote up
@Test
public void test() throws Exception {
	AbstractMessageListenerContainer container = TestUtils.getPropertyValue(this.endpoint, "listenerContainer",
			AbstractMessageListenerContainer.class);
	assertThat(container, instanceOf(DefaultMessageListenerContainer.class));
	assertEquals(Session.AUTO_ACKNOWLEDGE, TestUtils.getPropertyValue(container, "sessionAcknowledgeMode"));
	assertTrue(TestUtils.getPropertyValue(container, "sessionTransacted", Boolean.class));
	assertEquals("jmssource.test.queue", TestUtils.getPropertyValue(container, "destination"));
	assertEquals("JMSCorrelationId=foo", TestUtils.getPropertyValue(container, "messageSelector"));
	assertFalse(TestUtils.getPropertyValue(container, "subscriptionDurable", Boolean.class));
	assertFalse(TestUtils.getPropertyValue(container, "subscriptionShared", Boolean.class));
	assertEquals(3, TestUtils.getPropertyValue(container, "concurrentConsumers"));
	assertEquals(4, TestUtils.getPropertyValue(container, "maxConcurrentConsumers"));
	assertFalse(TestUtils.getPropertyValue(container, "pubSubDomain", Boolean.class));

	template.convertAndSend("jmssource.test.queue", "Hello, world!");
	Message<?> received = messageCollector.forChannel(channels.output()).poll(10, TimeUnit.SECONDS);
	assertNotNull(received);
	assertEquals("Hello, world!", received.getPayload());
}
 
Example #3
Source File: AbstractJmsListenerEndpoint.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void setupListenerContainer(MessageListenerContainer listenerContainer) {
	if (listenerContainer instanceof AbstractMessageListenerContainer) {
		setupJmsListenerContainer((AbstractMessageListenerContainer) listenerContainer);
	}
	else {
		new JcaEndpointConfigurer().configureEndpoint(listenerContainer);
	}
}
 
Example #4
Source File: AbstractJmsListenerEndpoint.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void setupJmsListenerContainer(AbstractMessageListenerContainer listenerContainer) {
	if (getDestination() != null) {
		listenerContainer.setDestinationName(getDestination());
	}
	if (getSubscription() != null) {
		listenerContainer.setSubscriptionName(getSubscription());
	}
	if (getSelector() != null) {
		listenerContainer.setMessageSelector(getSelector());
	}
	if (getConcurrency() != null) {
		listenerContainer.setConcurrency(getConcurrency());
	}
	setupMessageListener(listenerContainer);
}
 
Example #5
Source File: AbstractJmsListenerEndpoint.java    From spring-analysis-note with MIT License 5 votes vote down vote up
public void configureEndpoint(Object listenerContainer) {
	if (listenerContainer instanceof JmsMessageEndpointManager) {
		setupJcaMessageContainer((JmsMessageEndpointManager) listenerContainer);
	}
	else {
		throw new IllegalArgumentException("Could not configure endpoint with the specified container '" +
				listenerContainer + "' Only JMS (" + AbstractMessageListenerContainer.class.getName() +
				" subclass) or JCA (" + JmsMessageEndpointManager.class.getName() + ") are supported.");
	}
}
 
Example #6
Source File: JmsListenerContainerFactoryTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void assertDefaultJmsConfig(AbstractMessageListenerContainer container) {
	assertEquals(this.connectionFactory, container.getConnectionFactory());
	assertEquals(this.destinationResolver, container.getDestinationResolver());
	assertEquals(this.messageConverter, container.getMessageConverter());
	assertEquals(true, container.isSessionTransacted());
	assertEquals(Session.DUPS_OK_ACKNOWLEDGE, container.getSessionAcknowledgeMode());
	assertEquals(true, container.isPubSubDomain());
	assertEquals(true, container.isReplyPubSubDomain());
	assertEquals(new QosSettings(1, 7, 5000), container.getReplyQosSettings());
	assertEquals(true, container.isSubscriptionDurable());
	assertEquals("client-1234", container.getClientId());
	assertEquals(false, container.isAutoStartup());
}
 
Example #7
Source File: AbstractJmsListenerEndpoint.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void setupListenerContainer(MessageListenerContainer listenerContainer) {
	if (listenerContainer instanceof AbstractMessageListenerContainer) {
		setupJmsListenerContainer((AbstractMessageListenerContainer) listenerContainer);
	}
	else {
		new JcaEndpointConfigurer().configureEndpoint(listenerContainer);
	}
}
 
Example #8
Source File: AbstractJmsListenerEndpoint.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void setupJmsListenerContainer(AbstractMessageListenerContainer listenerContainer) {
	if (getDestination() != null) {
		listenerContainer.setDestinationName(getDestination());
	}
	if (getSubscription() != null) {
		listenerContainer.setSubscriptionName(getSubscription());
	}
	if (getSelector() != null) {
		listenerContainer.setMessageSelector(getSelector());
	}
	if (getConcurrency() != null) {
		listenerContainer.setConcurrency(getConcurrency());
	}
	setupMessageListener(listenerContainer);
}
 
Example #9
Source File: AbstractJmsListenerEndpoint.java    From java-technology-stack with MIT License 5 votes vote down vote up
public void configureEndpoint(Object listenerContainer) {
	if (listenerContainer instanceof JmsMessageEndpointManager) {
		setupJcaMessageContainer((JmsMessageEndpointManager) listenerContainer);
	}
	else {
		throw new IllegalArgumentException("Could not configure endpoint with the specified container '" +
				listenerContainer + "' Only JMS (" + AbstractMessageListenerContainer.class.getName() +
				" subclass) or JCA (" + JmsMessageEndpointManager.class.getName() + ") are supported.");
	}
}
 
Example #10
Source File: JmsListenerContainerFactoryTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void assertDefaultJmsConfig(AbstractMessageListenerContainer container) {
	assertEquals(this.connectionFactory, container.getConnectionFactory());
	assertEquals(this.destinationResolver, container.getDestinationResolver());
	assertEquals(this.messageConverter, container.getMessageConverter());
	assertEquals(true, container.isSessionTransacted());
	assertEquals(Session.DUPS_OK_ACKNOWLEDGE, container.getSessionAcknowledgeMode());
	assertEquals(true, container.isPubSubDomain());
	assertEquals(true, container.isReplyPubSubDomain());
	assertEquals(new QosSettings(1, 7, 5000), container.getReplyQosSettings());
	assertEquals(true, container.isSubscriptionDurable());
	assertEquals("client-1234", container.getClientId());
	assertEquals(false, container.isAutoStartup());
}
 
Example #11
Source File: AbstractJmsListenerEndpoint.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void setupListenerContainer(MessageListenerContainer listenerContainer) {
	if (listenerContainer instanceof AbstractMessageListenerContainer) {
		setupJmsListenerContainer((AbstractMessageListenerContainer) listenerContainer);
	}
	else {
		new JcaEndpointConfigurer().configureEndpoint(listenerContainer);
	}
}
 
Example #12
Source File: AbstractJmsListenerEndpoint.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void setupJmsListenerContainer(AbstractMessageListenerContainer listenerContainer) {
	if (getDestination() != null) {
		listenerContainer.setDestinationName(getDestination());
	}
	if (getSubscription() != null) {
		listenerContainer.setSubscriptionName(getSubscription());
	}
	if (getSelector() != null) {
		listenerContainer.setMessageSelector(getSelector());
	}
	if (getConcurrency() != null) {
		listenerContainer.setConcurrency(getConcurrency());
	}
	setupMessageListener(listenerContainer);
}
 
Example #13
Source File: AbstractJmsListenerEndpoint.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
public void configureEndpoint(Object listenerContainer) {
	if (listenerContainer instanceof JmsMessageEndpointManager) {
		setupJcaMessageContainer((JmsMessageEndpointManager) listenerContainer);
	}
	else {
		throw new IllegalArgumentException("Could not configure endpoint with the specified container '" +
				listenerContainer + "' Only JMS (" + AbstractMessageListenerContainer.class.getName() +
				" subclass) or JCA (" + JmsMessageEndpointManager.class.getName() + ") are supported.");
	}
}
 
Example #14
Source File: JmsListenerContainerFactoryTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
private void assertDefaultJmsConfig(AbstractMessageListenerContainer container) {
	assertEquals(connectionFactory, container.getConnectionFactory());
	assertEquals(destinationResolver, container.getDestinationResolver());
	assertEquals(messageConverter, container.getMessageConverter());
	assertEquals(true, container.isSessionTransacted());
	assertEquals(Session.DUPS_OK_ACKNOWLEDGE, container.getSessionAcknowledgeMode());
	assertEquals(true, container.isPubSubDomain());
	assertEquals(true, container.isReplyPubSubDomain());
	assertEquals(true, container.isSubscriptionDurable());
	assertEquals("client-1234", container.getClientId());
	assertEquals(false, container.isAutoStartup());
}
 
Example #15
Source File: JmsSourceTests.java    From spring-cloud-stream-app-starters with Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
	AbstractMessageListenerContainer container = TestUtils.getPropertyValue(this.endpoint, "listenerContainer",
			AbstractMessageListenerContainer.class);
	assertThat(container, instanceOf(SimpleMessageListenerContainer.class));
	assertEquals(Session.DUPS_OK_ACKNOWLEDGE, TestUtils.getPropertyValue(container, "sessionAcknowledgeMode"));
	assertFalse(TestUtils.getPropertyValue(container, "sessionTransacted", Boolean.class));
	assertEquals("client", TestUtils.getPropertyValue(container, "clientId"));
	assertEquals("topic", TestUtils.getPropertyValue(container, "destination"));
	assertEquals("JMSCorrelationId=foo", TestUtils.getPropertyValue(container, "messageSelector"));
	assertFalse(TestUtils.getPropertyValue(container, "subscriptionDurable", Boolean.class));
	assertFalse(TestUtils.getPropertyValue(container, "subscriptionShared", Boolean.class));
	assertEquals(3, TestUtils.getPropertyValue(container, "concurrentConsumers"));
	assertTrue(TestUtils.getPropertyValue(container, "pubSubDomain", Boolean.class));
}