Renamed JmsGateway to JmsInboundGateway (we also have JmsOutboundGateway now). The JmsSource is now JmsDestinationPollingSource.
This commit is contained in:
@@ -27,22 +27,22 @@ import org.springframework.jms.core.JmsTemplate;
|
||||
/**
|
||||
* A source for receiving JMS Messages with a polling listener. This source is
|
||||
* only recommended for very low message volume. Otherwise, the
|
||||
* {@link JmsGateway} that uses Spring's MessageListener
|
||||
* container support is highly recommended.
|
||||
* {@link JmsInboundGateway} that uses Spring's MessageListener container
|
||||
* support is a better option.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsSource extends AbstractJmsTemplateBasedAdapter implements MessageSource<Object> {
|
||||
public class JmsDestinationPollingSource extends AbstractJmsTemplateBasedAdapter implements MessageSource<Object> {
|
||||
|
||||
public JmsSource(JmsTemplate jmsTemplate) {
|
||||
public JmsDestinationPollingSource(JmsTemplate jmsTemplate) {
|
||||
super(jmsTemplate);
|
||||
}
|
||||
|
||||
public JmsSource(ConnectionFactory connectionFactory, Destination destination) {
|
||||
public JmsDestinationPollingSource(ConnectionFactory connectionFactory, Destination destination) {
|
||||
super(connectionFactory, destination);
|
||||
}
|
||||
|
||||
public JmsSource(ConnectionFactory connectionFactory, String destinationName) {
|
||||
public JmsDestinationPollingSource(ConnectionFactory connectionFactory, String destinationName) {
|
||||
super(connectionFactory, destinationName);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsGateway extends SimpleMessagingGateway implements Lifecycle, DisposableBean {
|
||||
public class JmsInboundGateway extends SimpleMessagingGateway implements Lifecycle, DisposableBean {
|
||||
|
||||
private volatile AbstractMessageListenerContainer container;
|
||||
|
||||
@@ -146,7 +146,7 @@ public class JmsGateway extends SimpleMessagingGateway implements Lifecycle, Dis
|
||||
listener.setDelegate(new SessionAwareMessageListener() {
|
||||
public void onMessage(javax.jms.Message jmsMessage, Session session) throws JMSException {
|
||||
Object object = messageConverter.fromMessage(jmsMessage);
|
||||
Message<?> replyMessage = JmsGateway.this.sendAndReceiveMessage(object);
|
||||
Message<?> replyMessage = JmsInboundGateway.this.sendAndReceiveMessage(object);
|
||||
if (replyMessage != null) {
|
||||
javax.jms.Message jmsReply = messageConverter.toMessage(replyMessage, session);
|
||||
MessageProducer producer = session.createProducer(jmsMessage.getJMSReplyTo());
|
||||
@@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractPollingInboundChannelAdapterParser;
|
||||
import org.springframework.integration.jms.JmsSource;
|
||||
import org.springframework.integration.jms.JmsDestinationPollingSource;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -43,7 +43,7 @@ public class JmsInboundChannelAdapterParser extends AbstractPollingInboundChanne
|
||||
|
||||
@Override
|
||||
protected String parseSource(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JmsSource.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JmsDestinationPollingSource.class);
|
||||
String jmsTemplate = element.getAttribute(JmsAdapterParserUtils.JMS_TEMPLATE_ATTRIBUTE);
|
||||
String destination = element.getAttribute(JmsAdapterParserUtils.DESTINATION_ATTRIBUTE);
|
||||
String destinationName = element.getAttribute(JmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE);
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.AbstractSingleBeanDefinitionParser;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.jms.JmsGateway;
|
||||
import org.springframework.integration.jms.JmsInboundGateway;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -33,11 +33,11 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsGatewayParser extends AbstractSingleBeanDefinitionParser {
|
||||
public class JmsInboundGatewayParser extends AbstractSingleBeanDefinitionParser {
|
||||
|
||||
@Override
|
||||
protected Class<?> getBeanClass(Element element) {
|
||||
return JmsGateway.class;
|
||||
return JmsInboundGateway.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -56,7 +56,7 @@ public class JmsGatewayParser extends AbstractSingleBeanDefinitionParser {
|
||||
String destinationName = element.getAttribute(JmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE);
|
||||
String messageConverter = element.getAttribute(JmsAdapterParserUtils.MESSAGE_CONVERTER_ATTRIBUTE);
|
||||
if (StringUtils.hasText(element.getAttribute(JmsAdapterParserUtils.JMS_TEMPLATE_ATTRIBUTE))) {
|
||||
throw new BeanCreationException(JmsGateway.class.getSimpleName() +
|
||||
throw new BeanCreationException(JmsInboundGateway.class.getSimpleName() +
|
||||
" does not accept a '" + JmsAdapterParserUtils.JMS_TEMPLATE_ATTRIBUTE +
|
||||
"' reference. One of '" + JmsAdapterParserUtils.DESTINATION_ATTRIBUTE + "' or '" +
|
||||
JmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE + "' must be provided.");
|
||||
@@ -28,7 +28,7 @@ import org.springframework.integration.jms.JmsHeaders;
|
||||
public class JmsNamespaceHandler extends NamespaceHandlerSupport {
|
||||
|
||||
public void init() {
|
||||
this.registerBeanDefinitionParser("inbound-gateway", new JmsGatewayParser());
|
||||
this.registerBeanDefinitionParser("inbound-gateway", new JmsInboundGatewayParser());
|
||||
this.registerBeanDefinitionParser("inbound-channel-adapter", new JmsInboundChannelAdapterParser());
|
||||
this.registerBeanDefinitionParser("outbound-channel-adapter", new JmsOutboundChannelAdapterParser());
|
||||
this.registerBeanDefinitionParser("header-enricher", new SimpleHeaderEnricherParser(
|
||||
|
||||
@@ -28,21 +28,21 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.jms.JmsGateway;
|
||||
import org.springframework.integration.jms.JmsInboundGateway;
|
||||
import org.springframework.jms.connection.JmsTransactionManager;
|
||||
import org.springframework.jms.listener.AbstractMessageListenerContainer;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsGatewayParserTests {
|
||||
public class JmsInboundGatewayParserTests {
|
||||
|
||||
@Test
|
||||
public void testGatewayWithConnectionFactoryAndDestination() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithConnectionFactoryAndDestination.xml", this.getClass());
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("jmsGateway");
|
||||
gateway.setRequestChannel(channel);
|
||||
context.start();
|
||||
Message<?> message = channel.receive(3000);
|
||||
@@ -56,7 +56,7 @@ public class JmsGatewayParserTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithConnectionFactoryAndDestinationName.xml", this.getClass());
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("jmsGateway");
|
||||
gateway.setRequestChannel(channel);
|
||||
context.start();
|
||||
Message<?> message = channel.receive(3000);
|
||||
@@ -70,7 +70,7 @@ public class JmsGatewayParserTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithMessageConverter.xml", this.getClass());
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("jmsGateway");
|
||||
gateway.setRequestChannel(channel);
|
||||
context.start();
|
||||
Message<?> message = channel.receive(3000);
|
||||
@@ -83,7 +83,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithDefaultExtractPayload() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewaysWithExtractPayloadAttributes.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("defaultGateway");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("defaultGateway");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals(Boolean.FALSE, accessor.getPropertyValue("extractPayloadForReply"));
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithExtractPayloadTrue() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewaysWithExtractPayloadAttributes.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayExpectingReply");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayExpectingReply");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals(Boolean.TRUE, accessor.getPropertyValue("extractPayloadForReply"));
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithExtractPayloadFalse() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewaysWithExtractPayloadAttributes.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayNotExpectingReply");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayNotExpectingReply");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals(Boolean.FALSE, accessor.getPropertyValue("extractPayloadForReply"));
|
||||
}
|
||||
@@ -133,7 +133,7 @@ public class JmsGatewayParserTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithDefaultConnectionFactory.xml", this.getClass());
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("jmsGateway");
|
||||
gateway.setRequestChannel(channel);
|
||||
context.start();
|
||||
Message<?> message = channel.receive(3000);
|
||||
@@ -146,7 +146,7 @@ public class JmsGatewayParserTests {
|
||||
public void testTransactionManagerIsNullByDefault() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayTransactionManagerTests.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayWithoutTransactionManager");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayWithoutTransactionManager");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertNull(accessor.getPropertyValue("transactionManager"));
|
||||
}
|
||||
@@ -155,7 +155,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithTransactionManagerReference() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayTransactionManagerTests.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayWithTransactionManager");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayWithTransactionManager");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
Object txManager = accessor.getPropertyValue("transactionManager");
|
||||
assertEquals(JmsTransactionManager.class, txManager.getClass());
|
||||
@@ -167,7 +167,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithConcurrentConsumers() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithContainerSettings.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayWithConcurrentConsumers");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayWithConcurrentConsumers");
|
||||
gateway.start();
|
||||
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer)
|
||||
new DirectFieldAccessor(gateway).getPropertyValue("container");
|
||||
@@ -179,7 +179,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithMaxConcurrentConsumers() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithContainerSettings.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayWithMaxConcurrentConsumers");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayWithMaxConcurrentConsumers");
|
||||
gateway.start();
|
||||
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer)
|
||||
new DirectFieldAccessor(gateway).getPropertyValue("container");
|
||||
@@ -191,7 +191,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithMaxMessagesPerTask() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithContainerSettings.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayWithMaxMessagesPerTask");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayWithMaxMessagesPerTask");
|
||||
gateway.start();
|
||||
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer)
|
||||
new DirectFieldAccessor(gateway).getPropertyValue("container");
|
||||
@@ -203,7 +203,7 @@ public class JmsGatewayParserTests {
|
||||
public void testGatewayWithIdleTaskExecutionLimit() {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"jmsGatewayWithContainerSettings.xml", this.getClass());
|
||||
JmsGateway gateway = (JmsGateway) context.getBean("gatewayWithIdleTaskExecutionLimit");
|
||||
JmsInboundGateway gateway = (JmsInboundGateway) context.getBean("gatewayWithIdleTaskExecutionLimit");
|
||||
gateway.start();
|
||||
AbstractMessageListenerContainer container = (AbstractMessageListenerContainer)
|
||||
new DirectFieldAccessor(gateway).getPropertyValue("container");
|
||||
Reference in New Issue
Block a user