Split MessageSource types into 2 sub-interfaces: PollableSource and SubscribableSource. The MessageChannel hierarchy has also been revised accordingly. DirectChannel and PublishSubscribeChannel are now SubscribableSources, while the other queue-based channels are PollableSources. The PollableChannel interface extends BlockingSource which in turn is an extension of PollableSource that adds timeout-aware methods.

This commit is contained in:
Mark Fisher
2008-07-30 20:48:00 +00:00
parent 759b5f6d0e
commit fa58dc9457
77 changed files with 422 additions and 497 deletions

View File

@@ -31,7 +31,7 @@ import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.ContextStartedEvent;
import org.springframework.context.event.ContextStoppedEvent;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.message.Message;
@@ -42,7 +42,7 @@ public class ApplicationEventSourceTests {
@Test
public void testAnyApplicationEventSentByDefault() {
MessageChannel channel = new QueueChannel();
QueueChannel channel = new QueueChannel();
ApplicationEventSource adapter = new ApplicationEventSource(channel);
Message<?> message1 = channel.receive(0);
assertNull(message1);
@@ -58,7 +58,7 @@ public class ApplicationEventSourceTests {
@Test
public void testOnlyConfiguredEventTypesAreSent() {
MessageChannel channel = new QueueChannel();
QueueChannel channel = new QueueChannel();
ApplicationEventSource adapter = new ApplicationEventSource(channel);
List<Class<? extends ApplicationEvent>> eventTypes = new ArrayList<Class<? extends ApplicationEvent>>();
eventTypes.add(TestApplicationEvent1.class);
@@ -77,7 +77,7 @@ public class ApplicationEventSourceTests {
@Test
public void testApplicationContextEvents() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationEventSourceTests.xml", this.getClass());
MessageChannel channel = (MessageChannel) context.getBean("channel");
PollableChannel channel = (PollableChannel) context.getBean("channel");
Message<?> refreshedEventMessage = channel.receive(0);
assertNotNull(refreshedEventMessage);
assertEquals(ContextRefreshedEvent.class, refreshedEventMessage.getPayload().getClass());

View File

@@ -29,7 +29,6 @@ import java.util.concurrent.Executors;
import org.junit.Test;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.message.Message;
import org.springframework.integration.message.MessageTarget;
@@ -46,7 +45,7 @@ public class HttpInvokerGatewayTests {
@Test
public void testRequestOnly() throws Exception {
MessageChannel channel = new QueueChannel();
QueueChannel channel = new QueueChannel();
HttpInvokerGateway gateway = new HttpInvokerGateway(channel);
gateway.setExpectReply(false);
gateway.afterPropertiesSet();
@@ -61,7 +60,7 @@ public class HttpInvokerGatewayTests {
@Test
public void testRequestReply() throws Exception {
final MessageChannel channel = new QueueChannel();
final QueueChannel channel = new QueueChannel();
Executors.newSingleThreadExecutor().execute(new Runnable() {
public void run() {
Message<?> message = channel.receive();

View File

@@ -27,7 +27,6 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.adapter.jms.JmsGateway;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.message.Message;
import org.springframework.jms.connection.JmsTransactionManager;
@@ -42,7 +41,7 @@ public class JmsGatewayParserTests {
public void testGatewayWithConnectionFactoryAndDestination() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewayWithConnectionFactoryAndDestination.xml", this.getClass());
MessageChannel channel = new QueueChannel(1);
QueueChannel channel = new QueueChannel(1);
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
gateway.setRequestChannel(channel);
context.start();
@@ -56,7 +55,7 @@ public class JmsGatewayParserTests {
public void testGatewayWithConnectionFactoryAndDestinationName() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewayWithConnectionFactoryAndDestinationName.xml", this.getClass());
MessageChannel channel = new QueueChannel(1);
QueueChannel channel = new QueueChannel(1);
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
gateway.setRequestChannel(channel);
context.start();
@@ -70,7 +69,7 @@ public class JmsGatewayParserTests {
public void testGatewayWithMessageConverter() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewayWithMessageConverter.xml", this.getClass());
MessageChannel channel = new QueueChannel(1);
QueueChannel channel = new QueueChannel(1);
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
gateway.setRequestChannel(channel);
context.start();
@@ -133,7 +132,7 @@ public class JmsGatewayParserTests {
public void testGatewayWithDefaultConnectionFactory() {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsGatewayWithDefaultConnectionFactory.xml", this.getClass());
MessageChannel channel = new QueueChannel(1);
QueueChannel channel = new QueueChannel(1);
JmsGateway gateway = (JmsGateway) context.getBean("jmsGateway");
gateway.setRequestChannel(channel);
context.start();

View File

@@ -26,7 +26,7 @@ import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.adapter.jms.JmsSource;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.PollableChannel;
import org.springframework.integration.message.Message;
/**
@@ -131,7 +131,7 @@ public class JmsSourceParserTests {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
"jmsSourceEndpoint.xml", this.getClass());
context.start();
MessageChannel channel = (MessageChannel) context.getBean("channel");
PollableChannel channel = (PollableChannel) context.getBean("channel");
Message<?> message = channel.receive(3000);
assertNotNull("message should not be null", message);
assertEquals("polling-test", message.getPayload());

View File

@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull;
import java.io.ByteArrayInputStream;
import org.junit.Test;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.endpoint.SourceEndpoint;
import org.springframework.integration.endpoint.TriggerMessage;
@@ -38,7 +38,7 @@ public class ByteStreamSourceTests {
public void testEndOfStream() {
byte[] bytes = new byte[] {1,2,3};
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
MessageChannel channel = new QueueChannel();
QueueChannel channel = new QueueChannel();
ByteStreamSource source = new ByteStreamSource(stream);
SourceEndpoint endpoint = new SourceEndpoint(source);
endpoint.setTarget(channel);
@@ -61,7 +61,7 @@ public class ByteStreamSourceTests {
public void testByteArrayIsTruncated() {
byte[] bytes = new byte[] {0,1,2,3,4,5};
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
MessageChannel channel = new QueueChannel();
QueueChannel channel = new QueueChannel();
ByteStreamSource source = new ByteStreamSource(stream);
source.setBytesPerMessage(4);
PollingSchedule schedule = new PollingSchedule(1000);
@@ -83,7 +83,7 @@ public class ByteStreamSourceTests {
public void testByteArrayIsNotTruncated() {
byte[] bytes = new byte[] {0,1,2,3,4,5};
ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
MessageChannel channel = new QueueChannel();
QueueChannel channel = new QueueChannel();
ByteStreamSource source = new ByteStreamSource(stream);
source.setBytesPerMessage(4);
source.setShouldTruncate(false);

View File

@@ -24,7 +24,6 @@ import java.io.IOException;
import org.junit.Before;
import org.junit.Test;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
import org.springframework.integration.dispatcher.PollingDispatcher;
@@ -37,7 +36,7 @@ import org.springframework.integration.scheduling.PollingSchedule;
*/
public class ByteStreamTargetTests {
private MessageChannel channel;
private QueueChannel channel;
private PollingDispatcher dispatcher;

View File

@@ -22,7 +22,7 @@ import static org.junit.Assert.assertNull;
import java.io.StringReader;
import org.junit.Test;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.endpoint.SourceEndpoint;
import org.springframework.integration.endpoint.TriggerMessage;
@@ -37,7 +37,7 @@ public class CharacterStreamSourceTests {
@Test
public void testEndOfStream() {
StringReader reader = new StringReader("test");
MessageChannel channel = new QueueChannel();
QueueChannel channel = new QueueChannel();
CharacterStreamSource source = new CharacterStreamSource(reader);
PollingSchedule schedule = new PollingSchedule(1000);
schedule.setInitialDelay(10000);

View File

@@ -23,7 +23,6 @@ import java.io.StringWriter;
import org.junit.Before;
import org.junit.Test;
import org.springframework.integration.channel.MessageChannel;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
import org.springframework.integration.dispatcher.PollingDispatcher;
@@ -36,7 +35,7 @@ import org.springframework.integration.scheduling.PollingSchedule;
*/
public class CharacterStreamTargetTests {
private MessageChannel channel;
private QueueChannel channel;
private PollingDispatcher dispatcher;