Refactored MessageConsumer with onMessage to MessageHandler with handleMessage.
This commit is contained in:
@@ -18,7 +18,7 @@ package org.springframework.integration.adapter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.remoting.RemoteAccessException;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractRemotingOutboundGateway extends AbstractReplyProducingMessageConsumer {
|
||||
public abstract class AbstractRemotingOutboundGateway extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
private final MessageHandler handlerProxy;
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class AbstractRemotingOutboundGateway extends AbstractReplyProdu
|
||||
|
||||
|
||||
@Override
|
||||
public final void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
public final void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
if (!(message.getPayload() instanceof Serializable)) {
|
||||
throw new MessageHandlingException(message,
|
||||
this.getClass().getName() + " expects a Serializable payload type " +
|
||||
|
||||
@@ -19,19 +19,19 @@ package org.springframework.integration.event;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.context.ApplicationEventPublisherAware;
|
||||
import org.springframework.integration.consumer.AbstractMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractMessageHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link org.springframework.integration.message.MessageConsumer} that
|
||||
* publishes each {@link Message} it receives as a {@link MessagingEvent}. The
|
||||
* {@link MessagingEvent} is a subclass of Spring's {@link ApplicationEvent}
|
||||
* used by this adapter to simply wrap the {@link Message}.
|
||||
* A {@link MessageHandler} that publishes each {@link Message} it receives as
|
||||
* a {@link MessagingEvent}. The {@link MessagingEvent} is a subclass of
|
||||
* Spring's {@link ApplicationEvent} used by this adapter to simply wrap the
|
||||
* {@link Message}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ApplicationEventPublishingMessageConsumer<T> extends AbstractMessageConsumer implements ApplicationEventPublisherAware {
|
||||
public class ApplicationEventPublishingMessageHandler<T> extends AbstractMessageHandler implements ApplicationEventPublisherAware {
|
||||
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ApplicationEventPublishingMessageConsumer<T> extends AbstractMessag
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMessageInternal(Message<?> message) {
|
||||
protected void handleMessageInternal(Message<?> message) {
|
||||
Assert.notNull(this.applicationEventPublisher, "applicationEventPublisher is required");
|
||||
this.applicationEventPublisher.publishEvent(new MessagingEvent((Message<?>) message));
|
||||
}
|
||||
@@ -29,17 +29,17 @@ import org.springframework.integration.message.StringMessage;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ApplicationEventPublishingMessageConsumerTests {
|
||||
public class ApplicationEventPublishingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testSendingEvent() throws InterruptedException {
|
||||
TestApplicationEventPublisher publisher = new TestApplicationEventPublisher();
|
||||
ApplicationEventPublishingMessageConsumer consumer = new ApplicationEventPublishingMessageConsumer();
|
||||
consumer.setApplicationEventPublisher(publisher);
|
||||
ApplicationEventPublishingMessageHandler handler = new ApplicationEventPublishingMessageHandler();
|
||||
handler.setApplicationEventPublisher(publisher);
|
||||
assertNull(publisher.getLastEvent());
|
||||
Message<?> message = new StringMessage("testing");
|
||||
consumer.onMessage(message);
|
||||
handler.handleMessage(message);
|
||||
ApplicationEvent event = publisher.getLastEvent();
|
||||
assertEquals(MessagingEvent.class, event.getClass());
|
||||
assertEquals(message, ((MessagingEvent) event).getMessage());
|
||||
@@ -22,20 +22,20 @@ import java.io.OutputStreamWriter;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
/**
|
||||
* A {@link MessageConsumer} implementation that writes the Message payload to a
|
||||
* A {@link MessageHandler} implementation that writes the Message payload to a
|
||||
* file. If the payload is a File object, it will copy the File to this
|
||||
* consumer's directory. If the payload is a byte array or String, it will
|
||||
* write it directly. Otherwise, it will invoke toString on the payload Object.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FileWritingMessageConsumer implements MessageConsumer {
|
||||
public class FileWritingMessageHandler implements MessageHandler {
|
||||
|
||||
private volatile FileNameGenerator fileNameGenerator = new DefaultFileNameGenerator();
|
||||
|
||||
@@ -44,11 +44,11 @@ public class FileWritingMessageConsumer implements MessageConsumer {
|
||||
private volatile Charset charset = Charset.defaultCharset();
|
||||
|
||||
|
||||
public FileWritingMessageConsumer(String parentDirectoryPath) {
|
||||
public FileWritingMessageHandler(String parentDirectoryPath) {
|
||||
this(new File(parentDirectoryPath));
|
||||
}
|
||||
|
||||
public FileWritingMessageConsumer(File parentDirectory) {
|
||||
public FileWritingMessageHandler(File parentDirectory) {
|
||||
this.parentDirectory = parentDirectory;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public class FileWritingMessageConsumer implements MessageConsumer {
|
||||
this.charset = Charset.forName(charset);
|
||||
}
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
Assert.notNull(message, "message must not be null");
|
||||
Object payload = message.getPayload();
|
||||
Assert.notNull(payload, "message payload must not be null");
|
||||
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.file.FileWritingMessageConsumer;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class FileOutboundChannelAdapterParser extends AbstractOutboundChannelAda
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
String directory = element.getAttribute("directory");
|
||||
Assert.hasText(directory, "directory is required");
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FileWritingMessageConsumer.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FileWritingMessageHandler.class);
|
||||
builder.addConstructorArgValue(directory);
|
||||
String fileNameGenerator = element.getAttribute("filename-generator");
|
||||
if (StringUtils.hasText(fileNameGenerator)) {
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
import org.springframework.integration.file.DefaultFileNameGenerator;
|
||||
import org.springframework.integration.file.FileWritingMessageConsumer;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@@ -53,23 +53,23 @@ public class FileOutboundChannelAdapterParserTests {
|
||||
@Test
|
||||
public void simpleAdapter() {
|
||||
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(simpleAdapter);
|
||||
FileWritingMessageConsumer consumer = (FileWritingMessageConsumer)
|
||||
adapterAccessor.getPropertyValue("consumer");
|
||||
DirectFieldAccessor consumerAccessor = new DirectFieldAccessor(consumer);
|
||||
FileWritingMessageHandler handler = (FileWritingMessageHandler)
|
||||
adapterAccessor.getPropertyValue("handler");
|
||||
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
|
||||
assertEquals(System.getProperty("java.io.tmpdir"),
|
||||
((File) consumerAccessor.getPropertyValue("parentDirectory")).getAbsolutePath());
|
||||
assertTrue(consumerAccessor.getPropertyValue("fileNameGenerator") instanceof DefaultFileNameGenerator);
|
||||
((File) handlerAccessor.getPropertyValue("parentDirectory")).getAbsolutePath());
|
||||
assertTrue(handlerAccessor.getPropertyValue("fileNameGenerator") instanceof DefaultFileNameGenerator);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void adapterWithCustomFileNameGenerator() {
|
||||
DirectFieldAccessor adapterAccessor = new DirectFieldAccessor(adapterWithCustomNameGenerator);
|
||||
FileWritingMessageConsumer consumer = (FileWritingMessageConsumer)
|
||||
adapterAccessor.getPropertyValue("consumer");
|
||||
DirectFieldAccessor consumerAccessor = new DirectFieldAccessor(consumer);
|
||||
FileWritingMessageHandler handler = (FileWritingMessageHandler)
|
||||
adapterAccessor.getPropertyValue("handler");
|
||||
DirectFieldAccessor handlerAccessor = new DirectFieldAccessor(handler);
|
||||
assertEquals(System.getProperty("java.io.tmpdir"),
|
||||
((File) consumerAccessor.getPropertyValue("parentDirectory")).getAbsolutePath());
|
||||
assertTrue(consumerAccessor.getPropertyValue("fileNameGenerator") instanceof CustomFileNameGenerator);
|
||||
((File) handlerAccessor.getPropertyValue("parentDirectory")).getAbsolutePath());
|
||||
assertTrue(handlerAccessor.getPropertyValue("fileNameGenerator") instanceof CustomFileNameGenerator);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,28 +24,28 @@ import java.io.IOException;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link MessageConsumer} implementation that sends files to an FTP server.
|
||||
* A {@link MessageHandler} implementation that sends files to an FTP server.
|
||||
*
|
||||
* @author Iwein Fuld
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class FtpSendingMessageConsumer implements MessageConsumer {
|
||||
public class FtpSendingMessageHandler implements MessageHandler {
|
||||
|
||||
private final FTPClientPool ftpClientPool;
|
||||
|
||||
|
||||
public FtpSendingMessageConsumer(FTPClientPool ftpClientPool) {
|
||||
public FtpSendingMessageHandler(FTPClientPool ftpClientPool) {
|
||||
Assert.notNull(ftpClientPool, "ftpClientPool must not be null");
|
||||
this.ftpClientPool = ftpClientPool;
|
||||
}
|
||||
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
Assert.notNull(message, "message must not be null");
|
||||
Object payload = message.getPayload();
|
||||
Assert.notNull(payload, "message payload must not be null");
|
||||
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.ftp.FtpSendingMessageConsumer;
|
||||
import org.springframework.integration.ftp.FtpSendingMessageHandler;
|
||||
import org.springframework.integration.ftp.QueuedFTPClientPool;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class FtpOutboundChannelAdapterParser extends AbstractOutboundChannelAdap
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FtpSendingMessageConsumer.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(FtpSendingMessageHandler.class);
|
||||
String username = element.getAttribute("username");
|
||||
String password = element.getAttribute("password");
|
||||
String host = element.getAttribute("host");
|
||||
|
||||
@@ -38,10 +38,9 @@ import org.springframework.integration.message.MessageDeliveryException;
|
||||
* @author Iwein Fuld
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class FtpSendingMessageConsumerTests {
|
||||
public class FtpSendingMessageHandlerTests {
|
||||
|
||||
private FtpSendingMessageConsumer consumer;
|
||||
private FtpSendingMessageHandler handler;
|
||||
|
||||
private FTPClient ftpClient = createMock(FTPClient.class);
|
||||
|
||||
@@ -66,7 +65,7 @@ public class FtpSendingMessageConsumerTests {
|
||||
|
||||
@Before
|
||||
public void intitializeSubject() {
|
||||
this.consumer = new FtpSendingMessageConsumer(ftpClientPool);
|
||||
this.handler = new FtpSendingMessageHandler(ftpClientPool);
|
||||
}
|
||||
|
||||
|
||||
@@ -77,7 +76,7 @@ public class FtpSendingMessageConsumerTests {
|
||||
Message<?> message = new GenericMessage<File>(File.createTempFile("test", ".tmp"));
|
||||
expect(ftpClient.storeFile(isA(String.class), isA(FileInputStream.class))).andReturn(true);
|
||||
replay(allMocks);
|
||||
consumer.onMessage(message);
|
||||
handler.handleMessage(message);
|
||||
verify(allMocks);
|
||||
}
|
||||
|
||||
@@ -86,7 +85,7 @@ public class FtpSendingMessageConsumerTests {
|
||||
Message<?> message = new GenericMessage<File>(File.createTempFile("test", ".tmp"));
|
||||
expect(ftpClient.storeFile(isA(String.class), isA(FileInputStream.class))).andReturn(false);
|
||||
replay(allMocks);
|
||||
consumer.onMessage(message);
|
||||
handler.handleMessage(message);
|
||||
verify(allMocks);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.ftp.FtpSendingMessageConsumer;
|
||||
import org.springframework.integration.ftp.FtpSendingMessageHandler;
|
||||
import org.springframework.integration.ftp.QueuedFTPClientPool;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.springframework.integration.message.GenericMessage;
|
||||
@Ignore
|
||||
public class FtpSendingMessageConsumerIntegrationTests {
|
||||
|
||||
private FtpSendingMessageConsumer consumer;
|
||||
private FtpSendingMessageHandler handler;
|
||||
|
||||
@Before
|
||||
public void initFtpTarget() {
|
||||
@@ -44,13 +44,13 @@ public class FtpSendingMessageConsumerIntegrationTests {
|
||||
clientPool.setUsername("ftp-user");
|
||||
clientPool.setPassword("kaas");
|
||||
clientPool.setRemoteWorkingDirectory("ftp-test");
|
||||
consumer = new FtpSendingMessageConsumer(clientPool);
|
||||
handler = new FtpSendingMessageHandler(clientPool);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void send() throws Exception {
|
||||
File file = File.createTempFile("test", "");
|
||||
consumer.onMessage(new GenericMessage<File>(file));
|
||||
handler.handleMessage(new GenericMessage<File>(file));
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
||||
@@ -37,7 +37,7 @@ public class HttpInvokerOutboundGatewayParserTests {
|
||||
"httpInvokerOutboundGatewayParserTests.xml", this.getClass());
|
||||
Object endpoint = context.getBean("gateway");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(HttpInvokerOutboundGateway.class, gateway.getClass());
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import javax.jms.QueueSession;
|
||||
import javax.jms.Session;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -42,7 +42,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsOutboundGateway extends AbstractReplyProducingMessageConsumer implements InitializingBean {
|
||||
public class JmsOutboundGateway extends AbstractReplyProducingMessageHandler implements InitializingBean {
|
||||
|
||||
private volatile Queue jmsQueue;
|
||||
|
||||
@@ -74,7 +74,7 @@ public class JmsOutboundGateway extends AbstractReplyProducingMessageConsumer im
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMessage(final Message<?> message, final ReplyMessageHolder replyMessageHolder) {
|
||||
protected void handleRequestMessage(final Message<?> message, final ReplyMessageHolder replyMessageHolder) {
|
||||
final Message<?> requestMessage = MessageBuilder.fromMessage(message).build();
|
||||
this.jmsTemplate.execute(new SessionCallback() {
|
||||
public Object doInJms(Session session) throws JMSException {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.jms;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* A MessageConsumer that sends the converted Message payload within
|
||||
@@ -25,9 +25,9 @@ import org.springframework.integration.message.MessageConsumer;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class JmsSendingMessageConsumer extends AbstractJmsTemplateBasedAdapter implements MessageConsumer {
|
||||
public class JmsSendingMessageHandler extends AbstractJmsTemplateBasedAdapter implements MessageHandler {
|
||||
|
||||
public final void onMessage(final Message<?> message) {
|
||||
public final void handleMessage(final Message<?> message) {
|
||||
if (message == null) {
|
||||
throw new IllegalArgumentException("message must not be null");
|
||||
}
|
||||
@@ -23,7 +23,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.jms.JmsSendingMessageConsumer;
|
||||
import org.springframework.integration.jms.JmsSendingMessageHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class JmsOutboundChannelAdapterParser extends AbstractOutboundChannelAdap
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JmsSendingMessageConsumer.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(JmsSendingMessageHandler.class);
|
||||
String jmsTemplate = element.getAttribute(JmsAdapterParserUtils.JMS_TEMPLATE_ATTRIBUTE);
|
||||
String destination = element.getAttribute(JmsAdapterParserUtils.DESTINATION_ATTRIBUTE);
|
||||
String destinationName = element.getAttribute(JmsAdapterParserUtils.DESTINATION_NAME_ATTRIBUTE);
|
||||
|
||||
@@ -39,7 +39,7 @@ public class JmsOutboundChannelAdapterParserTests {
|
||||
"jmsOutboundWithConnectionFactoryAndDestination.xml", this.getClass());
|
||||
SubscribingConsumerEndpoint endpoint = (SubscribingConsumerEndpoint) context.getBean("adapter");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("consumer"));
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
|
||||
assertNotNull(accessor.getPropertyValue("jmsTemplate"));
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ public class JmsOutboundChannelAdapterParserTests {
|
||||
"jmsOutboundWithConnectionFactoryAndDestinationName.xml", this.getClass());
|
||||
SubscribingConsumerEndpoint endpoint = (SubscribingConsumerEndpoint) context.getBean("adapter");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("consumer"));
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
|
||||
assertNotNull(accessor.getPropertyValue("jmsTemplate"));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class JmsOutboundChannelAdapterParserTests {
|
||||
"jmsOutboundWithDefaultConnectionFactory.xml", this.getClass());
|
||||
SubscribingConsumerEndpoint endpoint = (SubscribingConsumerEndpoint) context.getBean("adapter");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("consumer"));
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
|
||||
assertNotNull(accessor.getPropertyValue("jmsTemplate"));
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ public class JmsOutboundChannelAdapterParserTests {
|
||||
"jmsOutboundWithHeaderMapper.xml", this.getClass());
|
||||
SubscribingConsumerEndpoint endpoint = (SubscribingConsumerEndpoint) context.getBean("adapter");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("consumer"));
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("handler"));
|
||||
JmsHeaderMapper headerMapper = (JmsHeaderMapper) accessor.getPropertyValue("headerMapper");
|
||||
assertNotNull(headerMapper);
|
||||
assertEquals(TestJmsHeaderMapper.class, headerMapper.getClass());
|
||||
|
||||
@@ -34,7 +34,7 @@ public class JmsOutboundGatewayParserTests {
|
||||
PollingConsumerEndpoint endpoint = (PollingConsumerEndpoint) context.getBean("jmsGateway");
|
||||
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(endpoint);
|
||||
JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("consumer");
|
||||
JmsOutboundGateway gateway = (JmsOutboundGateway) accessor.getPropertyValue("handler");
|
||||
accessor = new DirectFieldAccessor(gateway);
|
||||
MessageConverter converter = (MessageConverter)accessor.getPropertyValue("messageConverter");
|
||||
assertTrue("Wrong mesage converter", converter instanceof StubMessageConverter);
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.core.io.ByteArrayResource;
|
||||
import org.springframework.integration.adapter.MessageMappingException;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.mail.MailMessage;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
@@ -33,7 +33,7 @@ import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A {@link MessageConsumer} implementation for sending mail.
|
||||
* A {@link MessageHandler} implementation for sending mail.
|
||||
*
|
||||
* <p>If the Message is an instance of {@link MailMessage}, it will be passed
|
||||
* as-is. If the Message payload is a byte array, it will be passed as an
|
||||
@@ -47,7 +47,7 @@ import org.springframework.util.StringUtils;
|
||||
* @author Marius Bogoevici
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MailSendingMessageConsumer implements MessageConsumer {
|
||||
public class MailSendingMessageHandler implements MessageHandler {
|
||||
|
||||
private final JavaMailSender mailSender;
|
||||
|
||||
@@ -58,13 +58,13 @@ public class MailSendingMessageConsumer implements MessageConsumer {
|
||||
* @param mailSender the {@link JavaMailSender} instance to which this
|
||||
* adapter will delegate.
|
||||
*/
|
||||
public MailSendingMessageConsumer(JavaMailSender mailSender) {
|
||||
public MailSendingMessageHandler(JavaMailSender mailSender) {
|
||||
Assert.notNull(mailSender, "'mailSender' must not be null");
|
||||
this.mailSender = mailSender;
|
||||
}
|
||||
|
||||
|
||||
public final void onMessage(Message<?> message) {
|
||||
public final void handleMessage(Message<?> message) {
|
||||
MailMessage mailMessage = this.convertMessageToMailMessage(message);
|
||||
if (mailMessage instanceof SimpleMailMessage) {
|
||||
this.mailSender.send((SimpleMailMessage) mailMessage);
|
||||
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.support.BeanDefinitionReaderUtils;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.config.xml.IntegrationNamespaceUtils;
|
||||
import org.springframework.integration.mail.MailSendingMessageConsumer;
|
||||
import org.springframework.integration.mail.MailSendingMessageHandler;
|
||||
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -38,7 +38,7 @@ public class MailOutboundChannelAdapterParser extends AbstractOutboundChannelAda
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MailSendingMessageConsumer.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MailSendingMessageHandler.class);
|
||||
String mailSenderRef = element.getAttribute("mail-sender");
|
||||
String host = element.getAttribute("host");
|
||||
String port = element.getAttribute("port");
|
||||
|
||||
@@ -42,11 +42,11 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
@RunWith(value = SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = {"classpath:/org/springframework/integration/mail/mailSendingMessageConsumerContextTests.xml"})
|
||||
public class MailSendingMessageConsumerContextTests {
|
||||
@ContextConfiguration(locations = {"classpath:/org/springframework/integration/mail/mailSendingMessageHandlerContextTests.xml"})
|
||||
public class MailSendingMessageHandlerContextTests {
|
||||
|
||||
@Autowired
|
||||
private MailSendingMessageConsumer consumer;
|
||||
private MailSendingMessageHandler handler;
|
||||
|
||||
@Autowired
|
||||
private StubJavaMailSender mailSender;
|
||||
@@ -59,7 +59,7 @@ public class MailSendingMessageConsumerContextTests {
|
||||
|
||||
@Test
|
||||
public void stringMesssagesWithConfiguration() {
|
||||
this.consumer.onMessage(MailTestsHelper.createIntegrationMessage());
|
||||
this.handler.handleMessage(MailTestsHelper.createIntegrationMessage());
|
||||
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
|
||||
assertEquals("no mime message should have been sent",
|
||||
0, this.mailSender.getSentMimeMessages().size());
|
||||
@@ -77,7 +77,7 @@ public class MailSendingMessageConsumerContextTests {
|
||||
.setHeader(MailHeaders.ATTACHMENT_FILENAME, "attachment.txt")
|
||||
.setHeader(MailHeaders.TO, MailTestsHelper.TO)
|
||||
.build();
|
||||
this.consumer.onMessage(message);
|
||||
this.handler.handleMessage(message);
|
||||
assertEquals("no mime message should have been sent",
|
||||
1, this.mailSender.getSentMimeMessages().size());
|
||||
assertEquals("only one simple message must be sent",
|
||||
@@ -96,7 +96,7 @@ public class MailSendingMessageConsumerContextTests {
|
||||
@Test(expected = MessageMappingException.class)
|
||||
public void byteArrayMessageWithoutAttachmentFileName() throws Exception {
|
||||
byte[] payload = {1, 2, 3};
|
||||
this.consumer.onMessage(new GenericMessage<byte[]>(payload));
|
||||
this.handler.handleMessage(new GenericMessage<byte[]>(payload));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -37,9 +37,9 @@ import org.springframework.mail.SimpleMailMessage;
|
||||
/**
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class MailSendingMessageConsumerTests {
|
||||
public class MailSendingMessageHandlerTests {
|
||||
|
||||
private MailSendingMessageConsumer consumer;
|
||||
private MailSendingMessageHandler handler;
|
||||
|
||||
private StubJavaMailSender mailSender;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MailSendingMessageConsumerTests {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
this.mailSender = new StubJavaMailSender(new MimeMessage((Session) null));
|
||||
this.consumer = new MailSendingMessageConsumer(this.mailSender);
|
||||
this.handler = new MailSendingMessageHandler(this.mailSender);
|
||||
}
|
||||
|
||||
@After
|
||||
@@ -58,7 +58,7 @@ public class MailSendingMessageConsumerTests {
|
||||
|
||||
@Test
|
||||
public void textMessage() {
|
||||
this.consumer.onMessage(MailTestsHelper.createIntegrationMessage());
|
||||
this.handler.handleMessage(MailTestsHelper.createIntegrationMessage());
|
||||
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
|
||||
assertEquals("no mime message should have been sent",
|
||||
0, mailSender.getSentMimeMessages().size());
|
||||
@@ -76,7 +76,7 @@ public class MailSendingMessageConsumerTests {
|
||||
.setHeader(MailHeaders.ATTACHMENT_FILENAME, "attachment.txt")
|
||||
.setHeader(MailHeaders.TO, MailTestsHelper.TO)
|
||||
.build();
|
||||
this.consumer.onMessage(message);
|
||||
this.handler.handleMessage(message);
|
||||
byte[] buffer = new byte[1024];
|
||||
MimeMessage mimeMessage = this.mailSender.getSentMimeMessages().get(0);
|
||||
assertTrue("message must be multipart", mimeMessage.getContent() instanceof Multipart);
|
||||
@@ -90,7 +90,7 @@ public class MailSendingMessageConsumerTests {
|
||||
|
||||
@Test
|
||||
public void mailHeaders() {
|
||||
this.consumer.onMessage(MailTestsHelper.createIntegrationMessage());
|
||||
this.handler.handleMessage(MailTestsHelper.createIntegrationMessage());
|
||||
SimpleMailMessage mailMessage = MailTestsHelper.createSimpleMailMessage();
|
||||
assertEquals("no mime message should have been sent",
|
||||
0, mailSender.getSentMimeMessages().size());
|
||||
@@ -23,7 +23,7 @@ import org.junit.Test;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.mail.MailSendingMessageConsumer;
|
||||
import org.springframework.integration.mail.MailSendingMessageHandler;
|
||||
import org.springframework.mail.MailSender;
|
||||
|
||||
/**
|
||||
@@ -36,9 +36,9 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailOutboundChannelAdapterParserTests.xml", this.getClass());
|
||||
Object adapter = context.getBean("adapterWithMailSenderReference.adapter");
|
||||
MailSendingMessageConsumer consumer = (MailSendingMessageConsumer)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("consumer");
|
||||
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(consumer);
|
||||
MailSendingMessageHandler handler = (MailSendingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(handler);
|
||||
MailSender mailSender = (MailSender) fieldAccessor.getPropertyValue("mailSender");
|
||||
assertNotNull(mailSender);
|
||||
}
|
||||
@@ -48,9 +48,9 @@ public class MailOutboundChannelAdapterParserTests {
|
||||
ApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"mailOutboundChannelAdapterParserTests.xml", this.getClass());
|
||||
Object adapter = context.getBean("adapterWithHostProperty.adapter");
|
||||
MailSendingMessageConsumer consumer = (MailSendingMessageConsumer)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("consumer");
|
||||
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(consumer);
|
||||
MailSendingMessageHandler handler = (MailSendingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
DirectFieldAccessor fieldAccessor = new DirectFieldAccessor(handler);
|
||||
MailSender mailSender = (MailSender) fieldAccessor.getPropertyValue("mailSender");
|
||||
assertNotNull(mailSender);
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<bean id="mailSendingMessageConsumer" class="org.springframework.integration.mail.MailSendingMessageConsumer">
|
||||
<bean id="mailSendingMessageConsumer" class="org.springframework.integration.mail.MailSendingMessageHandler">
|
||||
<constructor-arg ref="javaMailSender"/>
|
||||
</bean>
|
||||
|
||||
@@ -63,7 +63,7 @@ public class RmiOutboundGatewayTests {
|
||||
|
||||
@Test
|
||||
public void serializablePayload() throws RemoteException {
|
||||
gateway.onMessage(new StringMessage("test"));
|
||||
gateway.handleMessage(new StringMessage("test"));
|
||||
Message<?> replyMessage = output.receive(0);
|
||||
assertNotNull(replyMessage);
|
||||
assertEquals("TEST", replyMessage.getPayload());
|
||||
@@ -73,7 +73,7 @@ public class RmiOutboundGatewayTests {
|
||||
public void serializableAttribute() throws RemoteException {
|
||||
Message<String> requestMessage = MessageBuilder.withPayload("test")
|
||||
.setHeader("testAttribute", "foo").build();
|
||||
gateway.onMessage(requestMessage);
|
||||
gateway.handleMessage(requestMessage);
|
||||
Message<?> replyMessage = output.receive(0);
|
||||
assertNotNull(replyMessage);
|
||||
assertEquals("foo", replyMessage.getHeaders().get("testAttribute"));
|
||||
@@ -83,14 +83,14 @@ public class RmiOutboundGatewayTests {
|
||||
public void nonSerializablePayload() throws RemoteException {
|
||||
NonSerializableTestObject payload = new NonSerializableTestObject();
|
||||
Message<?> requestMessage = new GenericMessage<NonSerializableTestObject>(payload);
|
||||
gateway.onMessage(requestMessage);
|
||||
gateway.handleMessage(requestMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonSerializableAttribute() throws RemoteException {
|
||||
Message<String> requestMessage = MessageBuilder.withPayload("test")
|
||||
.setHeader("testAttribute", new NonSerializableTestObject()).build();
|
||||
gateway.onMessage(requestMessage);
|
||||
gateway.handleMessage(requestMessage);
|
||||
Message<?> reply = output.receive(0);
|
||||
assertNotNull(requestMessage.getHeaders().get("testAttribute"));
|
||||
assertNotNull(reply.getHeaders().get("testAttribute"));
|
||||
@@ -101,7 +101,7 @@ public class RmiOutboundGatewayTests {
|
||||
RmiOutboundGateway gateway = new RmiOutboundGateway("rmi://localhost:1099/noSuchService");
|
||||
boolean exceptionThrown = false;
|
||||
try {
|
||||
gateway.onMessage(new StringMessage("test"));
|
||||
gateway.handleMessage(new StringMessage("test"));
|
||||
}
|
||||
catch (MessageHandlingException e) {
|
||||
assertEquals(RemoteLookupFailureException.class, e.getCause().getClass());
|
||||
@@ -115,7 +115,7 @@ public class RmiOutboundGatewayTests {
|
||||
RmiOutboundGateway gateway = new RmiOutboundGateway("rmi://noSuchHost:1099/testRemoteHandler");
|
||||
boolean exceptionThrown = false;
|
||||
try {
|
||||
gateway.onMessage(new StringMessage("test"));
|
||||
gateway.handleMessage(new StringMessage("test"));
|
||||
}
|
||||
catch (MessageHandlingException e) {
|
||||
assertEquals(RemoteLookupFailureException.class, e.getCause().getClass());
|
||||
@@ -129,7 +129,7 @@ public class RmiOutboundGatewayTests {
|
||||
RmiOutboundGateway gateway = new RmiOutboundGateway("invalid");
|
||||
boolean exceptionThrown = false;
|
||||
try {
|
||||
gateway.onMessage(new StringMessage("test"));
|
||||
gateway.handleMessage(new StringMessage("test"));
|
||||
}
|
||||
catch (MessageHandlingException e) {
|
||||
assertEquals(RemoteLookupFailureException.class, e.getCause().getClass());
|
||||
|
||||
@@ -24,10 +24,10 @@
|
||||
<si-security:access-policy pattern="secured.*" send-access="ROLE_ADMIN"/>
|
||||
</si-security:secured-channels>
|
||||
|
||||
<beans:bean id="testConsumer" class="org.springframework.integration.security.channel.TestConsumer"/>
|
||||
<beans:bean id="testHandler" class="org.springframework.integration.security.channel.TestHandler"/>
|
||||
|
||||
<outbound-channel-adapter id="securedChannelAdapter" ref="testConsumer"/>
|
||||
<outbound-channel-adapter id="securedChannelAdapter" ref="testHandler"/>
|
||||
|
||||
<outbound-channel-adapter id="unsecuredChannelAdapter" ref="testConsumer"/>
|
||||
<outbound-channel-adapter id="unsecuredChannelAdapter" ref="testHandler"/>
|
||||
|
||||
</beans:beans>
|
||||
@@ -49,7 +49,7 @@ public class ChannelAdapterSecurityIntegrationTests extends AbstractJUnit4Spring
|
||||
MessageChannel unsecuredChannelAdapter;
|
||||
|
||||
@Autowired
|
||||
TestConsumer testConsumer;
|
||||
TestHandler testConsumer;
|
||||
|
||||
|
||||
@After
|
||||
|
||||
@@ -20,16 +20,16 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class TestConsumer implements MessageConsumer {
|
||||
public class TestHandler implements MessageHandler {
|
||||
|
||||
public List<Message<?>> sentMessages = new ArrayList<Message<?>>();
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
sentMessages.add(message);
|
||||
}
|
||||
|
||||
@@ -25,25 +25,25 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* A {@link MessageConsumer} that writes a byte array to an {@link OutputStream}.
|
||||
* A {@link MessageHandler} that writes a byte array to an {@link OutputStream}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ByteStreamWritingMessageConsumer implements MessageConsumer {
|
||||
public class ByteStreamWritingMessageHandler implements MessageHandler {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private final BufferedOutputStream stream;
|
||||
|
||||
|
||||
public ByteStreamWritingMessageConsumer(OutputStream stream) {
|
||||
public ByteStreamWritingMessageHandler(OutputStream stream) {
|
||||
this(stream, -1);
|
||||
}
|
||||
|
||||
public ByteStreamWritingMessageConsumer(OutputStream stream, int bufferSize) {
|
||||
public ByteStreamWritingMessageHandler(OutputStream stream, int bufferSize) {
|
||||
if (bufferSize > 0) {
|
||||
this.stream = new BufferedOutputStream(stream, bufferSize);
|
||||
}
|
||||
@@ -53,7 +53,7 @@ public class ByteStreamWritingMessageConsumer implements MessageConsumer {
|
||||
}
|
||||
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
Object payload = message.getPayload();
|
||||
if (payload == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
@@ -28,11 +28,11 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link MessageConsumer} that writes characters to a {@link Writer}.
|
||||
* A {@link MessageHandler} that writes characters to a {@link Writer}.
|
||||
* String, character array, and byte array payloads will be written directly,
|
||||
* but for other payload types, the result of the object's {@link #toString()}
|
||||
* method will be written. To append a new-line after each write, set the
|
||||
@@ -40,7 +40,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class CharacterStreamWritingMessageConsumer implements MessageConsumer {
|
||||
public class CharacterStreamWritingMessageHandler implements MessageHandler {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -49,11 +49,11 @@ public class CharacterStreamWritingMessageConsumer implements MessageConsumer {
|
||||
private volatile boolean shouldAppendNewLine = false;
|
||||
|
||||
|
||||
public CharacterStreamWritingMessageConsumer(Writer writer) {
|
||||
public CharacterStreamWritingMessageHandler(Writer writer) {
|
||||
this(writer, -1);
|
||||
}
|
||||
|
||||
public CharacterStreamWritingMessageConsumer(Writer writer, int bufferSize) {
|
||||
public CharacterStreamWritingMessageHandler(Writer writer, int bufferSize) {
|
||||
Assert.notNull(writer, "writer must not be null");
|
||||
if (writer instanceof BufferedWriter) {
|
||||
this.writer = (BufferedWriter) writer;
|
||||
@@ -71,7 +71,7 @@ public class CharacterStreamWritingMessageConsumer implements MessageConsumer {
|
||||
* Factory method that creates a target for stdout (System.out) with the
|
||||
* default charset encoding.
|
||||
*/
|
||||
public static CharacterStreamWritingMessageConsumer stdout() {
|
||||
public static CharacterStreamWritingMessageHandler stdout() {
|
||||
return stdout(null);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class CharacterStreamWritingMessageConsumer implements MessageConsumer {
|
||||
* Factory method that creates a target for stdout (System.out) with the
|
||||
* specified charset encoding.
|
||||
*/
|
||||
public static CharacterStreamWritingMessageConsumer stdout(String charsetName) {
|
||||
public static CharacterStreamWritingMessageHandler stdout(String charsetName) {
|
||||
return createTargetForStream(System.out, charsetName);
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ public class CharacterStreamWritingMessageConsumer implements MessageConsumer {
|
||||
* Factory method that creates a target for stderr (System.err) with the
|
||||
* default charset encoding.
|
||||
*/
|
||||
public static CharacterStreamWritingMessageConsumer stderr() {
|
||||
public static CharacterStreamWritingMessageHandler stderr() {
|
||||
return stderr(null);
|
||||
}
|
||||
|
||||
@@ -95,16 +95,16 @@ public class CharacterStreamWritingMessageConsumer implements MessageConsumer {
|
||||
* Factory method that creates a target for stderr (System.err) with the
|
||||
* specified charset encoding.
|
||||
*/
|
||||
public static CharacterStreamWritingMessageConsumer stderr(String charsetName) {
|
||||
public static CharacterStreamWritingMessageHandler stderr(String charsetName) {
|
||||
return createTargetForStream(System.err, charsetName);
|
||||
}
|
||||
|
||||
private static CharacterStreamWritingMessageConsumer createTargetForStream(OutputStream stream, String charsetName) {
|
||||
private static CharacterStreamWritingMessageHandler createTargetForStream(OutputStream stream, String charsetName) {
|
||||
if (charsetName == null) {
|
||||
return new CharacterStreamWritingMessageConsumer(new OutputStreamWriter(stream));
|
||||
return new CharacterStreamWritingMessageHandler(new OutputStreamWriter(stream));
|
||||
}
|
||||
try {
|
||||
return new CharacterStreamWritingMessageConsumer(new OutputStreamWriter(stream, charsetName));
|
||||
return new CharacterStreamWritingMessageHandler(new OutputStreamWriter(stream, charsetName));
|
||||
}
|
||||
catch (UnsupportedEncodingException e) {
|
||||
throw new IllegalArgumentException("unsupported encoding: " + charsetName, e);
|
||||
@@ -116,7 +116,7 @@ public class CharacterStreamWritingMessageConsumer implements MessageConsumer {
|
||||
this.shouldAppendNewLine = shouldAppendNewLine;
|
||||
}
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
Object payload = message.getPayload();
|
||||
if (payload == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.config.xml.AbstractOutboundChannelAdapterParser;
|
||||
import org.springframework.integration.stream.CharacterStreamWritingMessageConsumer;
|
||||
import org.springframework.integration.stream.CharacterStreamWritingMessageHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public class ConsoleOutboundChannelAdapterParser extends AbstractOutboundChannel
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(
|
||||
CharacterStreamWritingMessageConsumer.class);
|
||||
CharacterStreamWritingMessageHandler.class);
|
||||
if (element.getLocalName().startsWith("stderr")) {
|
||||
builder.setFactoryMethod("stderr");
|
||||
}
|
||||
|
||||
@@ -40,11 +40,11 @@ import org.springframework.integration.scheduling.Trigger;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ByteStreamWritingMessageConsumerTests {
|
||||
public class ByteStreamWritingMessageHandlerTests {
|
||||
|
||||
private ByteArrayOutputStream stream;
|
||||
|
||||
private ByteStreamWritingMessageConsumer consumer;
|
||||
private ByteStreamWritingMessageHandler handler;
|
||||
|
||||
private QueueChannel channel;
|
||||
|
||||
@@ -58,9 +58,9 @@ public class ByteStreamWritingMessageConsumerTests {
|
||||
@Before
|
||||
public void initialize() {
|
||||
stream = new ByteArrayOutputStream();
|
||||
consumer = new ByteStreamWritingMessageConsumer(stream);
|
||||
handler = new ByteStreamWritingMessageHandler(stream);
|
||||
this.channel = new QueueChannel(10);
|
||||
this.endpoint = new PollingConsumerEndpoint(consumer, channel);
|
||||
this.endpoint = new PollingConsumerEndpoint(channel, handler);
|
||||
scheduler = new SimpleTaskScheduler(new SimpleAsyncTaskExecutor());
|
||||
this.endpoint.setTaskScheduler(scheduler);
|
||||
scheduler.start();
|
||||
@@ -76,7 +76,7 @@ public class ByteStreamWritingMessageConsumerTests {
|
||||
|
||||
@Test
|
||||
public void singleByteArray() {
|
||||
consumer.onMessage(new GenericMessage<byte[]>(new byte[] {1,2,3}));
|
||||
handler.handleMessage(new GenericMessage<byte[]>(new byte[] {1,2,3}));
|
||||
byte[] result = stream.toByteArray();
|
||||
assertEquals(3, result.length);
|
||||
assertEquals(1, result[0]);
|
||||
@@ -86,7 +86,7 @@ public class ByteStreamWritingMessageConsumerTests {
|
||||
|
||||
@Test
|
||||
public void singleString() {
|
||||
consumer.onMessage(new StringMessage("foo"));
|
||||
handler.handleMessage(new StringMessage("foo"));
|
||||
byte[] result = stream.toByteArray();
|
||||
assertEquals(3, result.length);
|
||||
assertEquals("foo", new String(result));
|
||||
@@ -39,11 +39,11 @@ import org.springframework.integration.scheduling.Trigger;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class CharacterStreamWritingMessageConsumerTests {
|
||||
public class CharacterStreamWritingMessageHandlerTests {
|
||||
|
||||
private StringWriter writer;
|
||||
|
||||
private CharacterStreamWritingMessageConsumer consumer;
|
||||
private CharacterStreamWritingMessageHandler handler;
|
||||
|
||||
private QueueChannel channel;
|
||||
|
||||
@@ -57,10 +57,10 @@ public class CharacterStreamWritingMessageConsumerTests {
|
||||
@Before
|
||||
public void initialize() {
|
||||
writer = new StringWriter();
|
||||
consumer = new CharacterStreamWritingMessageConsumer(writer);
|
||||
handler = new CharacterStreamWritingMessageHandler(writer);
|
||||
this.channel = new QueueChannel(10);
|
||||
trigger.reset();
|
||||
this.endpoint = new PollingConsumerEndpoint(consumer, channel);
|
||||
this.endpoint = new PollingConsumerEndpoint(channel, handler);
|
||||
scheduler = new SimpleTaskScheduler(new SimpleAsyncTaskExecutor());
|
||||
this.endpoint.setTaskScheduler(scheduler);
|
||||
scheduler.start();
|
||||
@@ -76,7 +76,7 @@ public class CharacterStreamWritingMessageConsumerTests {
|
||||
|
||||
@Test
|
||||
public void singleString() {
|
||||
consumer.onMessage(new StringMessage("foo"));
|
||||
handler.handleMessage(new StringMessage("foo"));
|
||||
assertEquals("foo", writer.toString());
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class CharacterStreamWritingMessageConsumerTests {
|
||||
|
||||
@Test
|
||||
public void twoStringsWithNewLines() {
|
||||
consumer.setShouldAppendNewLine(true);
|
||||
handler.setShouldAppendNewLine(true);
|
||||
endpoint.setMaxMessagesPerPoll(1);
|
||||
channel.send(new StringMessage("foo"), 0);
|
||||
channel.send(new StringMessage("bar"), 0);
|
||||
@@ -129,7 +129,7 @@ public class CharacterStreamWritingMessageConsumerTests {
|
||||
public void maxMessagesPerTaskExceedsMessageCountWithAppendedNewLines() {
|
||||
endpoint.setMaxMessagesPerPoll(10);
|
||||
endpoint.setReceiveTimeout(0);
|
||||
consumer.setShouldAppendNewLine(true);
|
||||
handler.setShouldAppendNewLine(true);
|
||||
channel.send(new StringMessage("foo"), 0);
|
||||
channel.send(new StringMessage("bar"), 0);
|
||||
endpoint.start();
|
||||
@@ -166,7 +166,7 @@ public class CharacterStreamWritingMessageConsumerTests {
|
||||
|
||||
@Test
|
||||
public void twoNonStringObjectWithNewLines() {
|
||||
consumer.setShouldAppendNewLine(true);
|
||||
handler.setShouldAppendNewLine(true);
|
||||
endpoint.setReceiveTimeout(0);
|
||||
endpoint.setMaxMessagesPerPoll(2);
|
||||
TestObject testObject1 = new TestObject("foo");
|
||||
@@ -33,7 +33,7 @@ import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.integration.stream.CharacterStreamWritingMessageConsumer;
|
||||
import org.springframework.integration.stream.CharacterStreamWritingMessageHandler;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -61,9 +61,9 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class);
|
||||
Object adapter = context.getBean("stdoutAdapterWithDefaultCharset");
|
||||
CharacterStreamWritingMessageConsumer consumer = (CharacterStreamWritingMessageConsumer)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("consumer");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
|
||||
CharacterStreamWritingMessageHandler handler = (CharacterStreamWritingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
|
||||
Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer");
|
||||
assertEquals(BufferedWriter.class, bufferedWriter.getClass());
|
||||
DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter);
|
||||
@@ -72,7 +72,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
assertEquals(Charset.defaultCharset(), writerCharset);
|
||||
this.resetStreams();
|
||||
consumer.onMessage(new StringMessage("foo"));
|
||||
handler.handleMessage(new StringMessage("foo"));
|
||||
assertEquals("foo", out.toString());
|
||||
assertEquals("", err.toString());
|
||||
}
|
||||
@@ -82,9 +82,9 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class);
|
||||
Object adapter = context.getBean("stdoutAdapterWithProvidedCharset");
|
||||
CharacterStreamWritingMessageConsumer consumer = (CharacterStreamWritingMessageConsumer)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("consumer");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
|
||||
CharacterStreamWritingMessageHandler handler = (CharacterStreamWritingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
|
||||
Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer");
|
||||
assertEquals(BufferedWriter.class, bufferedWriter.getClass());
|
||||
DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter);
|
||||
@@ -93,7 +93,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
assertEquals(Charset.forName("UTF-8"), writerCharset);
|
||||
this.resetStreams();
|
||||
consumer.onMessage(new StringMessage("bar"));
|
||||
handler.handleMessage(new StringMessage("bar"));
|
||||
assertEquals("bar", out.toString());
|
||||
assertEquals("", err.toString());
|
||||
}
|
||||
@@ -119,9 +119,9 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class);
|
||||
Object adapter = context.getBean("stderrAdapter");
|
||||
CharacterStreamWritingMessageConsumer consumer = (CharacterStreamWritingMessageConsumer)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("consumer");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
|
||||
CharacterStreamWritingMessageHandler handler = (CharacterStreamWritingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
|
||||
Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer");
|
||||
assertEquals(BufferedWriter.class, bufferedWriter.getClass());
|
||||
DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter);
|
||||
@@ -130,7 +130,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
assertEquals(Charset.defaultCharset(), writerCharset);
|
||||
this.resetStreams();
|
||||
consumer.onMessage(new StringMessage("bad"));
|
||||
handler.handleMessage(new StringMessage("bad"));
|
||||
assertEquals("", out.toString());
|
||||
assertEquals("bad", err.toString());
|
||||
}
|
||||
@@ -140,9 +140,9 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
|
||||
"consoleOutboundChannelAdapterParserTests.xml", ConsoleOutboundChannelAdapterParserTests.class);
|
||||
Object adapter = context.getBean("newlineAdapter");
|
||||
CharacterStreamWritingMessageConsumer consumer = (CharacterStreamWritingMessageConsumer)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("consumer");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
|
||||
CharacterStreamWritingMessageHandler handler = (CharacterStreamWritingMessageHandler)
|
||||
new DirectFieldAccessor(adapter).getPropertyValue("handler");
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(handler);
|
||||
Writer bufferedWriter = (Writer) accessor.getPropertyValue("writer");
|
||||
assertEquals(BufferedWriter.class, bufferedWriter.getClass());
|
||||
DirectFieldAccessor bufferedWriterAccessor = new DirectFieldAccessor(bufferedWriter);
|
||||
@@ -151,7 +151,7 @@ public class ConsoleOutboundChannelAdapterParserTests {
|
||||
Charset writerCharset = Charset.forName(((OutputStreamWriter) writer).getEncoding());
|
||||
assertEquals(Charset.defaultCharset(), writerCharset);
|
||||
this.resetStreams();
|
||||
consumer.onMessage(new StringMessage("foo"));
|
||||
handler.handleMessage(new StringMessage("foo"));
|
||||
assertEquals("foo\n", out.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.ws;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -38,7 +38,7 @@ import org.springframework.ws.transport.WebServiceMessageSender;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyProducingMessageConsumer {
|
||||
public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
public static final String SOAP_ACTION_PROPERTY_KEY = "spring.integration.ws.soapAction";
|
||||
|
||||
@@ -85,7 +85,7 @@ public abstract class AbstractWebServiceOutboundGateway extends AbstractReplyPro
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
public final void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
Object responsePayload = this.doHandle(message.getPayload(), this.getRequestCallback(message));
|
||||
if (responsePayload != null) {
|
||||
replyHolder.set(responsePayload);
|
||||
|
||||
@@ -48,7 +48,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithDefaultSourceExtractor");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals("DefaultSourceExtractor", accessor.getPropertyValue("sourceExtractor").getClass().getSimpleName());
|
||||
@@ -60,7 +60,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomSourceExtractor");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
SourceExtractor sourceExtractor = (SourceExtractor) context.getBean("sourceExtractor");
|
||||
@@ -73,7 +73,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomRequestCallback");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
|
||||
@@ -86,7 +86,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomMessageFactory");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
@@ -101,7 +101,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomSourceExtractorAndMessageFactory");
|
||||
SourceExtractor sourceExtractor = (SourceExtractor) context.getBean("sourceExtractor");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
assertEquals(sourceExtractor, accessor.getPropertyValue("sourceExtractor"));
|
||||
@@ -116,7 +116,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomFaultMessageResolver");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
@@ -131,7 +131,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomMessageSender");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
@@ -144,7 +144,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"simpleWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomMessageSenderList");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(SimpleWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
accessor = new DirectFieldAccessor(accessor.getPropertyValue("webServiceTemplate"));
|
||||
@@ -175,7 +175,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithAllInOneMarshaller");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
|
||||
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
|
||||
@@ -191,7 +191,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshaller");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
|
||||
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
|
||||
@@ -208,7 +208,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithCustomRequestCallback");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(gateway);
|
||||
WebServiceMessageCallback callback = (WebServiceMessageCallback) context.getBean("requestCallback");
|
||||
@@ -221,7 +221,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithAllInOneMarshallerAndMessageFactory");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
|
||||
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
|
||||
@@ -239,7 +239,7 @@ public class WebServiceOutboundGatewayParserTests {
|
||||
"marshallingWebServiceOutboundGatewayParserTests.xml", this.getClass());
|
||||
MessageEndpoint endpoint = (MessageEndpoint) context.getBean("gatewayWithSeparateMarshallerAndUnmarshallerAndMessageFactory");
|
||||
assertEquals(SubscribingConsumerEndpoint.class, endpoint.getClass());
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object gateway = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals(MarshallingWebServiceOutboundGateway.class, gateway.getClass());
|
||||
DirectFieldAccessor gatewayAccessor = new DirectFieldAccessor(gateway);
|
||||
DirectFieldAccessor templateAccessor = new DirectFieldAccessor(
|
||||
|
||||
@@ -55,7 +55,7 @@ public class XPathMessageSplitterTests {
|
||||
@Test
|
||||
public void splitDocument() throws Exception {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<orders><order>one</order><order>two</order><order>three</order></orders>");
|
||||
splitter.onMessage(new GenericMessage<Document>(doc));
|
||||
splitter.handleMessage(new GenericMessage<Document>(doc));
|
||||
List<Message<?>> docMessages = this.replyChannel.clear();
|
||||
assertEquals("Wrong number of messages", 3, docMessages.size());
|
||||
for (Message<?> message : docMessages) {
|
||||
@@ -67,14 +67,14 @@ public class XPathMessageSplitterTests {
|
||||
@Test(expected = MessagingException.class)
|
||||
public void splitDocumentThatDoesNotMatch() throws Exception {
|
||||
Document doc = XmlTestUtil.getDocumentForString("<wrongDocument/>");
|
||||
splitter.onMessage(new GenericMessage<Document>(doc));
|
||||
splitter.handleMessage(new GenericMessage<Document>(doc));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void splitDocumentWithCreateDocumentsTrue() throws Exception {
|
||||
splitter.setCreateDocuments(true);
|
||||
Document doc = XmlTestUtil.getDocumentForString("<orders><order>one</order><order>two</order><order>three</order></orders>");
|
||||
splitter.onMessage(new GenericMessage<Document>(doc));
|
||||
splitter.handleMessage(new GenericMessage<Document>(doc));
|
||||
List<Message<?>> docMessages = this.replyChannel.clear();
|
||||
assertEquals("Wrong number of messages", 3, docMessages.size());
|
||||
for (Message<?> message : docMessages) {
|
||||
@@ -85,7 +85,7 @@ public class XPathMessageSplitterTests {
|
||||
@Test
|
||||
public void splitStringXml() throws Exception {
|
||||
String payload = "<orders><order>one</order><order>two</order><order>three</order></orders>";
|
||||
splitter.onMessage(new GenericMessage<String>(payload));
|
||||
splitter.handleMessage(new GenericMessage<String>(payload));
|
||||
List<Message<?>> docMessages = this.replyChannel.clear();
|
||||
assertEquals("Wrong number of messages", 3, docMessages.size());
|
||||
for (Message<?> message : docMessages) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A base class for aggregating a group of Messages into a single Message.
|
||||
* Extends {@link AbstractMessageBarrierConsumer} and waits for a
|
||||
* Extends {@link AbstractMessageBarrierHandler} and waits for a
|
||||
* <em>complete</em> group of {@link Message Messages} to arrive. Subclasses
|
||||
* must provide the implementation of the {@link #aggregateMessages(List)}
|
||||
* method to combine the group of Messages into a single {@link Message}.
|
||||
@@ -34,13 +34,13 @@ import org.springframework.util.Assert;
|
||||
* custom implementation of the {@link CompletionStrategy} may be provided.
|
||||
*
|
||||
* <p>All considerations regarding <code>timeout</code> and grouping by
|
||||
* <code>correlationId</code> from {@link AbstractMessageBarrierConsumer}
|
||||
* <code>correlationId</code> from {@link AbstractMessageBarrierHandler}
|
||||
* apply here as well.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public abstract class AbstractMessageAggregator extends AbstractMessageBarrierConsumer {
|
||||
public abstract class AbstractMessageAggregator extends AbstractMessageBarrierHandler {
|
||||
|
||||
private volatile CompletionStrategy completionStrategy = new SequenceSizeCompletionStrategy();
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.consumer.AbstractMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractMessageHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
import org.springframework.integration.scheduling.IntervalTrigger;
|
||||
import org.springframework.integration.scheduling.TaskScheduler;
|
||||
@@ -43,13 +43,13 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Base class for {@link MessageBarrier}-based Message Consumers. A
|
||||
* {@link MessageConsumer} implementation that waits for a group of
|
||||
* Base class for {@link MessageBarrier}-based Message Handlers. A
|
||||
* {@link MessageHandler} implementation that waits for a group of
|
||||
* {@link Message Messages} to arrive and processes them together. Uses a
|
||||
* {@link MessageBarrier} to store messages and to decide how the messages
|
||||
* should be released.
|
||||
* <p>
|
||||
* Each {@link Message} that is received by this consumer will be associated
|
||||
* Each {@link Message} that is received by this handler will be associated
|
||||
* with a group based upon the '<code>correlationId</code>' property of its
|
||||
* header. If no such property is available, a {@link MessageHandlingException}
|
||||
* will be thrown.
|
||||
@@ -64,7 +64,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public abstract class AbstractMessageBarrierConsumer extends AbstractMessageConsumer implements TaskSchedulerAware, InitializingBean {
|
||||
public abstract class AbstractMessageBarrierHandler extends AbstractMessageHandler implements TaskSchedulerAware, InitializingBean {
|
||||
|
||||
public final static long DEFAULT_SEND_TIMEOUT = 1000;
|
||||
|
||||
@@ -101,7 +101,7 @@ public abstract class AbstractMessageBarrierConsumer extends AbstractMessageCons
|
||||
private ScheduledFuture<?> reaperFutureTask;
|
||||
|
||||
|
||||
public AbstractMessageBarrierConsumer() {
|
||||
public AbstractMessageBarrierHandler() {
|
||||
this.channelTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ public abstract class AbstractMessageBarrierConsumer extends AbstractMessageCons
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onMessageInternal(Message<?> message) {
|
||||
protected final void handleMessageInternal(Message<?> message) {
|
||||
if (!this.initialized) {
|
||||
this.afterPropertiesSet();
|
||||
}
|
||||
@@ -22,7 +22,7 @@ import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
|
||||
/**
|
||||
* An {@link AbstractMessageBarrierConsumer} that waits for a group of
|
||||
* An {@link AbstractMessageBarrierHandler} that waits for a group of
|
||||
* {@link Message Messages} to arrive and re-sends them in order, sorted
|
||||
* by their <code>sequenceNumber</code>.
|
||||
* <p>
|
||||
@@ -30,12 +30,12 @@ import org.springframework.integration.core.MessageHeaders;
|
||||
* wait for the whole sequence to arrive before re-sending them.
|
||||
* <p>
|
||||
* All considerations regarding <code>timeout</code> and grouping by
|
||||
* '<code>correlationId</code>' from {@link AbstractMessageBarrierConsumer}
|
||||
* '<code>correlationId</code>' from {@link AbstractMessageBarrierHandler}
|
||||
* apply here as well.
|
||||
*
|
||||
* @author Marius Bogoevici
|
||||
*/
|
||||
public class Resequencer extends AbstractMessageBarrierConsumer {
|
||||
public class Resequencer extends AbstractMessageBarrierHandler {
|
||||
|
||||
private volatile boolean releasePartialSequences = true;
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ package org.springframework.integration.channel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.dispatcher.MessageDispatcher;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base implementation of {@link MessageChannel} that invokes the subscribed
|
||||
* {@link MessageConsumer consumer(s)} by delegating to a {@link MessageDispatcher}.
|
||||
* {@link MessageHandler handler(s)} by delegating to a {@link MessageDispatcher}.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@@ -43,12 +43,12 @@ public class AbstractSubscribableChannel<T extends MessageDispatcher> extends Ab
|
||||
return this.dispatcher;
|
||||
}
|
||||
|
||||
public boolean subscribe(MessageConsumer consumer) {
|
||||
return this.dispatcher.addConsumer(consumer);
|
||||
public boolean subscribe(MessageHandler handler) {
|
||||
return this.dispatcher.addHandler(handler);
|
||||
}
|
||||
|
||||
public boolean unsubscribe(MessageConsumer consumer) {
|
||||
return this.dispatcher.removeConsumer(consumer);
|
||||
public boolean unsubscribe(MessageHandler handle) {
|
||||
return this.dispatcher.removeHandler(handle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.channel;
|
||||
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* Interface for any MessageChannel implementation that accepts subscribers.
|
||||
@@ -27,13 +27,13 @@ import org.springframework.integration.message.MessageConsumer;
|
||||
public interface SubscribableChannel extends MessageChannel {
|
||||
|
||||
/**
|
||||
* Register a {@link MessageConsumer} as a subscriber to this channel.
|
||||
* Register a {@link MessageHandler} as a subscriber to this channel.
|
||||
*/
|
||||
boolean subscribe(MessageConsumer consumer);
|
||||
boolean subscribe(MessageHandler handler);
|
||||
|
||||
/**
|
||||
* Remove a {@link MessageConsumer} from the subscribers of this channel.
|
||||
* Remove a {@link MessageHandler} from the subscribers of this channel.
|
||||
*/
|
||||
boolean unsubscribe(MessageConsumer consumer);
|
||||
boolean unsubscribe(MessageHandler handler);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractConsumerFactoryBean implements FactoryBean {
|
||||
|
||||
private volatile MessageConsumer consumer;
|
||||
private volatile MessageHandler consumer;
|
||||
|
||||
private volatile Object targetObject;
|
||||
|
||||
@@ -59,8 +59,8 @@ public abstract class AbstractConsumerFactoryBean implements FactoryBean {
|
||||
this.initializeConsumer();
|
||||
Assert.notNull(this.consumer, "failed to create MessageConsumer");
|
||||
if (this.outputChannel != null
|
||||
&& this.consumer instanceof AbstractReplyProducingMessageConsumer) {
|
||||
((AbstractReplyProducingMessageConsumer) this.consumer).setOutputChannel(this.outputChannel);
|
||||
&& this.consumer instanceof AbstractReplyProducingMessageHandler) {
|
||||
((AbstractReplyProducingMessageHandler) this.consumer).setOutputChannel(this.outputChannel);
|
||||
}
|
||||
}
|
||||
return this.consumer;
|
||||
@@ -70,7 +70,7 @@ public abstract class AbstractConsumerFactoryBean implements FactoryBean {
|
||||
if (this.consumer != null) {
|
||||
return this.consumer.getClass();
|
||||
}
|
||||
return MessageConsumer.class;
|
||||
return MessageHandler.class;
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
@@ -90,6 +90,6 @@ public abstract class AbstractConsumerFactoryBean implements FactoryBean {
|
||||
/**
|
||||
* Subclasses must implement this method to create the MessageConsumer.
|
||||
*/
|
||||
protected abstract MessageConsumer createConsumer(Object targetObject, String targetMethodName);
|
||||
protected abstract MessageHandler createConsumer(Object targetObject, String targetMethodName);
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.endpoint.MessageEndpoint;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.scheduling.IntervalTrigger;
|
||||
import org.springframework.integration.scheduling.Trigger;
|
||||
import org.springframework.transaction.PlatformTransactionManager;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAware, BeanNameAware, InitializingBean {
|
||||
|
||||
private final MessageConsumer consumer;
|
||||
private final MessageHandler handler;
|
||||
|
||||
private volatile String beanName;
|
||||
|
||||
@@ -68,9 +68,9 @@ public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAwar
|
||||
private final Object initializationMonitor = new Object();
|
||||
|
||||
|
||||
public ConsumerEndpointFactoryBean(MessageConsumer consumer) {
|
||||
Assert.notNull(consumer, "consumer must not be null");
|
||||
this.consumer = consumer;
|
||||
public ConsumerEndpointFactoryBean(MessageHandler handler) {
|
||||
Assert.notNull(handler, "handler must not be null");
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
@@ -146,15 +146,14 @@ public class ConsumerEndpointFactoryBean implements FactoryBean, BeanFactoryAwar
|
||||
if (channel instanceof SubscribableChannel) {
|
||||
Assert.isNull(trigger, "A trigger should not be specified for endpoint '" + this.beanName
|
||||
+ "', since '" + this.inputChannelName + "' is a SubscribableChannel (not pollable).");
|
||||
this.endpoint = new SubscribingConsumerEndpoint(
|
||||
this.consumer, (SubscribableChannel) channel);
|
||||
this.endpoint = new SubscribingConsumerEndpoint((SubscribableChannel) channel, this.handler);
|
||||
}
|
||||
else if (channel instanceof PollableChannel) {
|
||||
if (this.trigger == null) {
|
||||
this.trigger = new IntervalTrigger(0);
|
||||
}
|
||||
PollingConsumerEndpoint pollingEndpoint = new PollingConsumerEndpoint(
|
||||
this.consumer, (PollableChannel) channel);
|
||||
(PollableChannel) channel, this.handler);
|
||||
pollingEndpoint.setTrigger(this.trigger);
|
||||
pollingEndpoint.setMaxMessagesPerPoll(this.maxMessagesPerPoll);
|
||||
pollingEndpoint.setReceiveTimeout(this.receiveTimeout);
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.router.AbstractMessageRouter;
|
||||
import org.springframework.integration.router.MethodInvokingRouter;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -45,7 +45,7 @@ public class RouterFactoryBean extends AbstractConsumerFactoryBean {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object targetObject, String targetMethodName) {
|
||||
protected MessageHandler createConsumer(Object targetObject, String targetMethodName) {
|
||||
Assert.notNull(targetObject, "target object must not be null");
|
||||
AbstractMessageRouter router = this.createRouter(targetObject, targetMethodName);
|
||||
if (this.defaultOutputChannel != null) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.splitter.AbstractMessageSplitter;
|
||||
import org.springframework.integration.splitter.DefaultMessageSplitter;
|
||||
import org.springframework.integration.splitter.MethodInvokingSplitter;
|
||||
@@ -31,7 +31,7 @@ import org.springframework.util.StringUtils;
|
||||
public class SplitterFactoryBean extends AbstractConsumerFactoryBean {
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object targetObject, String targetMethodName) {
|
||||
protected MessageHandler createConsumer(Object targetObject, String targetMethodName) {
|
||||
if (targetObject == null) {
|
||||
Assert.isTrue(!StringUtils.hasText(targetMethodName),
|
||||
"'method' should only be provided when 'ref' is also provided");
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.endpoint.MessageEndpoint;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -60,9 +60,9 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
|
||||
|
||||
public Object postProcess(Object bean, String beanName, Method method, T annotation) {
|
||||
MessageConsumer consumer = this.createConsumer(bean, method, annotation);
|
||||
MessageHandler handler = this.createHandler(bean, method, annotation);
|
||||
Poller pollerAnnotation = AnnotationUtils.findAnnotation(method, Poller.class);
|
||||
MessageEndpoint endpoint = this.createEndpoint(consumer, annotation, pollerAnnotation);
|
||||
MessageEndpoint endpoint = this.createEndpoint(handler, annotation, pollerAnnotation);
|
||||
if (endpoint != null) {
|
||||
if (endpoint instanceof InitializingBean) {
|
||||
try {
|
||||
@@ -75,14 +75,14 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
}
|
||||
return endpoint;
|
||||
}
|
||||
return consumer;
|
||||
return handler;
|
||||
}
|
||||
|
||||
protected boolean shouldCreateEndpoint(T annotation) {
|
||||
return (StringUtils.hasText((String) AnnotationUtils.getValue(annotation, INPUT_CHANNEL_ATTRIBUTE)));
|
||||
}
|
||||
|
||||
private MessageEndpoint createEndpoint(MessageConsumer consumer, T annotation, Poller pollerAnnotation) {
|
||||
private MessageEndpoint createEndpoint(MessageHandler handler, T annotation, Poller pollerAnnotation) {
|
||||
MessageEndpoint endpoint = null;
|
||||
String inputChannelName = (String) AnnotationUtils.getValue(annotation, INPUT_CHANNEL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(inputChannelName)) {
|
||||
@@ -90,7 +90,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
Assert.notNull(inputChannel, "failed to resolve inputChannel '" + inputChannelName + "'");
|
||||
if (inputChannel instanceof PollableChannel) {
|
||||
PollingConsumerEndpoint pollingEndpoint = new PollingConsumerEndpoint(
|
||||
consumer, (PollableChannel) inputChannel);
|
||||
(PollableChannel) inputChannel, handler);
|
||||
if (pollerAnnotation != null) {
|
||||
AnnotationConfigUtils.configurePollingEndpointWithPollerAnnotation(
|
||||
pollingEndpoint, pollerAnnotation, this.beanFactoryAccessor.getBeanFactory());
|
||||
@@ -100,21 +100,21 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
else if (inputChannel instanceof SubscribableChannel) {
|
||||
Assert.isTrue(pollerAnnotation == null,
|
||||
"The @Poller annotation should only be provided for a PollableChannel");
|
||||
endpoint = new SubscribingConsumerEndpoint(consumer, (SubscribableChannel) inputChannel);
|
||||
endpoint = new SubscribingConsumerEndpoint((SubscribableChannel) inputChannel, handler);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("unsupported channel type: [" + inputChannel.getClass() + "]");
|
||||
}
|
||||
if (consumer instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) consumer).setBeanFactory(this.beanFactoryAccessor.getBeanFactory());
|
||||
if (handler instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) handler).setBeanFactory(this.beanFactoryAccessor.getBeanFactory());
|
||||
}
|
||||
}
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclasses must implement this method to create the MessageConsumer.
|
||||
* Subclasses must implement this method to create the MessageHandler.
|
||||
*/
|
||||
protected abstract MessageConsumer createConsumer(Object bean, Method method, T annotation);
|
||||
protected abstract MessageHandler createHandler(Object bean, Method method, T annotation);
|
||||
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.integration.aggregator.MethodInvokingAggregator;
|
||||
import org.springframework.integration.annotation.Aggregator;
|
||||
import org.springframework.integration.annotation.CompletionStrategy;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -45,7 +45,7 @@ public class AggregatorAnnotationPostProcessor extends AbstractMethodAnnotationP
|
||||
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, Aggregator annotation) {
|
||||
protected MessageHandler createHandler(Object bean, Method method, Aggregator annotation) {
|
||||
MethodInvokingAggregator aggregator = new MethodInvokingAggregator(bean, method);
|
||||
this.configureCompletionStrategy(bean, aggregator);
|
||||
String discardChannelName = annotation.discardChannel();
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.channel.SubscribableChannel;
|
||||
import org.springframework.integration.consumer.MethodInvokingConsumer;
|
||||
import org.springframework.integration.consumer.MethodInvokingMessageHandler;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.endpoint.MessageEndpoint;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
@@ -71,8 +71,8 @@ public class ChannelAdapterAnnotationPostProcessor implements MethodAnnotationPo
|
||||
endpoint = this.createInboundChannelAdapter(source, channel, pollerAnnotation);
|
||||
}
|
||||
else if (method.getParameterTypes().length > 0 && !hasReturnValue(method)) {
|
||||
MethodInvokingConsumer consumer = new MethodInvokingConsumer(bean, method);
|
||||
endpoint = this.createOutboundChannelAdapter(consumer, channel, pollerAnnotation);
|
||||
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(bean, method);
|
||||
endpoint = this.createOutboundChannelAdapter(channel, handler, pollerAnnotation);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("The @ChannelAdapter can only be applied to methods"
|
||||
@@ -110,17 +110,17 @@ public class ChannelAdapterAnnotationPostProcessor implements MethodAnnotationPo
|
||||
return adapter;
|
||||
}
|
||||
|
||||
private MessageEndpoint createOutboundChannelAdapter(MethodInvokingConsumer consumer, MessageChannel channel, Poller pollerAnnotation) {
|
||||
private MessageEndpoint createOutboundChannelAdapter(MessageChannel channel, MethodInvokingMessageHandler handler, Poller pollerAnnotation) {
|
||||
if (channel instanceof PollableChannel) {
|
||||
Trigger trigger = (pollerAnnotation != null)
|
||||
? AnnotationConfigUtils.parseTriggerFromPollerAnnotation(pollerAnnotation)
|
||||
: new IntervalTrigger(0);
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(consumer, (PollableChannel) channel);
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint((PollableChannel) channel, handler);
|
||||
endpoint.setTrigger(trigger);
|
||||
return endpoint;
|
||||
}
|
||||
if (channel instanceof SubscribableChannel) {
|
||||
return new SubscribingConsumerEndpoint(consumer, (SubscribableChannel) channel);
|
||||
return new SubscribingConsumerEndpoint((SubscribableChannel) channel, handler);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.lang.reflect.Method;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.integration.annotation.Router;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.router.MethodInvokingRouter;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -39,7 +39,7 @@ public class RouterAnnotationPostProcessor extends AbstractMethodAnnotationPostP
|
||||
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, Router annotation) {
|
||||
protected MessageHandler createHandler(Object bean, Method method, Router annotation) {
|
||||
MethodInvokingRouter router = new MethodInvokingRouter(bean, method);
|
||||
router.setChannelResolver(this.channelResolver);
|
||||
String defaultOutputChannelName = annotation.defaultOutputChannel();
|
||||
|
||||
@@ -20,8 +20,8 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.consumer.ServiceActivatingHandler;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -37,8 +37,8 @@ public class ServiceActivatorAnnotationPostProcessor extends AbstractMethodAnnot
|
||||
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, ServiceActivator annotation) {
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(bean, method);
|
||||
protected MessageHandler createHandler(Object bean, Method method, ServiceActivator annotation) {
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(bean, method);
|
||||
String outputChannelName = annotation.outputChannel();
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
serviceActivator.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.integration.annotation.Splitter;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.splitter.MethodInvokingSplitter;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class SplitterAnnotationPostProcessor extends AbstractMethodAnnotationPos
|
||||
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, Splitter annotation) {
|
||||
protected MessageHandler createHandler(Object bean, Method method, Splitter annotation) {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(bean, method);
|
||||
String outputChannelName = annotation.outputChannel();
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
|
||||
@@ -20,9 +20,9 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.integration.annotation.Transformer;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.transformer.MethodInvokingTransformer;
|
||||
import org.springframework.integration.transformer.MessageTransformingConsumer;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -38,14 +38,14 @@ public class TransformerAnnotationPostProcessor extends AbstractMethodAnnotation
|
||||
|
||||
|
||||
@Override
|
||||
protected MessageConsumer createConsumer(Object bean, Method method, Transformer annotation) {
|
||||
protected MessageHandler createHandler(Object bean, Method method, Transformer annotation) {
|
||||
MethodInvokingTransformer transformer = new MethodInvokingTransformer(bean, method);
|
||||
MessageTransformingConsumer consumer = new MessageTransformingConsumer(transformer);
|
||||
MessageTransformingHandler handler = new MessageTransformingHandler(transformer);
|
||||
String outputChannelName = annotation.outputChannel();
|
||||
if (StringUtils.hasText(outputChannelName)) {
|
||||
consumer.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
|
||||
handler.setOutputChannel(this.channelResolver.resolveChannelName(outputChannelName));
|
||||
}
|
||||
return consumer;
|
||||
return handler;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,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.transformer.Transformer;
|
||||
import org.springframework.integration.transformer.MessageTransformingConsumer;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
@@ -31,7 +31,7 @@ public abstract class AbstractTransformerParser extends AbstractConsumerEndpoint
|
||||
|
||||
@Override
|
||||
protected BeanDefinitionBuilder parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MessageTransformingConsumer.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MessageTransformingHandler.class);
|
||||
BeanDefinitionBuilder transformerBuilder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(this.getTransformerClass());
|
||||
this.parseTransformer(element, parserContext, transformerBuilder);
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.springframework.beans.factory.support.AbstractBeanDefinition;
|
||||
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.consumer.MethodInvokingConsumer;
|
||||
import org.springframework.integration.consumer.MethodInvokingMessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MethodInvokingOutboundChannelAdapterParser extends AbstractOutbound
|
||||
|
||||
@Override
|
||||
protected AbstractBeanDefinition parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder invokerBuilder = BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingConsumer.class);
|
||||
BeanDefinitionBuilder invokerBuilder = BeanDefinitionBuilder.genericBeanDefinition(MethodInvokingMessageHandler.class);
|
||||
invokerBuilder.addConstructorArgReference(element.getAttribute("ref"));
|
||||
invokerBuilder.addConstructorArgValue(element.getAttribute("method"));
|
||||
return invokerBuilder.getBeanDefinition();
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.w3c.dom.Element;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.consumer.ServiceActivatingHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class ServiceActivatorParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@Override
|
||||
protected BeanDefinitionBuilder parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ServiceActivatingConsumer.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(ServiceActivatingHandler.class);
|
||||
String ref = element.getAttribute(REF_ATTRIBUTE);
|
||||
Assert.hasText(ref, "The '" + REF_ATTRIBUTE + "' attribute is required.");
|
||||
builder.addConstructorArgReference(ref);
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.w3c.dom.Element;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
|
||||
import org.springframework.beans.factory.xml.ParserContext;
|
||||
import org.springframework.integration.transformer.MethodInvokingTransformer;
|
||||
import org.springframework.integration.transformer.MessageTransformingConsumer;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
|
||||
/**
|
||||
* Parser for the <transformer/> element.
|
||||
@@ -32,7 +32,7 @@ public class TransformerParser extends AbstractConsumerEndpointParser {
|
||||
|
||||
@Override
|
||||
protected BeanDefinitionBuilder parseConsumer(Element element, ParserContext parserContext) {
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MessageTransformingConsumer.class);
|
||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(MessageTransformingHandler.class);
|
||||
builder.addConstructorArgReference(this.parseAdapter(element, parserContext, MethodInvokingTransformer.class));
|
||||
return builder;
|
||||
}
|
||||
|
||||
@@ -21,41 +21,41 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageHandlingException;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for MessageConsumer implementations that provides basic
|
||||
* Base class for MessageHandler implementations that provides basic
|
||||
* validation and error handling capabilities. Asserts that the incoming
|
||||
* Message is not null and that it does not contain a null payload. Converts
|
||||
* checked exceptions into runtime {@link MessagingException}s.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractMessageConsumer implements MessageConsumer {
|
||||
public abstract class AbstractMessageHandler implements MessageHandler {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
|
||||
public final void onMessage(Message<?> message) {
|
||||
public final void handleMessage(Message<?> message) {
|
||||
Assert.notNull(message == null, "Message must not be null");
|
||||
Assert.notNull(message.getPayload(), "Message payload must not be null");
|
||||
if (this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("consumer '" + this + "' received message: " + message);
|
||||
this.logger.debug(this + " received message: " + message);
|
||||
}
|
||||
try {
|
||||
this.onMessageInternal(message);
|
||||
this.handleMessageInternal(message);
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (e instanceof MessagingException) {
|
||||
throw (MessagingException) e;
|
||||
}
|
||||
throw new MessageHandlingException(message,
|
||||
"error occurred in consumer [" + this + "]", e);
|
||||
"error occurred in message handler [" + this + "]", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void onMessageInternal(Message<?> message) throws Exception;
|
||||
protected abstract void handleMessageInternal(Message<?> message) throws Exception;
|
||||
|
||||
}
|
||||
@@ -32,11 +32,11 @@ import org.springframework.integration.selector.MessageSelector;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for MessageConsumers that are capable of producing replies.
|
||||
* Base class for MessageHandlers that are capable of producing replies.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractReplyProducingMessageConsumer extends AbstractMessageConsumer implements BeanFactoryAware {
|
||||
public abstract class AbstractReplyProducingMessageHandler extends AbstractMessageHandler implements BeanFactoryAware {
|
||||
|
||||
public static final long DEFAULT_SEND_TIMEOUT = 1000;
|
||||
|
||||
@@ -52,7 +52,7 @@ public abstract class AbstractReplyProducingMessageConsumer extends AbstractMess
|
||||
private final MessageChannelTemplate channelTemplate;
|
||||
|
||||
|
||||
public AbstractReplyProducingMessageConsumer() {
|
||||
public AbstractReplyProducingMessageHandler() {
|
||||
this.channelTemplate = new MessageChannelTemplate();
|
||||
this.channelTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
|
||||
}
|
||||
@@ -93,15 +93,15 @@ public abstract class AbstractReplyProducingMessageConsumer extends AbstractMess
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onMessageInternal(Message<?> message) {
|
||||
protected final void handleMessageInternal(Message<?> message) {
|
||||
if (!this.supports(message)) {
|
||||
throw new MessageRejectedException(message, "unsupported message");
|
||||
}
|
||||
ReplyMessageHolder replyMessageHolder = new ReplyMessageHolder();
|
||||
this.onMessage(message, replyMessageHolder);
|
||||
this.handleRequestMessage(message, replyMessageHolder);
|
||||
if (replyMessageHolder.isEmpty()) {
|
||||
if (this.requiresReply) {
|
||||
throw new MessageHandlingException(message, "consumer '" + this
|
||||
throw new MessageHandlingException(message, "handler '" + this
|
||||
+ "' requires a reply, but no reply was received");
|
||||
}
|
||||
return;
|
||||
@@ -121,12 +121,12 @@ public abstract class AbstractReplyProducingMessageConsumer extends AbstractMess
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void onMessage(Message<?> requestMessage, ReplyMessageHolder replyMessageHolder);
|
||||
protected abstract void handleRequestMessage(Message<?> requestMessage, ReplyMessageHolder replyMessageHolder);
|
||||
|
||||
protected boolean supports(Message<?> message) {
|
||||
if (this.selector != null && !this.selector.accept(message)) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("selector for consumer '" + this + "' rejected message: " + message);
|
||||
logger.debug("selector for handler '" + this + "' rejected message: " + message);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -20,33 +20,33 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageMappingMethodInvoker;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A {@link MessageConsumer} that invokes the specified method on the provided object.
|
||||
* A {@link MessageHandler} that invokes the specified method on the provided object.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MethodInvokingConsumer extends MessageMappingMethodInvoker implements MessageConsumer {
|
||||
public class MethodInvokingMessageHandler extends MessageMappingMethodInvoker implements MessageHandler {
|
||||
|
||||
public MethodInvokingConsumer(Object object, Method method) {
|
||||
public MethodInvokingMessageHandler(Object object, Method method) {
|
||||
super(object, method);
|
||||
Assert.isTrue(method.getReturnType().equals(void.class),
|
||||
"MethodInvokingConsumer requires a void-returning method");
|
||||
"MethodInvokingMessageHandler requires a void-returning method");
|
||||
}
|
||||
|
||||
public MethodInvokingConsumer(Object object, String methodName) {
|
||||
public MethodInvokingMessageHandler(Object object, String methodName) {
|
||||
super(object, methodName);
|
||||
}
|
||||
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
Object result = this.invokeMethod(message);
|
||||
if (result != null) {
|
||||
throw new MessagingException(message, "the MethodInvokingConsumer method must have a void return, "
|
||||
+ "but '" + this + "' received a value: [" + result + "]");
|
||||
throw new MessagingException(message, "the MethodInvokingMessageHandler method must "
|
||||
+ "have a void return, but '" + this + "' received a value: [" + result + "]");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ import org.springframework.util.Assert;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ServiceActivatingConsumer extends AbstractReplyProducingMessageConsumer implements InitializingBean {
|
||||
public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandler implements InitializingBean {
|
||||
|
||||
private final MethodResolver methodResolver = new DefaultMethodResolver(ServiceActivator.class);
|
||||
|
||||
private final MethodInvoker invoker;
|
||||
|
||||
|
||||
public ServiceActivatingConsumer(final Object object) {
|
||||
public ServiceActivatingHandler(final Object object) {
|
||||
Assert.notNull(object, "object must not be null");
|
||||
Method method = this.methodResolver.findMethod(object);
|
||||
Assert.notNull(method, "unable to resolve ServiceActivator method on target class ["
|
||||
@@ -46,11 +46,11 @@ public class ServiceActivatingConsumer extends AbstractReplyProducingMessageCons
|
||||
this.invoker = new MessageMappingMethodInvoker(object, method);
|
||||
}
|
||||
|
||||
public ServiceActivatingConsumer(Object object, Method method) {
|
||||
public ServiceActivatingHandler(Object object, Method method) {
|
||||
this.invoker = new MessageMappingMethodInvoker(object, method);
|
||||
}
|
||||
|
||||
public ServiceActivatingConsumer(Object object, String methodName) {
|
||||
public ServiceActivatingHandler(Object object, String methodName) {
|
||||
this.invoker = new MessageMappingMethodInvoker(object, methodName);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public class ServiceActivatingConsumer extends AbstractReplyProducingMessageCons
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
protected void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
try {
|
||||
Object result = this.invoker.invokeMethod(message);
|
||||
if (result != null) {
|
||||
@@ -24,7 +24,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageRejectedException;
|
||||
|
||||
/**
|
||||
@@ -36,21 +36,21 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
protected final Set<MessageConsumer> consumers = new CopyOnWriteArraySet<MessageConsumer>();
|
||||
protected final Set<MessageHandler> handlers = new CopyOnWriteArraySet<MessageHandler>();
|
||||
|
||||
private volatile TaskExecutor taskExecutor;
|
||||
|
||||
|
||||
public boolean addConsumer(MessageConsumer consumer) {
|
||||
return this.consumers.add(consumer);
|
||||
public boolean addHandler(MessageHandler handler) {
|
||||
return this.handlers.add(handler);
|
||||
}
|
||||
|
||||
public boolean removeConsumer(MessageConsumer consumer) {
|
||||
return this.consumers.remove(consumer);
|
||||
public boolean removeHandler(MessageHandler handler) {
|
||||
return this.handlers.remove(handler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify a {@link TaskExecutor} for invoking the consumers.
|
||||
* Specify a {@link TaskExecutor} for invoking the handlers.
|
||||
* If none is provided, the invocation will occur in the thread
|
||||
* that runs this polling dispatcher.
|
||||
*/
|
||||
@@ -63,21 +63,21 @@ public abstract class AbstractDispatcher implements MessageDispatcher {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.getClass().getSimpleName() + " with consumers: " + this.consumers;
|
||||
return this.getClass().getSimpleName() + " with handlers: " + this.handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method available for subclasses. Returns 'true' unless a
|
||||
* "Selective Consumer" throws a {@link MessageRejectedException}.
|
||||
*/
|
||||
protected boolean sendMessageToConsumer(Message<?> message, MessageConsumer consumer) {
|
||||
protected boolean sendMessageToHandler(Message<?> message, MessageHandler handler) {
|
||||
try {
|
||||
consumer.onMessage(message);
|
||||
handler.handleMessage(message);
|
||||
return true;
|
||||
}
|
||||
catch (MessageRejectedException e) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Consumer '" + consumer + "' rejected Message, continuing with other consumers if available.", e);
|
||||
logger.debug("Handler '" + handler + "' rejected Message, continuing with other handlers if available.", e);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -19,13 +19,13 @@ package org.springframework.integration.dispatcher;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* A broadcasting dispatcher implementation. It makes a best effort to
|
||||
* send the message to each of its consumers. If it fails to send to any
|
||||
* one consumer, it will log a warn-level message but continue to send
|
||||
* to the other consumers.
|
||||
* send the message to each of its handlers. If it fails to send to any
|
||||
* one handler, it will log a warn-level message but continue to send
|
||||
* to the other handlers.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@@ -36,7 +36,7 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
|
||||
|
||||
/**
|
||||
* Specify whether to apply sequence numbers to the messages
|
||||
* prior to sending to the endpoints. By default, sequence
|
||||
* prior to sending to the handlers. By default, sequence
|
||||
* numbers will <em>not</em> be applied
|
||||
*/
|
||||
public void setApplySequence(boolean applySequence) {
|
||||
@@ -45,8 +45,8 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
|
||||
|
||||
public boolean dispatch(Message<?> message) {
|
||||
int sequenceNumber = 1;
|
||||
int sequenceSize = this.consumers.size();
|
||||
for (final MessageConsumer consumer : this.consumers) {
|
||||
int sequenceSize = this.handlers.size();
|
||||
for (final MessageHandler handler : this.handlers) {
|
||||
final Message<?> messageToSend = (!this.applySequence) ? message
|
||||
: MessageBuilder.fromMessage(message)
|
||||
.setSequenceNumber(sequenceNumber++)
|
||||
@@ -56,12 +56,12 @@ public class BroadcastingDispatcher extends AbstractDispatcher {
|
||||
if (executor != null) {
|
||||
executor.execute(new Runnable() {
|
||||
public void run() {
|
||||
BroadcastingDispatcher.this.sendMessageToConsumer(messageToSend, consumer);
|
||||
BroadcastingDispatcher.this.sendMessageToHandler(messageToSend, handler);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.sendMessageToConsumer(messageToSend, consumer);
|
||||
this.sendMessageToHandler(messageToSend, handler);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -17,18 +17,18 @@
|
||||
package org.springframework.integration.dispatcher;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* Strategy interface for dispatching messages to consumers.
|
||||
* Strategy interface for dispatching messages to handlers.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public interface MessageDispatcher {
|
||||
|
||||
boolean addConsumer(MessageConsumer consumer);
|
||||
boolean addHandler(MessageHandler handler);
|
||||
|
||||
boolean removeConsumer(MessageConsumer consumer);
|
||||
boolean removeHandler(MessageHandler handler);
|
||||
|
||||
boolean dispatch(Message<?> message);
|
||||
|
||||
|
||||
@@ -17,17 +17,17 @@
|
||||
package org.springframework.integration.dispatcher;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
import org.springframework.integration.message.MessageRejectedException;
|
||||
|
||||
/**
|
||||
* Basic implementation of {@link MessageDispatcher} that will attempt
|
||||
* to send a {@link Message} to one of its consumers. As soon as <em>one</em>
|
||||
* of the consumers accepts the Message, the dispatcher will return 'true'.
|
||||
* to send a {@link Message} to one of its handlers. As soon as <em>one</em>
|
||||
* of the handlers accepts the Message, the dispatcher will return 'true'.
|
||||
* <p>
|
||||
* If the dispatcher has no consumers, a {@link MessageDeliveryException}
|
||||
* will be thrown. If all consumers reject the Message, the dispatcher will
|
||||
* If the dispatcher has no handlers, a {@link MessageDeliveryException}
|
||||
* will be thrown. If all handlers reject the Message, the dispatcher will
|
||||
* throw a MessageRejectedException.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
@@ -35,14 +35,14 @@ import org.springframework.integration.message.MessageRejectedException;
|
||||
public class SimpleDispatcher extends AbstractDispatcher {
|
||||
|
||||
public boolean dispatch(Message<?> message) {
|
||||
if (this.consumers.size() == 0) {
|
||||
if (this.handlers.size() == 0) {
|
||||
throw new MessageDeliveryException(message, "Dispatcher has no subscribers.");
|
||||
}
|
||||
int count = 0;
|
||||
int rejectedExceptionCount = 0;
|
||||
for (MessageConsumer consumer : this.consumers) {
|
||||
for (MessageHandler handler : this.handlers) {
|
||||
count++;
|
||||
if (this.sendMessageToConsumer(message, consumer)) {
|
||||
if (this.sendMessageToHandler(message, handler)) {
|
||||
return true;
|
||||
}
|
||||
rejectedExceptionCount++;
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.endpoint;
|
||||
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -26,18 +26,18 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class PollingConsumerEndpoint extends AbstractPollingEndpoint {
|
||||
|
||||
private final MessageConsumer consumer;
|
||||
|
||||
private final PollableChannel inputChannel;
|
||||
|
||||
private final MessageHandler handler;
|
||||
|
||||
private volatile long receiveTimeout = 1000;
|
||||
|
||||
|
||||
public PollingConsumerEndpoint(MessageConsumer consumer, PollableChannel inputChannel) {
|
||||
Assert.notNull(consumer, "consumer must not be null");
|
||||
public PollingConsumerEndpoint(PollableChannel inputChannel, MessageHandler handler) {
|
||||
Assert.notNull(inputChannel, "inputChannel must not be null");
|
||||
this.consumer = consumer;
|
||||
Assert.notNull(handler, "handler must not be null");
|
||||
this.inputChannel = inputChannel;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ public class PollingConsumerEndpoint extends AbstractPollingEndpoint {
|
||||
if (message == null) {
|
||||
return false;
|
||||
}
|
||||
this.consumer.onMessage(message);
|
||||
this.handler.handleMessage(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.endpoint;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.channel.SubscribableChannel;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -26,20 +26,20 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class SubscribingConsumerEndpoint extends AbstractEndpoint implements Lifecycle {
|
||||
|
||||
private final MessageConsumer consumer;
|
||||
|
||||
private final SubscribableChannel inputChannel;
|
||||
|
||||
private final MessageHandler handler;
|
||||
|
||||
private volatile boolean running;
|
||||
|
||||
private final Object lifecycleMonitor = new Object();
|
||||
|
||||
|
||||
public SubscribingConsumerEndpoint(MessageConsumer consumer, SubscribableChannel inputChannel) {
|
||||
Assert.notNull(consumer, "consumer must not be null");
|
||||
public SubscribingConsumerEndpoint(SubscribableChannel inputChannel, MessageHandler handler) {
|
||||
Assert.notNull(inputChannel, "inputChannel must not be null");
|
||||
this.consumer = consumer;
|
||||
Assert.notNull(handler, "handler must not be null");
|
||||
this.inputChannel = inputChannel;
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ public class SubscribingConsumerEndpoint extends AbstractEndpoint implements Lif
|
||||
public void start() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
if (!this.running) {
|
||||
this.inputChannel.subscribe(this.consumer);
|
||||
this.inputChannel.subscribe(this.handler);
|
||||
this.running = true;
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class SubscribingConsumerEndpoint extends AbstractEndpoint implements Lif
|
||||
public void stop() {
|
||||
synchronized (this.lifecycleMonitor) {
|
||||
if (this.running) {
|
||||
this.inputChannel.unsubscribe(this.consumer);
|
||||
this.inputChannel.unsubscribe(this.handler);
|
||||
this.running = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,20 +16,20 @@
|
||||
|
||||
package org.springframework.integration.filter;
|
||||
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.selector.MessageSelector;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Message Consumer that delegates to a {@link MessageSelector}. If and only if
|
||||
* Message Handler that delegates to a {@link MessageSelector}. If and only if
|
||||
* the selector {@link MessageSelector#accept(Message) accepts} the Message, it
|
||||
* will be passed to this filter's output channel.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MessageFilter extends AbstractReplyProducingMessageConsumer {
|
||||
public class MessageFilter extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
private MessageSelector selector;
|
||||
|
||||
@@ -41,7 +41,7 @@ public class MessageFilter extends AbstractReplyProducingMessageConsumer {
|
||||
|
||||
|
||||
@Override
|
||||
protected void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
protected void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
if (this.selector.accept(message)) {
|
||||
replyHolder.set(message);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.channel.SubscribableChannel;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -30,7 +30,7 @@ import org.springframework.integration.endpoint.MessagingGateway;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
import org.springframework.integration.message.ErrorMessage;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
import org.springframework.integration.scheduling.TaskScheduler;
|
||||
import org.springframework.integration.scheduling.TaskSchedulerAware;
|
||||
@@ -178,19 +178,19 @@ public abstract class AbstractMessagingGateway implements MessagingGateway, Mess
|
||||
return;
|
||||
}
|
||||
MessageEndpoint correlator = null;
|
||||
MessageConsumer consumer = new AbstractReplyProducingMessageConsumer() {
|
||||
MessageHandler handler = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
protected void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
protected void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
replyHolder.set(message);
|
||||
}
|
||||
};
|
||||
if (this.replyChannel instanceof SubscribableChannel) {
|
||||
correlator = new SubscribingConsumerEndpoint(
|
||||
consumer, (SubscribableChannel) this.replyChannel);
|
||||
(SubscribableChannel) this.replyChannel, handler);
|
||||
}
|
||||
else if (this.replyChannel instanceof PollableChannel) {
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(
|
||||
consumer, (PollableChannel) this.replyChannel);
|
||||
(PollableChannel) this.replyChannel, handler);
|
||||
endpoint.setTaskScheduler(this.taskScheduler);
|
||||
endpoint.afterPropertiesSet();
|
||||
correlator = endpoint;
|
||||
|
||||
@@ -19,12 +19,12 @@ package org.springframework.integration.message;
|
||||
import org.springframework.integration.core.Message;
|
||||
|
||||
/**
|
||||
* Base interface for any component that consumes Messages.
|
||||
* Base interface for any component that handles Messages.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public interface MessageConsumer {
|
||||
public interface MessageHandler {
|
||||
|
||||
void onMessage(Message<?> message);
|
||||
void handleMessage(Message<?> message);
|
||||
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.router;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.consumer.AbstractMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractMessageHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
@@ -29,7 +29,7 @@ import org.springframework.integration.message.MessageDeliveryException;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractMessageRouter extends AbstractMessageConsumer {
|
||||
public abstract class AbstractMessageRouter extends AbstractMessageHandler {
|
||||
|
||||
private volatile MessageChannel defaultOutputChannel;
|
||||
|
||||
@@ -67,7 +67,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageConsumer {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMessageInternal(Message<?> message) {
|
||||
protected void handleMessageInternal(Message<?> message) {
|
||||
boolean sent = false;
|
||||
Collection<MessageChannel> results = this.determineTargetChannels(message);
|
||||
if (results != null) {
|
||||
|
||||
@@ -18,19 +18,19 @@ package org.springframework.integration.splitter;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
|
||||
/**
|
||||
* Base class for Message-splitting consumers.
|
||||
* Base class for Message-splitting handlers.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public abstract class AbstractMessageSplitter extends AbstractReplyProducingMessageConsumer {
|
||||
public abstract class AbstractMessageSplitter extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
@Override
|
||||
protected final void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
protected final void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
Object result = this.splitMessage(message);
|
||||
if (result == null) {
|
||||
return;
|
||||
|
||||
@@ -16,35 +16,35 @@
|
||||
|
||||
package org.springframework.integration.transformer;
|
||||
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A reply-producing {@link org.springframework.integration.message.MessageConsumer}
|
||||
* that delegates to a {@link Transformer} instance to modify the received
|
||||
* {@link Message} and send the result to its output channel.
|
||||
* A reply-producing {@link MessageHandler} that delegates to a
|
||||
* {@link Transformer} instance to modify the received {@link Message}
|
||||
* and sends the result to its output channel.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MessageTransformingConsumer extends AbstractReplyProducingMessageConsumer {
|
||||
public class MessageTransformingHandler extends AbstractReplyProducingMessageHandler {
|
||||
|
||||
private final Transformer transformer;
|
||||
|
||||
|
||||
/**
|
||||
* Create a {@link MessageTransformingConsumer} instance that delegates to
|
||||
* Create a {@link MessageTransformingHandler} instance that delegates to
|
||||
* the provided {@link Transformer}.
|
||||
*/
|
||||
public MessageTransformingConsumer(Transformer transformer) {
|
||||
public MessageTransformingHandler(Transformer transformer) {
|
||||
Assert.notNull(transformer, "transformer must not be null");
|
||||
this.transformer = transformer;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
protected void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
try {
|
||||
Message<?> result = transformer.transform(message);
|
||||
if (result != null) {
|
||||
@@ -153,9 +153,9 @@ public class AggregatorEndpointTests {
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
QueueChannel discardChannel = new QueueChannel();
|
||||
this.aggregator.setDiscardChannel(discardChannel);
|
||||
this.aggregator.onMessage(createMessage("test-1a", 1, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-1a", 1, 1, 1, replyChannel));
|
||||
assertEquals("test-1a", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-1b", 1, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-1b", 1, 1, 1, replyChannel));
|
||||
assertEquals("test-1b", discardChannel.receive(100).getPayload());
|
||||
}
|
||||
|
||||
@@ -165,13 +165,13 @@ public class AggregatorEndpointTests {
|
||||
QueueChannel discardChannel = new QueueChannel();
|
||||
this.aggregator.setTrackedCorrelationIdCapacity(3);
|
||||
this.aggregator.setDiscardChannel(discardChannel);
|
||||
this.aggregator.onMessage(createMessage("test-1a", 1, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-1a", 1, 1, 1, replyChannel));
|
||||
assertEquals("test-1a", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-2", 2, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-2", 2, 1, 1, replyChannel));
|
||||
assertEquals("test-2", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-3", 3, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-3", 3, 1, 1, replyChannel));
|
||||
assertEquals("test-3", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-1b", 1, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-1b", 1, 1, 1, replyChannel));
|
||||
assertEquals("test-1b", discardChannel.receive(100).getPayload());
|
||||
}
|
||||
|
||||
@@ -181,15 +181,15 @@ public class AggregatorEndpointTests {
|
||||
QueueChannel discardChannel = new QueueChannel();
|
||||
this.aggregator.setTrackedCorrelationIdCapacity(3);
|
||||
this.aggregator.setDiscardChannel(discardChannel);
|
||||
this.aggregator.onMessage(createMessage("test-1a", 1, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-1a", 1, 1, 1, replyChannel));
|
||||
assertEquals("test-1a", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-2", 2, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-2", 2, 1, 1, replyChannel));
|
||||
assertEquals("test-2", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-3", 3, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-3", 3, 1, 1, replyChannel));
|
||||
assertEquals("test-3", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-4", 4, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-4", 4, 1, 1, replyChannel));
|
||||
assertEquals("test-4", replyChannel.receive(100).getPayload());
|
||||
this.aggregator.onMessage(createMessage("test-1b", 1, 1, 1, replyChannel));
|
||||
this.aggregator.handleMessage(createMessage("test-1b", 1, 1, 1, replyChannel));
|
||||
assertEquals("test-1b", replyChannel.receive(100).getPayload());
|
||||
assertNull(discardChannel.receive(0));
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public class AggregatorEndpointTests {
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
public void testExceptionThrownIfNoCorrelationId() throws InterruptedException {
|
||||
Message<?> message = createMessage("123", null, 2, 1, new QueueChannel());
|
||||
this.aggregator.onMessage(message);
|
||||
this.aggregator.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -311,7 +311,7 @@ public class AggregatorEndpointTests {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
this.aggregator.onMessage(message);
|
||||
this.aggregator.handleMessage(message);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.exception = e;
|
||||
|
||||
@@ -57,9 +57,9 @@ public class ResequencerTests {
|
||||
Message<?> message1 = createMessage("123", "ABC", 3, 3, replyChannel);
|
||||
Message<?> message2 = createMessage("456", "ABC", 3, 1, replyChannel);
|
||||
Message<?> message3 = createMessage("789", "ABC", 3, 2, replyChannel);
|
||||
this.resequencer.onMessage(message1);
|
||||
this.resequencer.onMessage(message3);
|
||||
this.resequencer.onMessage(message2);
|
||||
this.resequencer.handleMessage(message1);
|
||||
this.resequencer.handleMessage(message3);
|
||||
this.resequencer.handleMessage(message2);
|
||||
Message<?> reply1 = replyChannel.receive(0);
|
||||
Message<?> reply2 = replyChannel.receive(0);
|
||||
Message<?> reply3 = replyChannel.receive(0);
|
||||
@@ -79,9 +79,9 @@ public class ResequencerTests {
|
||||
Message<?> message2 = createMessage("456", "ABC", 4, 1, replyChannel);
|
||||
Message<?> message3 = createMessage("789", "ABC", 4, 4, replyChannel);
|
||||
Message<?> message4 = createMessage("XYZ", "ABC", 4, 3, replyChannel);
|
||||
this.resequencer.onMessage(message1);
|
||||
this.resequencer.onMessage(message2);
|
||||
this.resequencer.onMessage(message3);
|
||||
this.resequencer.handleMessage(message1);
|
||||
this.resequencer.handleMessage(message2);
|
||||
this.resequencer.handleMessage(message3);
|
||||
Message<?> reply1 = replyChannel.receive(0);
|
||||
Message<?> reply2 = replyChannel.receive(0);
|
||||
Message<?> reply3 = replyChannel.receive(0);
|
||||
@@ -92,7 +92,7 @@ public class ResequencerTests {
|
||||
assertEquals(new Integer(2), reply2.getHeaders().getSequenceNumber());
|
||||
assertNull(reply3);
|
||||
// when sending the last message, the whole sequence must have been sent
|
||||
this.resequencer.onMessage(message4);
|
||||
this.resequencer.handleMessage(message4);
|
||||
reply3 = replyChannel.receive(0);
|
||||
Message<?> reply4 = replyChannel.receive(0);
|
||||
assertNotNull(reply3);
|
||||
@@ -110,9 +110,9 @@ public class ResequencerTests {
|
||||
Message<?> message2 = createMessage("456", "ABC", 4, 1, replyChannel);
|
||||
Message<?> message3 = createMessage("789", "ABC", 4, 4, replyChannel);
|
||||
Message<?> message4 = createMessage("XYZ", "ABC", 4, 3, replyChannel);
|
||||
this.resequencer.onMessage(message1);
|
||||
this.resequencer.onMessage(message2);
|
||||
this.resequencer.onMessage(message3);
|
||||
this.resequencer.handleMessage(message1);
|
||||
this.resequencer.handleMessage(message2);
|
||||
this.resequencer.handleMessage(message3);
|
||||
Message<?> reply1 = replyChannel.receive(0);
|
||||
Message<?> reply2 = replyChannel.receive(0);
|
||||
Message<?> reply3 = replyChannel.receive(0);
|
||||
@@ -121,7 +121,7 @@ public class ResequencerTests {
|
||||
assertNull(reply2);
|
||||
assertNull(reply3);
|
||||
// after sending the last message, the whole sequence should have been sent
|
||||
this.resequencer.onMessage(message4);
|
||||
this.resequencer.handleMessage(message4);
|
||||
reply1 = replyChannel.receive(0);
|
||||
reply2 = replyChannel.receive(0);
|
||||
reply3 = replyChannel.receive(0);
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.config.xml.MessageBusParser;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
@@ -69,13 +69,13 @@ public class ApplicationContextMessageBusTests {
|
||||
Message<String> message = MessageBuilder.withPayload("test")
|
||||
.setReplyChannelName("targetChannel").build();
|
||||
sourceChannel.send(message);
|
||||
AbstractReplyProducingMessageConsumer consumer = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
replyHolder.set(message);
|
||||
}
|
||||
};
|
||||
consumer.setBeanFactory(context);
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(consumer, sourceChannel);
|
||||
handler.setBeanFactory(context);
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(sourceChannel, handler);
|
||||
endpoint.afterPropertiesSet();
|
||||
context.getBeanFactory().registerSingleton("testEndpoint", endpoint);
|
||||
context.refresh();
|
||||
@@ -128,13 +128,15 @@ public class ApplicationContextMessageBusTests {
|
||||
QueueChannel inputChannel = new QueueChannel();
|
||||
QueueChannel outputChannel1 = new QueueChannel();
|
||||
QueueChannel outputChannel2 = new QueueChannel();
|
||||
AbstractReplyProducingMessageConsumer consumer1 = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler1 = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
replyHolder.set(message);
|
||||
}
|
||||
};
|
||||
AbstractReplyProducingMessageConsumer consumer2 = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler2 = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
replyHolder.set(message);
|
||||
}
|
||||
};
|
||||
@@ -144,11 +146,11 @@ public class ApplicationContextMessageBusTests {
|
||||
context.getBeanFactory().registerSingleton("input", inputChannel);
|
||||
context.getBeanFactory().registerSingleton("output1", outputChannel1);
|
||||
context.getBeanFactory().registerSingleton("output2", outputChannel2);
|
||||
consumer1.setOutputChannel(outputChannel1);
|
||||
consumer2.setOutputChannel(outputChannel2);
|
||||
PollingConsumerEndpoint endpoint1 = new PollingConsumerEndpoint(consumer1, inputChannel);
|
||||
handler1.setOutputChannel(outputChannel1);
|
||||
handler2.setOutputChannel(outputChannel2);
|
||||
PollingConsumerEndpoint endpoint1 = new PollingConsumerEndpoint(inputChannel, handler1);
|
||||
endpoint1.afterPropertiesSet();
|
||||
PollingConsumerEndpoint endpoint2 = new PollingConsumerEndpoint(consumer2, inputChannel);
|
||||
PollingConsumerEndpoint endpoint2 = new PollingConsumerEndpoint(inputChannel, handler2);
|
||||
endpoint2.afterPropertiesSet();
|
||||
context.getBeanFactory().registerSingleton("testEndpoint1", endpoint1);
|
||||
context.getBeanFactory().registerSingleton("testEndpoint2", endpoint2);
|
||||
@@ -171,14 +173,16 @@ public class ApplicationContextMessageBusTests {
|
||||
QueueChannel outputChannel1 = new QueueChannel();
|
||||
QueueChannel outputChannel2 = new QueueChannel();
|
||||
final CountDownLatch latch = new CountDownLatch(2);
|
||||
AbstractReplyProducingMessageConsumer consumer1 = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler1 = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
replyHolder.set(message);
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
AbstractReplyProducingMessageConsumer consumer2 = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler2 = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
replyHolder.set(message);
|
||||
latch.countDown();
|
||||
}
|
||||
@@ -189,10 +193,10 @@ public class ApplicationContextMessageBusTests {
|
||||
context.getBeanFactory().registerSingleton("input", inputChannel);
|
||||
context.getBeanFactory().registerSingleton("output1", outputChannel1);
|
||||
context.getBeanFactory().registerSingleton("output2", outputChannel2);
|
||||
consumer1.setOutputChannel(outputChannel1);
|
||||
consumer2.setOutputChannel(outputChannel2);
|
||||
SubscribingConsumerEndpoint endpoint1 = new SubscribingConsumerEndpoint(consumer1, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint2 = new SubscribingConsumerEndpoint(consumer2, inputChannel);
|
||||
handler1.setOutputChannel(outputChannel1);
|
||||
handler2.setOutputChannel(outputChannel2);
|
||||
SubscribingConsumerEndpoint endpoint1 = new SubscribingConsumerEndpoint(inputChannel, handler1);
|
||||
SubscribingConsumerEndpoint endpoint2 = new SubscribingConsumerEndpoint(inputChannel, handler2);
|
||||
context.getBeanFactory().registerSingleton("testEndpoint1", endpoint1);
|
||||
context.getBeanFactory().registerSingleton("testEndpoint2", endpoint2);
|
||||
ApplicationContextMessageBus bus = new ApplicationContextMessageBus();
|
||||
@@ -256,12 +260,13 @@ public class ApplicationContextMessageBusTests {
|
||||
errorChannel.setBeanName(ApplicationContextMessageBus.ERROR_CHANNEL_BEAN_NAME);
|
||||
context.getBeanFactory().registerSingleton(ApplicationContextMessageBus.ERROR_CHANNEL_BEAN_NAME, errorChannel);
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
AbstractReplyProducingMessageConsumer consumer = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
latch.countDown();
|
||||
}
|
||||
};
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(consumer, errorChannel);
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(errorChannel, handler);
|
||||
endpoint.afterPropertiesSet();
|
||||
context.getBeanFactory().registerSingleton("testEndpoint", endpoint);
|
||||
ApplicationContextMessageBus bus = new ApplicationContextMessageBus();
|
||||
|
||||
@@ -29,9 +29,9 @@ import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.channel.ThreadLocalChannel;
|
||||
import org.springframework.integration.config.annotation.MessagingAnnotationPostProcessor;
|
||||
import org.springframework.integration.config.xml.MessageBusParser;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.consumer.ServiceActivatingHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.endpoint.SubscribingConsumerEndpoint;
|
||||
@@ -67,9 +67,9 @@ public class DirectChannelSubscriptionTests {
|
||||
@Test
|
||||
public void sendAndReceiveForRegisteredEndpoint() {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "handle");
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "handle");
|
||||
serviceActivator.setOutputChannel(targetChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, sourceChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(sourceChannel, serviceActivator);
|
||||
context.getBeanFactory().registerSingleton("testEndpoint", endpoint);
|
||||
bus.setApplicationContext(context);
|
||||
context.refresh();
|
||||
@@ -97,13 +97,14 @@ public class DirectChannelSubscriptionTests {
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
public void exceptionThrownFromRegisteredEndpoint() {
|
||||
AbstractReplyProducingMessageConsumer consumer = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
throw new RuntimeException("intentional test failure");
|
||||
}
|
||||
};
|
||||
consumer.setOutputChannel(targetChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(consumer, sourceChannel);
|
||||
handler.setOutputChannel(targetChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(sourceChannel, handler);
|
||||
context.getBeanFactory().registerSingleton("testEndpoint", endpoint);
|
||||
bus.setApplicationContext(context);
|
||||
context.refresh();
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<constructor-arg ref="sourceChannel"/>
|
||||
</bean>
|
||||
|
||||
<bean id="serviceActivator" class="org.springframework.integration.consumer.ServiceActivatingConsumer">
|
||||
<bean id="serviceActivator" class="org.springframework.integration.consumer.ServiceActivatingHandler">
|
||||
<constructor-arg ref="handler"/>
|
||||
<property name="outputChannel" ref="targetChannel"/>
|
||||
</bean>
|
||||
|
||||
@@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public class DirectChannelTests {
|
||||
}
|
||||
|
||||
|
||||
private static class ThreadNameExtractingTestTarget implements MessageConsumer {
|
||||
private static class ThreadNameExtractingTestTarget implements MessageHandler {
|
||||
|
||||
private String threadName;
|
||||
|
||||
@@ -75,7 +75,7 @@ public class DirectChannelTests {
|
||||
this.latch = latch;
|
||||
}
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
this.threadName = Thread.currentThread().getName();
|
||||
if (this.latch != null) {
|
||||
this.latch.countDown();
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.integration.bus.ApplicationContextMessageBus;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ReplyMessageHolder;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -52,12 +52,13 @@ public class MessageChannelTemplateTests {
|
||||
public void setUp() {
|
||||
this.requestChannel = new QueueChannel();
|
||||
this.requestChannel.setBeanName("requestChannel");
|
||||
AbstractReplyProducingMessageConsumer consumer = new AbstractReplyProducingMessageConsumer() {
|
||||
public void onMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
AbstractReplyProducingMessageHandler handler = new AbstractReplyProducingMessageHandler() {
|
||||
@Override
|
||||
public void handleRequestMessage(Message<?> message, ReplyMessageHolder replyHolder) {
|
||||
replyHolder.set(message.getPayload().toString().toUpperCase());
|
||||
}
|
||||
};
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(consumer, requestChannel);
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(requestChannel, handler);
|
||||
endpoint.afterPropertiesSet();
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("requestChannel", requestChannel);
|
||||
|
||||
@@ -78,7 +78,7 @@ public class AggregatorParserTests {
|
||||
CompletionStrategy completionStrategy = (CompletionStrategy) context.getBean("completionStrategy");
|
||||
MessageChannel outputChannel = (MessageChannel) context.getBean("outputChannel");
|
||||
MessageChannel discardChannel = (MessageChannel) context.getBean("discardChannel");
|
||||
Object consumer = new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Object consumer = new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
Assert.assertEquals(MethodInvokingAggregator.class, consumer.getClass());
|
||||
DirectFieldAccessor accessor = new DirectFieldAccessor(consumer);
|
||||
Method expectedMethod = TestAggregatorBean.class.getMethod("createSingleMessageFromGroup", List.class);
|
||||
@@ -138,7 +138,7 @@ public class AggregatorParserTests {
|
||||
SubscribingConsumerEndpoint endpoint =
|
||||
(SubscribingConsumerEndpoint) context.getBean("aggregatorWithPojoCompletionStrategy");
|
||||
CompletionStrategy completionStrategy = (CompletionStrategy) new DirectFieldAccessor(
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("consumer")).getPropertyValue("completionStrategy");
|
||||
new DirectFieldAccessor(endpoint).getPropertyValue("handler")).getPropertyValue("completionStrategy");
|
||||
Assert.assertTrue(completionStrategy instanceof CompletionStrategyAdapter);
|
||||
DirectFieldAccessor completionStrategyAccessor = new DirectFieldAccessor(completionStrategy);
|
||||
MethodInvoker invoker = (MethodInvoker) completionStrategyAccessor.getPropertyValue("invoker");
|
||||
|
||||
@@ -76,7 +76,7 @@ public class ResequencerParserTests {
|
||||
@Test
|
||||
public void testDefaultResequencerProperties() {
|
||||
SubscribingConsumerEndpoint endpoint = (SubscribingConsumerEndpoint) context.getBean("defaultResequencer");
|
||||
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertNull(getPropertyValue(resequencer, "outputChannel"));
|
||||
assertNull(getPropertyValue(resequencer, "discardChannel"));
|
||||
assertEquals("The ResequencerEndpoint is not set with the appropriate timeout value",
|
||||
@@ -98,7 +98,7 @@ public class ResequencerParserTests {
|
||||
SubscribingConsumerEndpoint endpoint = (SubscribingConsumerEndpoint) context.getBean("completelyDefinedResequencer");
|
||||
MessageChannel outputChannel = (MessageChannel) context.getBean("outputChannel");
|
||||
MessageChannel discardChannel = (MessageChannel) context.getBean("discardChannel");
|
||||
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
Resequencer resequencer = (Resequencer) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
assertEquals("The ResequencerEndpoint is not injected with the appropriate output channel",
|
||||
outputChannel, getPropertyValue(resequencer, "outputChannel"));
|
||||
assertEquals("The ResequencerEndpoint is not injected with the appropriate discard channel",
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class TestConsumer implements MessageConsumer {
|
||||
public class TestConsumer implements MessageHandler {
|
||||
|
||||
private volatile Message<?> lastMessage;
|
||||
|
||||
@@ -31,7 +31,7 @@ public class TestConsumer implements MessageConsumer {
|
||||
return this.lastMessage;
|
||||
}
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
this.lastMessage = message;
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +101,10 @@ public class AggregatorAnnotationTests {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private AbstractMessageAggregator getAggregator(ApplicationContext context, final String endpointName) {
|
||||
SubscribingConsumerEndpoint endpoint = (SubscribingConsumerEndpoint) context.getBean(
|
||||
endpointName + ".aggregatingMethod.aggregator");
|
||||
return (AbstractMessageAggregator) new DirectFieldAccessor(endpoint).getPropertyValue("consumer");
|
||||
return (AbstractMessageAggregator) new DirectFieldAccessor(endpoint).getPropertyValue("handler");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.integration.scheduling.IntervalTrigger;
|
||||
import org.springframework.integration.scheduling.Trigger;
|
||||
@@ -403,8 +403,8 @@ public class MessagingAnnotationPostProcessorTests {
|
||||
DirectChannel testChannel = (DirectChannel) channelResolver.resolveChannelName("testChannel");
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicReference<Message<?>> receivedMessage = new AtomicReference<Message<?>>();
|
||||
testChannel.subscribe(new MessageConsumer() {
|
||||
public void onMessage(Message<?> message) {
|
||||
testChannel.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message) {
|
||||
receivedMessage.set(message);
|
||||
latch.countDown();
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
/**
|
||||
@@ -50,11 +50,11 @@ public class BroadcastingDispatcherTests {
|
||||
|
||||
private Message<?> messageMock = createMock(Message.class);
|
||||
|
||||
private MessageConsumer targetMock1 = createMock(MessageConsumer.class);
|
||||
private MessageHandler targetMock1 = createMock(MessageHandler.class);
|
||||
|
||||
private MessageConsumer targetMock2 = createMock(MessageConsumer.class);
|
||||
private MessageHandler targetMock2 = createMock(MessageHandler.class);
|
||||
|
||||
private MessageConsumer targetMock3 = createMock(MessageConsumer.class);
|
||||
private MessageHandler targetMock3 = createMock(MessageHandler.class);
|
||||
|
||||
private Object[] globalMocks = new Object[] {
|
||||
messageMock, taskExecutorMock, targetMock1, targetMock2, targetMock3 };
|
||||
@@ -72,8 +72,8 @@ public class BroadcastingDispatcherTests {
|
||||
@Test
|
||||
public void singleTargetWithoutTaskExecutor() throws Exception {
|
||||
dispatcher.setTaskExecutor(null);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
targetMock1.onMessage(messageMock);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -82,8 +82,8 @@ public class BroadcastingDispatcherTests {
|
||||
|
||||
@Test
|
||||
public void singleTargetWithTaskExecutor() throws Exception {
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
targetMock1.onMessage(messageMock);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -93,14 +93,14 @@ public class BroadcastingDispatcherTests {
|
||||
@Test
|
||||
public void multipleTargetsWithoutTaskExecutor() {
|
||||
dispatcher.setTaskExecutor(null);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
targetMock1.onMessage(messageMock);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock2.onMessage(messageMock);
|
||||
targetMock2.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock3.onMessage(messageMock);
|
||||
targetMock3.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -109,14 +109,14 @@ public class BroadcastingDispatcherTests {
|
||||
|
||||
@Test
|
||||
public void multipleTargetsWithTaskExecutor() {
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
targetMock1.onMessage(messageMock);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock2.onMessage(messageMock);
|
||||
targetMock2.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock3.onMessage(messageMock);
|
||||
targetMock3.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -126,13 +126,13 @@ public class BroadcastingDispatcherTests {
|
||||
@Test
|
||||
public void multipleTargetsPartialFailureFirst() {
|
||||
reset(taskExecutorMock);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
partialFailingExecutorMock(false, true, true);
|
||||
targetMock2.onMessage(messageMock);
|
||||
targetMock2.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock3.onMessage(messageMock);
|
||||
targetMock3.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -142,13 +142,13 @@ public class BroadcastingDispatcherTests {
|
||||
@Test
|
||||
public void multipleTargetsPartialFailureMiddle() {
|
||||
reset(taskExecutorMock);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
partialFailingExecutorMock(true, false, true);
|
||||
targetMock1.onMessage(messageMock);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock3.onMessage(messageMock);
|
||||
targetMock3.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -158,13 +158,13 @@ public class BroadcastingDispatcherTests {
|
||||
@Test
|
||||
public void multipleTargetsPartialFailureLast() {
|
||||
reset(taskExecutorMock);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
partialFailingExecutorMock(true, true, false);
|
||||
targetMock1.onMessage(messageMock);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock2.onMessage(messageMock);
|
||||
targetMock2.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -174,9 +174,9 @@ public class BroadcastingDispatcherTests {
|
||||
@Test
|
||||
public void multipleTargetsAllFail() {
|
||||
reset(taskExecutorMock);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
partialFailingExecutorMock(false, false, false);
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -185,10 +185,10 @@ public class BroadcastingDispatcherTests {
|
||||
|
||||
@Test
|
||||
public void noDuplicateSubscription() {
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
targetMock1.onMessage(messageMock);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -197,13 +197,13 @@ public class BroadcastingDispatcherTests {
|
||||
|
||||
@Test
|
||||
public void removeConsumerBeforeSend() {
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
dispatcher.removeConsumer(targetMock2);
|
||||
targetMock1.onMessage(messageMock);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
dispatcher.removeHandler(targetMock2);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock3.onMessage(messageMock);
|
||||
targetMock3.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
@@ -212,18 +212,18 @@ public class BroadcastingDispatcherTests {
|
||||
|
||||
@Test
|
||||
public void removeConsumerBetweenSends() {
|
||||
dispatcher.addConsumer(targetMock1);
|
||||
dispatcher.addConsumer(targetMock2);
|
||||
dispatcher.addConsumer(targetMock3);
|
||||
targetMock1.onMessage(messageMock);
|
||||
dispatcher.addHandler(targetMock1);
|
||||
dispatcher.addHandler(targetMock2);
|
||||
dispatcher.addHandler(targetMock3);
|
||||
targetMock1.handleMessage(messageMock);
|
||||
expectLastCall().times(2);
|
||||
targetMock2.onMessage(messageMock);
|
||||
targetMock2.handleMessage(messageMock);
|
||||
expectLastCall();
|
||||
targetMock3.onMessage(messageMock);
|
||||
targetMock3.handleMessage(messageMock);
|
||||
expectLastCall().times(2);
|
||||
replay(globalMocks);
|
||||
dispatcher.dispatch(messageMock);
|
||||
dispatcher.removeConsumer(targetMock2);
|
||||
dispatcher.removeHandler(targetMock2);
|
||||
dispatcher.dispatch(messageMock);
|
||||
verify(globalMocks);
|
||||
}
|
||||
@@ -232,10 +232,10 @@ public class BroadcastingDispatcherTests {
|
||||
public void applySequenceDisabledByDefault() {
|
||||
BroadcastingDispatcher dispatcher = new BroadcastingDispatcher();
|
||||
final List<Message<?>> messages = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageConsumer target1 = new MessageStoringTestEndpoint(messages);
|
||||
MessageConsumer target2 = new MessageStoringTestEndpoint(messages);
|
||||
dispatcher.addConsumer(target1);
|
||||
dispatcher.addConsumer(target2);
|
||||
MessageHandler target1 = new MessageStoringTestEndpoint(messages);
|
||||
MessageHandler target2 = new MessageStoringTestEndpoint(messages);
|
||||
dispatcher.addHandler(target1);
|
||||
dispatcher.addHandler(target2);
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
assertEquals(2, messages.size());
|
||||
assertEquals(0, (int) messages.get(0).getHeaders().getSequenceNumber());
|
||||
@@ -249,12 +249,12 @@ public class BroadcastingDispatcherTests {
|
||||
BroadcastingDispatcher dispatcher = new BroadcastingDispatcher();
|
||||
dispatcher.setApplySequence(true);
|
||||
final List<Message<?>> messages = Collections.synchronizedList(new ArrayList<Message<?>>());
|
||||
MessageConsumer target1 = new MessageStoringTestEndpoint(messages);
|
||||
MessageConsumer target2 = new MessageStoringTestEndpoint(messages);
|
||||
MessageConsumer target3 = new MessageStoringTestEndpoint(messages);
|
||||
dispatcher.addConsumer(target1);
|
||||
dispatcher.addConsumer(target2);
|
||||
dispatcher.addConsumer(target3);
|
||||
MessageHandler target1 = new MessageStoringTestEndpoint(messages);
|
||||
MessageHandler target2 = new MessageStoringTestEndpoint(messages);
|
||||
MessageHandler target3 = new MessageStoringTestEndpoint(messages);
|
||||
dispatcher.addHandler(target1);
|
||||
dispatcher.addHandler(target2);
|
||||
dispatcher.addHandler(target3);
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
assertEquals(3, messages.size());
|
||||
assertEquals(1, (int) messages.get(0).getHeaders().getSequenceNumber());
|
||||
@@ -294,7 +294,7 @@ public class BroadcastingDispatcherTests {
|
||||
}
|
||||
|
||||
|
||||
private static class MessageStoringTestEndpoint implements MessageConsumer {
|
||||
private static class MessageStoringTestEndpoint implements MessageHandler {
|
||||
|
||||
private final List<Message<?>> messageList;
|
||||
|
||||
@@ -302,7 +302,7 @@ public class BroadcastingDispatcherTests {
|
||||
this.messageList = messageList;
|
||||
}
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
this.messageList.add(message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,10 +26,10 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageConsumer;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.consumer.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.consumer.ServiceActivatingHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageDeliveryException;
|
||||
import org.springframework.integration.message.MessageRejectedException;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
@@ -45,7 +45,7 @@ public class SimpleDispatcherTests {
|
||||
public void singleMessage() throws InterruptedException {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
dispatcher.addConsumer(createConsumer(TestHandlers.countDownHandler(latch)));
|
||||
dispatcher.addHandler(createConsumer(TestHandlers.countDownHandler(latch)));
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
latch.await(500, TimeUnit.MILLISECONDS);
|
||||
assertEquals(0, latch.getCount());
|
||||
@@ -57,8 +57,8 @@ public class SimpleDispatcherTests {
|
||||
final CountDownLatch latch = new CountDownLatch(1);
|
||||
final AtomicInteger counter1 = new AtomicInteger();
|
||||
final AtomicInteger counter2 = new AtomicInteger();
|
||||
dispatcher.addConsumer(createConsumer(TestHandlers.countingCountDownHandler(counter1, latch)));
|
||||
dispatcher.addConsumer(createConsumer(TestHandlers.countingCountDownHandler(counter2, latch)));
|
||||
dispatcher.addHandler(createConsumer(TestHandlers.countingCountDownHandler(counter1, latch)));
|
||||
dispatcher.addHandler(createConsumer(TestHandlers.countingCountDownHandler(counter2, latch)));
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
latch.await(500, TimeUnit.MILLISECONDS);
|
||||
assertEquals(0, latch.getCount());
|
||||
@@ -69,9 +69,9 @@ public class SimpleDispatcherTests {
|
||||
public void noDuplicateSubscriptions() {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
MessageConsumer target = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addConsumer(target);
|
||||
dispatcher.addConsumer(target);
|
||||
MessageHandler target = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addHandler(target);
|
||||
dispatcher.addHandler(target);
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
}
|
||||
@@ -85,13 +85,13 @@ public class SimpleDispatcherTests {
|
||||
public void removeConsumerBeforeSend() {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
MessageConsumer target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addConsumer(target1);
|
||||
dispatcher.addConsumer(target2);
|
||||
dispatcher.addConsumer(target3);
|
||||
dispatcher.removeConsumer(target2);
|
||||
MessageHandler target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addHandler(target1);
|
||||
dispatcher.addHandler(target2);
|
||||
dispatcher.addHandler(target3);
|
||||
dispatcher.removeHandler(target2);
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
}
|
||||
@@ -105,12 +105,12 @@ public class SimpleDispatcherTests {
|
||||
public void removeConsumerBetweenSends() {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
MessageConsumer target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addConsumer(target1);
|
||||
dispatcher.addConsumer(target2);
|
||||
dispatcher.addConsumer(target3);
|
||||
MessageHandler target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addHandler(target1);
|
||||
dispatcher.addHandler(target2);
|
||||
dispatcher.addHandler(target3);
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test1"));
|
||||
}
|
||||
@@ -118,7 +118,7 @@ public class SimpleDispatcherTests {
|
||||
// ignore
|
||||
}
|
||||
assertEquals(3, counter.get());
|
||||
dispatcher.removeConsumer(target2);
|
||||
dispatcher.removeHandler(target2);
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test2"));
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class SimpleDispatcherTests {
|
||||
// ignore
|
||||
}
|
||||
assertEquals(5, counter.get());
|
||||
dispatcher.removeConsumer(target1);
|
||||
dispatcher.removeHandler(target1);
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test3"));
|
||||
}
|
||||
@@ -140,8 +140,8 @@ public class SimpleDispatcherTests {
|
||||
public void removeConsumerLastTargetCausesDeliveryException() {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
MessageConsumer target = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addConsumer(target);
|
||||
MessageHandler target = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addHandler(target);
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test1"));
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public class SimpleDispatcherTests {
|
||||
// ignore
|
||||
}
|
||||
assertEquals(1, counter.get());
|
||||
dispatcher.removeConsumer(target);
|
||||
dispatcher.removeHandler(target);
|
||||
dispatcher.dispatch(new StringMessage("test2"));
|
||||
}
|
||||
|
||||
@@ -161,15 +161,15 @@ public class SimpleDispatcherTests {
|
||||
final AtomicInteger counter2 = new AtomicInteger();
|
||||
final AtomicInteger counter3 = new AtomicInteger();
|
||||
final AtomicInteger selectorCounter = new AtomicInteger();
|
||||
AbstractReplyProducingMessageConsumer consumer1 = createConsumer(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer2 = createConsumer(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer3 = createConsumer(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
AbstractReplyProducingMessageHandler consumer1 = createConsumer(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageHandler consumer2 = createConsumer(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageHandler consumer3 = createConsumer(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
consumer1.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer2.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer3.setSelector(new TestMessageSelector(selectorCounter, true));
|
||||
dispatcher.addConsumer(consumer1);
|
||||
dispatcher.addConsumer(consumer2);
|
||||
dispatcher.addConsumer(consumer3);
|
||||
dispatcher.addHandler(consumer1);
|
||||
dispatcher.addHandler(consumer2);
|
||||
dispatcher.addHandler(consumer3);
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
assertEquals(0, latch.getCount());
|
||||
assertEquals("selectors should have been invoked one time each", 3, selectorCounter.get());
|
||||
@@ -186,15 +186,15 @@ public class SimpleDispatcherTests {
|
||||
final AtomicInteger counter2 = new AtomicInteger();
|
||||
final AtomicInteger counter3 = new AtomicInteger();
|
||||
final AtomicInteger selectorCounter = new AtomicInteger();
|
||||
AbstractReplyProducingMessageConsumer consumer1 = createConsumer(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer2 = createConsumer(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageConsumer consumer3 = createConsumer(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
AbstractReplyProducingMessageHandler consumer1 = createConsumer(TestHandlers.countingCountDownHandler(counter1, latch));
|
||||
AbstractReplyProducingMessageHandler consumer2 = createConsumer(TestHandlers.countingCountDownHandler(counter2, latch));
|
||||
AbstractReplyProducingMessageHandler consumer3 = createConsumer(TestHandlers.countingCountDownHandler(counter3, latch));
|
||||
consumer1.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer2.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
consumer3.setSelector(new TestMessageSelector(selectorCounter, false));
|
||||
dispatcher.addConsumer(consumer1);
|
||||
dispatcher.addConsumer(consumer2);
|
||||
dispatcher.addConsumer(consumer3);
|
||||
dispatcher.addHandler(consumer1);
|
||||
dispatcher.addHandler(consumer2);
|
||||
dispatcher.addHandler(consumer3);
|
||||
boolean exceptionThrown = false;
|
||||
try {
|
||||
dispatcher.dispatch(new StringMessage("test"));
|
||||
@@ -213,12 +213,12 @@ public class SimpleDispatcherTests {
|
||||
public void firstHandlerReturnsTrue() {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
MessageConsumer target1 = new CountingTestEndpoint(counter, true);
|
||||
MessageConsumer target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addConsumer(target1);
|
||||
dispatcher.addConsumer(target2);
|
||||
dispatcher.addConsumer(target3);
|
||||
MessageHandler target1 = new CountingTestEndpoint(counter, true);
|
||||
MessageHandler target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addHandler(target1);
|
||||
dispatcher.addHandler(target2);
|
||||
dispatcher.addHandler(target3);
|
||||
assertTrue(dispatcher.dispatch(new StringMessage("test")));
|
||||
assertEquals("only the first target should have been invoked", 1, counter.get());
|
||||
}
|
||||
@@ -227,12 +227,12 @@ public class SimpleDispatcherTests {
|
||||
public void middleHandlerReturnsTrue() {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
MessageConsumer target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target2 = new CountingTestEndpoint(counter, true);
|
||||
MessageConsumer target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addConsumer(target1);
|
||||
dispatcher.addConsumer(target2);
|
||||
dispatcher.addConsumer(target3);
|
||||
MessageHandler target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target2 = new CountingTestEndpoint(counter, true);
|
||||
MessageHandler target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addHandler(target1);
|
||||
dispatcher.addHandler(target2);
|
||||
dispatcher.addHandler(target3);
|
||||
assertTrue(dispatcher.dispatch(new StringMessage("test")));
|
||||
assertEquals("first two targets should have been invoked", 2, counter.get());
|
||||
}
|
||||
@@ -241,12 +241,12 @@ public class SimpleDispatcherTests {
|
||||
public void allHandlersReturnFalse() {
|
||||
SimpleDispatcher dispatcher = new SimpleDispatcher();
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
MessageConsumer target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageConsumer target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addConsumer(target1);
|
||||
dispatcher.addConsumer(target2);
|
||||
dispatcher.addConsumer(target3);
|
||||
MessageHandler target1 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target2 = new CountingTestEndpoint(counter, false);
|
||||
MessageHandler target3 = new CountingTestEndpoint(counter, false);
|
||||
dispatcher.addHandler(target1);
|
||||
dispatcher.addHandler(target2);
|
||||
dispatcher.addHandler(target3);
|
||||
try {
|
||||
assertFalse(dispatcher.dispatch(new StringMessage("test")));
|
||||
}
|
||||
@@ -257,8 +257,8 @@ public class SimpleDispatcherTests {
|
||||
}
|
||||
|
||||
|
||||
private static ServiceActivatingConsumer createConsumer(Object object) {
|
||||
return new ServiceActivatingConsumer(object);
|
||||
private static ServiceActivatingHandler createConsumer(Object object) {
|
||||
return new ServiceActivatingHandler(object);
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +280,7 @@ public class SimpleDispatcherTests {
|
||||
}
|
||||
|
||||
|
||||
private static class CountingTestEndpoint implements MessageConsumer {
|
||||
private static class CountingTestEndpoint implements MessageHandler {
|
||||
|
||||
private final AtomicInteger counter;
|
||||
|
||||
@@ -291,7 +291,7 @@ public class SimpleDispatcherTests {
|
||||
this.shouldAccept = shouldAccept;
|
||||
}
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
this.counter.incrementAndGet();
|
||||
if (!this.shouldAccept) {
|
||||
throw new MessageRejectedException(message, "intentional test failure");
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.consumer.ServiceActivatingHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
@@ -42,9 +42,9 @@ public class CorrelationIdTests {
|
||||
.setCorrelationId(correlationId).build();
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "upperCase");
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "upperCase");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(inputChannel, serviceActivator);
|
||||
endpoint.start();
|
||||
assertTrue(inputChannel.send(message));
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
@@ -57,9 +57,9 @@ public class CorrelationIdTests {
|
||||
.setCorrelationId("correlationId").build();
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "upperCase");
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "upperCase");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(inputChannel, serviceActivator);
|
||||
endpoint.start();
|
||||
assertTrue(inputChannel.send(message));
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
@@ -74,9 +74,9 @@ public class CorrelationIdTests {
|
||||
.setCorrelationId(correlationId).build();
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "createMessage");
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "createMessage");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(inputChannel, serviceActivator);
|
||||
endpoint.start();
|
||||
assertTrue(inputChannel.send(message));
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
@@ -88,9 +88,9 @@ public class CorrelationIdTests {
|
||||
Message<?> message = new StringMessage("test");
|
||||
DirectChannel inputChannel = new DirectChannel();
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(new TestBean(), "createMessage");
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(new TestBean(), "createMessage");
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(serviceActivator, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(inputChannel, serviceActivator);
|
||||
endpoint.start();
|
||||
assertTrue(inputChannel.send(message));
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
@@ -105,7 +105,7 @@ public class CorrelationIdTests {
|
||||
new TestBean(), TestBean.class.getMethod("split", String.class));
|
||||
splitter.setOutputChannel(testChannel);
|
||||
splitter.afterPropertiesSet();
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
Message<?> reply1 = testChannel.receive(100);
|
||||
Message<?> reply2 = testChannel.receive(100);
|
||||
assertEquals(message.getHeaders().getId(), reply1.getHeaders().getCorrelationId());
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.junit.Test;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageConsumer;
|
||||
import org.springframework.integration.message.MessageHandler;
|
||||
import org.springframework.integration.message.MessageRejectedException;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
import org.springframework.integration.scheduling.SimpleTaskScheduler;
|
||||
@@ -72,7 +72,7 @@ public class PollingConsumerEndpointTests {
|
||||
public void init() throws InterruptedException {
|
||||
consumer.counter.set(0);
|
||||
trigger.reset();
|
||||
endpoint = new PollingConsumerEndpoint(consumer, channelMock);
|
||||
endpoint = new PollingConsumerEndpoint(channelMock, consumer);
|
||||
endpoint.setTaskScheduler(taskScheduler);
|
||||
taskScheduler.setErrorHandler(errorHandler);
|
||||
taskScheduler.start();
|
||||
@@ -178,11 +178,11 @@ public class PollingConsumerEndpointTests {
|
||||
}
|
||||
|
||||
|
||||
private static class TestConsumer implements MessageConsumer {
|
||||
private static class TestConsumer implements MessageHandler {
|
||||
|
||||
private volatile AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
public void onMessage(Message<?> message) {
|
||||
public void handleMessage(Message<?> message) {
|
||||
this.counter.incrementAndGet();
|
||||
if ("bad".equals(message.getPayload().toString())) {
|
||||
throw new MessageRejectedException(message, "intentional test failure");
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.channel.TestChannelResolver;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.consumer.ServiceActivatingHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
@@ -50,10 +50,10 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void outputChannel() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
ServiceActivatingHandler endpoint = this.createEndpoint();
|
||||
endpoint.setOutputChannel(channel);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
Message<?> reply = channel.receive(0);
|
||||
assertNotNull(reply);
|
||||
assertEquals("FOO", reply.getPayload());
|
||||
@@ -63,10 +63,10 @@ public class ServiceActivatorEndpointTests {
|
||||
public void outputChannelTakesPrecedence() {
|
||||
QueueChannel channel1 = new QueueChannel(1);
|
||||
QueueChannel channel2 = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
ServiceActivatingHandler endpoint = this.createEndpoint();
|
||||
endpoint.setOutputChannel(channel1);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setReplyChannel(channel2).build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
Message<?> reply1 = channel1.receive(0);
|
||||
assertNotNull(reply1);
|
||||
assertEquals("FOO", reply1.getPayload());
|
||||
@@ -77,9 +77,9 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void returnAddressHeader() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
ServiceActivatingHandler endpoint = this.createEndpoint();
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setReplyChannel(channel).build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
Message<?> reply = channel.receive(0);
|
||||
assertNotNull(reply);
|
||||
assertEquals("FOO", reply.getPayload());
|
||||
@@ -91,11 +91,11 @@ public class ServiceActivatorEndpointTests {
|
||||
channel.setBeanName("testChannel");
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
channelResolver.addChannel(channel);
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
ServiceActivatingHandler endpoint = this.createEndpoint();
|
||||
endpoint.setChannelResolver(channelResolver);
|
||||
Message<?> message = MessageBuilder.withPayload("foo")
|
||||
.setReplyChannelName("testChannel").build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
Message<?> reply = channel.receive(0);
|
||||
assertNotNull(reply);
|
||||
assertEquals("FOO", reply.getPayload());
|
||||
@@ -112,13 +112,13 @@ public class ServiceActivatorEndpointTests {
|
||||
return new StringMessage("foo" + message.getPayload());
|
||||
}
|
||||
};
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(handler, "handle");
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(handler, "handle");
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
channelResolver.addChannel(replyChannel2);
|
||||
endpoint.setChannelResolver(channelResolver);
|
||||
Message<String> testMessage1 = MessageBuilder.withPayload("bar")
|
||||
.setReplyChannel(replyChannel1).build();
|
||||
endpoint.onMessage(testMessage1);
|
||||
endpoint.handleMessage(testMessage1);
|
||||
Message<?> reply1 = replyChannel1.receive(50);
|
||||
assertNotNull(reply1);
|
||||
assertEquals("foobar", reply1.getPayload());
|
||||
@@ -126,7 +126,7 @@ public class ServiceActivatorEndpointTests {
|
||||
assertNull(reply2);
|
||||
Message<String> testMessage2 = MessageBuilder.fromMessage(testMessage1)
|
||||
.setReplyChannelName("replyChannel2").build();
|
||||
endpoint.onMessage(testMessage2);
|
||||
endpoint.handleMessage(testMessage2);
|
||||
reply1 = replyChannel1.receive(0);
|
||||
assertNull(reply1);
|
||||
reply2 = replyChannel2.receive(0);
|
||||
@@ -137,9 +137,9 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void noOutputChannelFallsBackToReturnAddress() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
ServiceActivatingHandler endpoint = this.createEndpoint();
|
||||
Message<?> message = MessageBuilder.withPayload("foo").setReplyChannel(channel).build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
Message<?> reply = channel.receive(0);
|
||||
assertNotNull(reply);
|
||||
assertEquals("FOO", reply.getPayload());
|
||||
@@ -147,56 +147,56 @@ public class ServiceActivatorEndpointTests {
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
public void noReplyTarget() {
|
||||
ServiceActivatingConsumer endpoint = this.createEndpoint();
|
||||
ServiceActivatingHandler endpoint = this.createEndpoint();
|
||||
Message<?> message = MessageBuilder.withPayload("foo").build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noReplyMessage() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(
|
||||
new TestNullReplyBean(), "handle");
|
||||
endpoint.setOutputChannel(channel);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
assertNull(channel.receive(0));
|
||||
}
|
||||
|
||||
@Test(expected = MessageHandlingException.class)
|
||||
public void noReplyMessageWithRequiresReply() {
|
||||
QueueChannel channel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(
|
||||
new TestNullReplyBean(), "handle");
|
||||
endpoint.setRequiresReply(true);
|
||||
endpoint.setOutputChannel(channel);
|
||||
Message<?> message = MessageBuilder.withPayload("foo").build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected=MessageRejectedException.class)
|
||||
public void endpointWithSelectorRejecting() {
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(
|
||||
TestHandlers.nullHandler(), "handle");
|
||||
endpoint.setSelector(new MessageSelector() {
|
||||
public boolean accept(Message<?> message) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
endpoint.onMessage(new StringMessage("test"));
|
||||
endpoint.handleMessage(new StringMessage("test"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void endpointWithSelectorAccepting() throws InterruptedException {
|
||||
CountDownLatch latch = new CountDownLatch(1);
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(
|
||||
TestHandlers.countDownHandler(latch), "handle");
|
||||
endpoint.setSelector(new MessageSelector() {
|
||||
public boolean accept(Message<?> message) {
|
||||
return true;
|
||||
}
|
||||
});
|
||||
endpoint.onMessage(new StringMessage("test"));
|
||||
endpoint.handleMessage(new StringMessage("test"));
|
||||
latch.await(100, TimeUnit.MILLISECONDS);
|
||||
assertEquals("handler should have been invoked", 0, latch.getCount());
|
||||
}
|
||||
@@ -204,7 +204,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void endpointWithMultipleSelectorsAndFirstRejects() {
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(
|
||||
TestHandlers.countingHandler(counter), "handle");
|
||||
MessageSelectorChain selectorChain = new MessageSelectorChain();
|
||||
selectorChain.add(new MessageSelector() {
|
||||
@@ -222,7 +222,7 @@ public class ServiceActivatorEndpointTests {
|
||||
endpoint.setSelector(selectorChain);
|
||||
boolean exceptionWasThrown = false;
|
||||
try {
|
||||
endpoint.onMessage(new StringMessage("test"));
|
||||
endpoint.handleMessage(new StringMessage("test"));
|
||||
}
|
||||
catch (MessageRejectedException e) {
|
||||
exceptionWasThrown = true;
|
||||
@@ -235,7 +235,7 @@ public class ServiceActivatorEndpointTests {
|
||||
public void endpointWithMultipleSelectorsAndFirstAccepts() {
|
||||
final AtomicInteger selectorCounter = new AtomicInteger();
|
||||
AtomicInteger handlerCounter = new AtomicInteger();
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(
|
||||
TestHandlers.countingHandler(handlerCounter), "handle");
|
||||
MessageSelectorChain selectorChain = new MessageSelectorChain();
|
||||
selectorChain.add(new MessageSelector() {
|
||||
@@ -253,7 +253,7 @@ public class ServiceActivatorEndpointTests {
|
||||
endpoint.setSelector(selectorChain);
|
||||
boolean exceptionWasThrown = false;
|
||||
try {
|
||||
endpoint.onMessage(new StringMessage("test"));
|
||||
endpoint.handleMessage(new StringMessage("test"));
|
||||
}
|
||||
catch (MessageRejectedException e) {
|
||||
exceptionWasThrown = true;
|
||||
@@ -266,7 +266,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void endpointWithMultipleSelectorsAndBothAccept() {
|
||||
final AtomicInteger counter = new AtomicInteger();
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(
|
||||
TestHandlers.countingHandler(counter), "handle");
|
||||
MessageSelectorChain selectorChain = new MessageSelectorChain();
|
||||
selectorChain.add(new MessageSelector() {
|
||||
@@ -282,14 +282,14 @@ public class ServiceActivatorEndpointTests {
|
||||
}
|
||||
});
|
||||
endpoint.setSelector(selectorChain);
|
||||
endpoint.onMessage(new StringMessage("test"));
|
||||
endpoint.handleMessage(new StringMessage("test"));
|
||||
assertEquals("both selectors and handler should have been invoked", 3, counter.get());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correlationIdNotSetIfMessageIsReturnedUnaltered() {
|
||||
QueueChannel replyChannel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(new Object() {
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return message;
|
||||
@@ -297,7 +297,7 @@ public class ServiceActivatorEndpointTests {
|
||||
}, "handle");
|
||||
Message<String> message = MessageBuilder.withPayload("test")
|
||||
.setReplyChannel(replyChannel).build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
Message<?> reply = replyChannel.receive(500);
|
||||
assertNull(reply.getHeaders().getCorrelationId());
|
||||
}
|
||||
@@ -305,7 +305,7 @@ public class ServiceActivatorEndpointTests {
|
||||
@Test
|
||||
public void correlationIdSetByHandlerTakesPrecedence() {
|
||||
QueueChannel replyChannel = new QueueChannel(1);
|
||||
ServiceActivatingConsumer endpoint = new ServiceActivatingConsumer(new Object() {
|
||||
ServiceActivatingHandler endpoint = new ServiceActivatingHandler(new Object() {
|
||||
@SuppressWarnings("unused")
|
||||
public Message<?> handle(Message<?> message) {
|
||||
return MessageBuilder.fromMessage(message)
|
||||
@@ -314,7 +314,7 @@ public class ServiceActivatorEndpointTests {
|
||||
}, "handle");
|
||||
Message<String> message = MessageBuilder.withPayload("test")
|
||||
.setReplyChannel(replyChannel).build();
|
||||
endpoint.onMessage(message);
|
||||
endpoint.handleMessage(message);
|
||||
Message<?> reply = replyChannel.receive(500);
|
||||
Object correlationId = reply.getHeaders().getCorrelationId();
|
||||
assertFalse(message.getHeaders().getId().equals(correlationId));
|
||||
@@ -322,8 +322,8 @@ public class ServiceActivatorEndpointTests {
|
||||
}
|
||||
|
||||
|
||||
private ServiceActivatingConsumer createEndpoint() {
|
||||
return new ServiceActivatingConsumer(new TestBean(), "handle");
|
||||
private ServiceActivatingHandler createEndpoint() {
|
||||
return new ServiceActivatingHandler(new TestBean(), "handle");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.consumer.ServiceActivatingConsumer;
|
||||
import org.springframework.integration.consumer.ServiceActivatingHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.StringMessage;
|
||||
|
||||
@@ -34,10 +34,10 @@ public class ServiceActivatorMethodResolutionTests {
|
||||
@Test
|
||||
public void singleAnnotationMatches() {
|
||||
SingleAnnotationTestBean testBean = new SingleAnnotationTestBean();
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(testBean);
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(testBean);
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
serviceActivator.onMessage(new StringMessage("foo"));
|
||||
serviceActivator.handleMessage(new StringMessage("foo"));
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertEquals("FOO", result.getPayload());
|
||||
}
|
||||
@@ -45,16 +45,16 @@ public class ServiceActivatorMethodResolutionTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void multipleAnnotationFails() {
|
||||
MultipleAnnotationTestBean testBean = new MultipleAnnotationTestBean();
|
||||
new ServiceActivatingConsumer(testBean);
|
||||
new ServiceActivatingHandler(testBean);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singlePublicMethodMatches() {
|
||||
SinglePublicMethodTestBean testBean = new SinglePublicMethodTestBean();
|
||||
ServiceActivatingConsumer serviceActivator = new ServiceActivatingConsumer(testBean);
|
||||
ServiceActivatingHandler serviceActivator = new ServiceActivatingHandler(testBean);
|
||||
QueueChannel outputChannel = new QueueChannel();
|
||||
serviceActivator.setOutputChannel(outputChannel);
|
||||
serviceActivator.onMessage(new StringMessage("foo"));
|
||||
serviceActivator.handleMessage(new StringMessage("foo"));
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertEquals("FOO", result.getPayload());
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class ServiceActivatorMethodResolutionTests {
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void multiplePublicMethodFails() {
|
||||
MultiplePublicMethodTestBean testBean = new MultiplePublicMethodTestBean();
|
||||
new ServiceActivatingConsumer(testBean);
|
||||
new ServiceActivatingHandler(testBean);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class MessageFilterTests {
|
||||
Message<?> message = new StringMessage("test");
|
||||
QueueChannel output = new QueueChannel();
|
||||
filter.setOutputChannel(output);
|
||||
filter.onMessage(message);
|
||||
filter.handleMessage(message);
|
||||
assertEquals(message, output.receive(0));
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class MessageFilterTests {
|
||||
});
|
||||
QueueChannel output = new QueueChannel();
|
||||
filter.setOutputChannel(output);
|
||||
filter.onMessage(new StringMessage("test"));
|
||||
filter.handleMessage(new StringMessage("test"));
|
||||
assertNull(output.receive(0));
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class MessageFilterTests {
|
||||
}
|
||||
});
|
||||
filter.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(filter, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(inputChannel, filter);
|
||||
endpoint.start();
|
||||
Message<?> message = new StringMessage("test");
|
||||
assertTrue(inputChannel.send(message));
|
||||
@@ -92,7 +92,7 @@ public class MessageFilterTests {
|
||||
}
|
||||
});
|
||||
filter.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(filter, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(inputChannel, filter);
|
||||
endpoint.start();
|
||||
Message<?> message = new StringMessage("test");
|
||||
assertTrue(inputChannel.send(message));
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.junit.Test;
|
||||
import org.springframework.context.support.GenericApplicationContext;
|
||||
import org.springframework.integration.bus.ApplicationContextMessageBus;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.consumer.MethodInvokingConsumer;
|
||||
import org.springframework.integration.consumer.MethodInvokingMessageHandler;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.endpoint.PollingConsumerEndpoint;
|
||||
@@ -38,28 +38,28 @@ import org.springframework.integration.util.TestUtils;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MethodInvokingConsumerTests {
|
||||
public class MethodInvokingMessageHandlerTests {
|
||||
|
||||
@Test
|
||||
public void validMethod() {
|
||||
MethodInvokingConsumer consumer = new MethodInvokingConsumer(new TestSink(), "validMethod");
|
||||
consumer.afterPropertiesSet();
|
||||
consumer.onMessage(new GenericMessage<String>("test"));
|
||||
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "validMethod");
|
||||
handler.afterPropertiesSet();
|
||||
handler.handleMessage(new GenericMessage<String>("test"));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void invalidMethodWithNoArgs() {
|
||||
MethodInvokingConsumer consumer = new MethodInvokingConsumer(new TestSink(), "invalidMethodWithNoArgs");
|
||||
consumer.afterPropertiesSet();
|
||||
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "invalidMethodWithNoArgs");
|
||||
handler.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
public void methodWithReturnValue() {
|
||||
Message<?> message = new StringMessage("test");
|
||||
try {
|
||||
MethodInvokingConsumer consumer = new MethodInvokingConsumer(new TestSink(), "methodWithReturnValue");
|
||||
consumer.afterPropertiesSet();
|
||||
consumer.onMessage(message);
|
||||
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "methodWithReturnValue");
|
||||
handler.afterPropertiesSet();
|
||||
handler.handleMessage(message);
|
||||
}
|
||||
catch (MessagingException e) {
|
||||
assertEquals(e.getFailedMessage(), message);
|
||||
@@ -69,8 +69,8 @@ public class MethodInvokingConsumerTests {
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
public void noMatchingMethodName() {
|
||||
MethodInvokingConsumer consumer = new MethodInvokingConsumer(new TestSink(), "noSuchMethod");
|
||||
consumer.afterPropertiesSet();
|
||||
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(new TestSink(), "noSuchMethod");
|
||||
handler.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,8 +84,8 @@ public class MethodInvokingConsumerTests {
|
||||
Message<String> message = new GenericMessage<String>("testing");
|
||||
channel.send(message);
|
||||
assertNull(queue.poll());
|
||||
MethodInvokingConsumer consumer = new MethodInvokingConsumer(testBean, "foo");
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(consumer, channel);
|
||||
MethodInvokingMessageHandler handler = new MethodInvokingMessageHandler(testBean, "foo");
|
||||
PollingConsumerEndpoint endpoint = new PollingConsumerEndpoint(channel, handler);
|
||||
context.getBeanFactory().registerSingleton("testEndpoint", endpoint);
|
||||
ApplicationContextMessageBus bus = new ApplicationContextMessageBus();
|
||||
bus.setTaskScheduler(TestUtils.createTaskScheduler(10));
|
||||
@@ -64,7 +64,7 @@ public class ErrorMessageExceptionTypeRouterTests {
|
||||
exceptionTypeChannelMap.put(MessageHandlingException.class, messageHandlingExceptionChannel);
|
||||
router.setExceptionTypeChannelMap(exceptionTypeChannelMap);
|
||||
router.setDefaultOutputChannel(defaultChannel);
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
assertNotNull(illegalArgumentChannel.receive(1000));
|
||||
assertNull(defaultChannel.receive(0));
|
||||
assertNull(runtimeExceptionChannel.receive(0));
|
||||
@@ -85,7 +85,7 @@ public class ErrorMessageExceptionTypeRouterTests {
|
||||
exceptionTypeChannelMap.put(MessageHandlingException.class, messageHandlingExceptionChannel);
|
||||
router.setExceptionTypeChannelMap(exceptionTypeChannelMap);
|
||||
router.setDefaultOutputChannel(defaultChannel);
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
assertNotNull(runtimeExceptionChannel.receive(1000));
|
||||
assertNull(illegalArgumentChannel.receive(0));
|
||||
assertNull(defaultChannel.receive(0));
|
||||
@@ -105,7 +105,7 @@ public class ErrorMessageExceptionTypeRouterTests {
|
||||
exceptionTypeChannelMap.put(MessageHandlingException.class, messageHandlingExceptionChannel);
|
||||
router.setExceptionTypeChannelMap(exceptionTypeChannelMap);
|
||||
router.setDefaultOutputChannel(defaultChannel);
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
assertNotNull(messageHandlingExceptionChannel.receive(1000));
|
||||
assertNull(runtimeExceptionChannel.receive(0));
|
||||
assertNull(illegalArgumentChannel.receive(0));
|
||||
@@ -121,7 +121,7 @@ public class ErrorMessageExceptionTypeRouterTests {
|
||||
ErrorMessage message = new ErrorMessage(error);
|
||||
ErrorMessageExceptionTypeRouter router = new ErrorMessageExceptionTypeRouter();
|
||||
router.setDefaultOutputChannel(defaultChannel);
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
assertNotNull(defaultChannel.receive(1000));
|
||||
assertNull(runtimeExceptionChannel.receive(0));
|
||||
assertNull(illegalArgumentChannel.receive(0));
|
||||
@@ -141,7 +141,7 @@ public class ErrorMessageExceptionTypeRouterTests {
|
||||
exceptionTypeChannelMap.put(MessageDeliveryException.class, messageDeliveryExceptionChannel);
|
||||
router.setExceptionTypeChannelMap(exceptionTypeChannelMap);
|
||||
router.setResolutionRequired(true);
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -159,7 +159,7 @@ public class ErrorMessageExceptionTypeRouterTests {
|
||||
exceptionTypeChannelMap.put(MessageHandlingException.class, messageHandlingExceptionChannel);
|
||||
router.setExceptionTypeChannelMap(exceptionTypeChannelMap);
|
||||
router.setDefaultOutputChannel(defaultChannel);
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
assertNotNull(illegalArgumentChannel.receive(1000));
|
||||
assertNull(defaultChannel.receive(0));
|
||||
assertNull(runtimeExceptionChannel.receive(0));
|
||||
@@ -180,7 +180,7 @@ public class ErrorMessageExceptionTypeRouterTests {
|
||||
exceptionTypeChannelMap.put(MessageHandlingException.class, messageHandlingExceptionChannel);
|
||||
router.setExceptionTypeChannelMap(exceptionTypeChannelMap);
|
||||
router.setDefaultOutputChannel(defaultChannel);
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
assertNotNull(illegalArgumentChannel.receive(1000));
|
||||
assertNull(defaultChannel.receive(0));
|
||||
assertNull(runtimeExceptionChannel.receive(0));
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MethodInvokingRouterTests {
|
||||
MethodInvokingRouter router = new MethodInvokingRouter(testBean, routingMethod);
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new GenericMessage<String>("bar");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> replyMessage = barChannel.receive();
|
||||
assertNotNull(replyMessage);
|
||||
assertEquals(message, replyMessage);
|
||||
@@ -69,7 +69,7 @@ public class MethodInvokingRouterTests {
|
||||
MethodInvokingRouter router = new MethodInvokingRouter(testBean, "routePayload");
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new GenericMessage<String>("bar");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> replyMessage = barChannel.receive();
|
||||
assertNotNull(replyMessage);
|
||||
assertEquals(message, replyMessage);
|
||||
@@ -90,7 +90,7 @@ public class MethodInvokingRouterTests {
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = MessageBuilder.withPayload("bar")
|
||||
.setHeader("targetChannel", "foo").build();
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> fooReply = fooChannel.receive(0);
|
||||
Message<?> barReply = barChannel.receive(0);
|
||||
assertNotNull(fooReply);
|
||||
@@ -103,7 +103,7 @@ public class MethodInvokingRouterTests {
|
||||
SingleChannelNameRoutingTestBean testBean = new SingleChannelNameRoutingTestBean();
|
||||
Method routingMethod = testBean.getClass().getMethod("routeByHeader", String.class);
|
||||
MethodInvokingRouter router = new MethodInvokingRouter(testBean, routingMethod);
|
||||
router.onMessage(new GenericMessage<String>("testing"));
|
||||
router.handleMessage(new GenericMessage<String>("testing"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -133,15 +133,15 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1 = fooChannel.receive(0);
|
||||
assertNotNull(result1);
|
||||
assertEquals("foo", result1.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2 = barChannel.receive(0);
|
||||
assertNotNull(result2);
|
||||
assertEquals("bar", result2.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -172,15 +172,15 @@ public class MethodInvokingRouterTests {
|
||||
channelResolver.addChannel(fooChannel);
|
||||
channelResolver.addChannel(barChannel);
|
||||
router.setChannelResolver(channelResolver);
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1 = fooChannel.receive(0);
|
||||
assertNotNull(result1);
|
||||
assertEquals("foo", result1.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2 = barChannel.receive(0);
|
||||
assertNotNull(result2);
|
||||
assertEquals("bar", result2.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -211,15 +211,15 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1 = fooChannel.receive(0);
|
||||
assertNotNull(result1);
|
||||
assertEquals("foo", result1.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2 = barChannel.receive(0);
|
||||
assertNotNull(result2);
|
||||
assertEquals("bar", result2.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -250,21 +250,21 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1a = fooChannel.receive(0);
|
||||
Message<?> result1b = barChannel.receive(0);
|
||||
assertNotNull(result1a);
|
||||
assertEquals("foo", result1a.getPayload());
|
||||
assertNotNull(result1b);
|
||||
assertEquals("foo", result1b.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2a = fooChannel.receive(0);
|
||||
Message<?> result2b = barChannel.receive(0);
|
||||
assertNotNull(result2a);
|
||||
assertEquals("bar", result2a.getPayload());
|
||||
assertNotNull(result2b);
|
||||
assertEquals("bar", result2b.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -295,21 +295,21 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1a = fooChannel.receive(0);
|
||||
assertNotNull(result1a);
|
||||
assertEquals("foo", result1a.getPayload());
|
||||
Message<?> result1b = barChannel.receive(0);
|
||||
assertNotNull(result1b);
|
||||
assertEquals("foo", result1b.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2a = fooChannel.receive(0);
|
||||
assertNotNull(result2a);
|
||||
assertEquals("bar", result2a.getPayload());
|
||||
Message<?> result2b = barChannel.receive(0);
|
||||
assertNotNull(result2b);
|
||||
assertEquals("bar", result2b.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -340,21 +340,21 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1a = fooChannel.receive(0);
|
||||
assertNotNull(result1a);
|
||||
assertEquals("foo", result1a.getPayload());
|
||||
Message<?> result1b = barChannel.receive(0);
|
||||
assertNotNull(result1b);
|
||||
assertEquals("foo", result1b.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2a = fooChannel.receive(0);
|
||||
assertNotNull(result2a);
|
||||
assertEquals("bar", result2a.getPayload());
|
||||
Message<?> result2b = barChannel.receive(0);
|
||||
assertNotNull(result2b);
|
||||
assertEquals("bar", result2b.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -385,21 +385,21 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1a = fooChannel.receive(0);
|
||||
Message<?> result1b = barChannel.receive(0);
|
||||
assertNotNull(result1a);
|
||||
assertEquals("foo", result1a.getPayload());
|
||||
assertNotNull(result1b);
|
||||
assertEquals("foo", result1b.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2a = fooChannel.receive(0);
|
||||
Message<?> result2b = barChannel.receive(0);
|
||||
assertNotNull(result2a);
|
||||
assertEquals("bar", result2a.getPayload());
|
||||
assertNotNull(result2b);
|
||||
assertEquals("bar", result2b.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -430,21 +430,21 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1a = fooChannel.receive(0);
|
||||
Message<?> result1b = barChannel.receive(0);
|
||||
assertNotNull(result1a);
|
||||
assertEquals("foo", result1a.getPayload());
|
||||
assertNotNull(result1b);
|
||||
assertEquals("foo", result1b.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2a = fooChannel.receive(0);
|
||||
Message<?> result2b = barChannel.receive(0);
|
||||
assertNotNull(result2a);
|
||||
assertEquals("bar", result2a.getPayload());
|
||||
assertNotNull(result2b);
|
||||
assertEquals("bar", result2b.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -475,21 +475,21 @@ public class MethodInvokingRouterTests {
|
||||
Message<String> fooMessage = new StringMessage("foo");
|
||||
Message<String> barMessage = new StringMessage("bar");
|
||||
Message<String> badMessage = new StringMessage("bad");
|
||||
router.onMessage(fooMessage);
|
||||
router.handleMessage(fooMessage);
|
||||
Message<?> result1a = fooChannel.receive(0);
|
||||
Message<?> result1b = barChannel.receive(0);
|
||||
assertNotNull(result1a);
|
||||
assertEquals("foo", result1a.getPayload());
|
||||
assertNotNull(result1b);
|
||||
assertEquals("foo", result1b.getPayload());
|
||||
router.onMessage(barMessage);
|
||||
router.handleMessage(barMessage);
|
||||
Message<?> result2a = fooChannel.receive(0);
|
||||
Message<?> result2b = barChannel.receive(0);
|
||||
assertNotNull(result2a);
|
||||
assertEquals("bar", result2a.getPayload());
|
||||
assertNotNull(result2b);
|
||||
assertEquals("bar", result2b.getPayload());
|
||||
router.onMessage(badMessage);
|
||||
router.handleMessage(badMessage);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class MultiChannelRouterTests {
|
||||
channelResolver.addChannel(channel2);
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> result1 = channel1.receive(25);
|
||||
assertNotNull(result1);
|
||||
assertEquals("test", result1.getPayload());
|
||||
@@ -67,7 +67,7 @@ public class MultiChannelRouterTests {
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
@@ -78,7 +78,7 @@ public class MultiChannelRouterTests {
|
||||
}
|
||||
};
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public class PayloadTypeRouterTests {
|
||||
router.setPayloadTypeChannelMap(payloadTypeChannelMap);
|
||||
Message<String> message1 = new StringMessage("test");
|
||||
Message<Integer> message2 = new GenericMessage<Integer>(123);
|
||||
router.onMessage(message1);
|
||||
router.onMessage(message2);
|
||||
router.handleMessage(message1);
|
||||
router.handleMessage(message2);
|
||||
Message<?> reply1 = stringChannel.receive(0);
|
||||
Message<?> reply2 = integerChannel.receive(0);
|
||||
assertEquals("test", reply1.getPayload());
|
||||
@@ -86,8 +86,8 @@ public class PayloadTypeRouterTests {
|
||||
router.setDefaultOutputChannel(defaultChannel);
|
||||
Message<String> message1 = new StringMessage("test");
|
||||
Message<Integer> message2 = new GenericMessage<Integer>(123);
|
||||
router.onMessage(message1);
|
||||
router.onMessage(message2);
|
||||
router.handleMessage(message1);
|
||||
router.handleMessage(message2);
|
||||
Message<?> result1 = stringChannel.receive(25);
|
||||
assertNotNull(result1);
|
||||
assertEquals("test", result1.getPayload());
|
||||
|
||||
@@ -66,7 +66,7 @@ public class RecipientListRouterTests {
|
||||
router.setChannels(channels);
|
||||
router.afterPropertiesSet();
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> result1 = channel1.receive(25);
|
||||
assertNotNull(result1);
|
||||
assertEquals("test", result1.getPayload());
|
||||
@@ -82,7 +82,7 @@ public class RecipientListRouterTests {
|
||||
RecipientListRouter router = new RecipientListRouter();
|
||||
router.setChannels(Collections.singletonList((MessageChannel) channel));
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> result1 = channel.receive(25);
|
||||
assertNotNull(result1);
|
||||
assertEquals("test", result1.getPayload());
|
||||
|
||||
@@ -45,7 +45,7 @@ public class RouterTests {
|
||||
}
|
||||
};
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected = MessageDeliveryException.class)
|
||||
@@ -57,7 +57,7 @@ public class RouterTests {
|
||||
};
|
||||
router.setResolutionRequired(true);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -68,7 +68,7 @@ public class RouterTests {
|
||||
}
|
||||
};
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected = MessageDeliveryException.class)
|
||||
@@ -80,7 +80,7 @@ public class RouterTests {
|
||||
};
|
||||
router.setResolutionRequired(true);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +93,7 @@ public class RouterTests {
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected = MessageDeliveryException.class)
|
||||
@@ -107,7 +107,7 @@ public class RouterTests {
|
||||
router.setChannelResolver(channelResolver);
|
||||
router.setResolutionRequired(true);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ public class RouterTests {
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected = MessageDeliveryException.class)
|
||||
@@ -135,7 +135,7 @@ public class RouterTests {
|
||||
router.setChannelResolver(channelResolver);
|
||||
router.setResolutionRequired(true);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
@@ -145,7 +145,7 @@ public class RouterTests {
|
||||
return "notImportant";
|
||||
}
|
||||
};
|
||||
router.onMessage(new StringMessage("this should fail"));
|
||||
router.handleMessage(new StringMessage("this should fail"));
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
@@ -155,7 +155,7 @@ public class RouterTests {
|
||||
return new String[] { "notImportant" };
|
||||
}
|
||||
};
|
||||
router.onMessage(new StringMessage("this should fail"));
|
||||
router.handleMessage(new StringMessage("this should fail"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -169,7 +169,7 @@ public class RouterTests {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("testChannel", testChannel);
|
||||
router.setBeanFactory(context);
|
||||
router.onMessage(new StringMessage("test"));
|
||||
router.handleMessage(new StringMessage("test"));
|
||||
Message<?> reply = testChannel.receive(0);
|
||||
assertEquals("test", reply.getPayload());
|
||||
}
|
||||
@@ -185,7 +185,7 @@ public class RouterTests {
|
||||
GenericApplicationContext context = new GenericApplicationContext();
|
||||
context.getBeanFactory().registerSingleton("testChannel", testChannel);
|
||||
router.setBeanFactory(context);
|
||||
router.onMessage(new StringMessage("test"));
|
||||
router.handleMessage(new StringMessage("test"));
|
||||
Message<?> reply = testChannel.receive(0);
|
||||
assertEquals("test", reply.getPayload());
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class SingleChannelRouterTests {
|
||||
}
|
||||
};
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> result = channel.receive(25);
|
||||
assertNotNull(result);
|
||||
assertEquals("test", result.getPayload());
|
||||
@@ -61,7 +61,7 @@ public class SingleChannelRouterTests {
|
||||
channelResolver.addChannel(channel);
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
Message<?> result = channel.receive(25);
|
||||
assertNotNull(result);
|
||||
assertEquals("test", result.getPayload());
|
||||
@@ -75,7 +75,7 @@ public class SingleChannelRouterTests {
|
||||
}
|
||||
};
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
@Test(expected = MessagingException.class)
|
||||
@@ -88,7 +88,7 @@ public class SingleChannelRouterTests {
|
||||
TestChannelResolver channelResolver = new TestChannelResolver();
|
||||
router.setChannelResolver(channelResolver);
|
||||
Message<String> message = new StringMessage("test");
|
||||
router.onMessage(message);
|
||||
router.handleMessage(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class DefaultSplitterTests {
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
DefaultMessageSplitter splitter = new DefaultMessageSplitter();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
assertEquals(3, replies.size());
|
||||
Message<?> reply1 = replies.get(0);
|
||||
@@ -64,7 +64,7 @@ public class DefaultSplitterTests {
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
DefaultMessageSplitter splitter = new DefaultMessageSplitter();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
assertEquals(3, replies.size());
|
||||
Message<?> reply1 = replies.get(0);
|
||||
@@ -85,7 +85,7 @@ public class DefaultSplitterTests {
|
||||
QueueChannel outputChannel = new QueueChannel(1);
|
||||
DefaultMessageSplitter splitter = new DefaultMessageSplitter();
|
||||
splitter.setOutputChannel(outputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(splitter, inputChannel);
|
||||
SubscribingConsumerEndpoint endpoint = new SubscribingConsumerEndpoint(inputChannel, splitter);
|
||||
endpoint.start();
|
||||
assertTrue(inputChannel.send(message));
|
||||
Message<?> reply = outputChannel.receive(0);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("stringToStringArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -63,7 +63,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("stringToStringList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -79,7 +79,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("messageToStringArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -95,7 +95,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("messageToStringList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -111,7 +111,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("messageToMessageArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -127,7 +127,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("messageToMessageList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -143,7 +143,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("stringToMessageArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -159,7 +159,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("stringToMessageList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -175,7 +175,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToStringArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -191,7 +191,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToStringList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -207,7 +207,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToStringArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -223,7 +223,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToStringList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -239,7 +239,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToMessageArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -255,7 +255,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "messageToMessageList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -271,7 +271,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToMessageArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -287,7 +287,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, "stringToMessageList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -303,7 +303,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("stringToStringArray");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -323,7 +323,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("messageToMessageList");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -344,7 +344,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = this.getSplitter("splitHeader");
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -362,7 +362,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean, splittingMethod);
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -385,7 +385,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(annotatedBean);
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
@@ -407,7 +407,7 @@ public class MethodInvokingSplitterTests {
|
||||
MethodInvokingSplitter splitter = new MethodInvokingSplitter(testBean);
|
||||
QueueChannel replyChannel = new QueueChannel();
|
||||
splitter.setOutputChannel(replyChannel);
|
||||
splitter.onMessage(message);
|
||||
splitter.handleMessage(message);
|
||||
List<Message<?>> replies = replyChannel.clear();
|
||||
Message<?> reply1 = replies.get(0);
|
||||
assertNotNull(reply1);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user