Renamed ApplicationEventOutboundChannelAdapter to ApplicationEventPublishingMessageConsumer, since a consumer only plays the role of a "Channel Adapter" when connected to a channel within either a PublishingConsumerEndpoint or SubscribingConsumerEndpoint.
This commit is contained in:
@@ -24,13 +24,14 @@ import org.springframework.integration.message.Message;
|
|||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An outbound Channel Adapter that publishes each {@link Message} it receives
|
* A {@link org.springframework.integration.message.MessageConsumer} that
|
||||||
* as a {@link MessagingEvent}. The {@link MessagingEvent} is a subclass of Spring's
|
* publishes each {@link Message} it receives as a {@link MessagingEvent}. The
|
||||||
* {@link ApplicationEvent} used by this adapter to simply wrap the {@link Message}.
|
* {@link MessagingEvent} is a subclass of Spring's {@link ApplicationEvent}
|
||||||
|
* used by this adapter to simply wrap the {@link Message}.
|
||||||
*
|
*
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
public class ApplicationEventOutboundChannelAdapter<T> extends AbstractMessageConsumer implements ApplicationEventPublisherAware {
|
public class ApplicationEventPublishingMessageConsumer<T> extends AbstractMessageConsumer implements ApplicationEventPublisherAware {
|
||||||
|
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
@@ -29,17 +29,17 @@ import org.springframework.integration.message.StringMessage;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
public class ApplicationEventOutboundChannelAdapterTests {
|
public class ApplicationEventPublishingMessageConsumerTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void testSendingEvent() throws InterruptedException {
|
public void testSendingEvent() throws InterruptedException {
|
||||||
TestApplicationEventPublisher publisher = new TestApplicationEventPublisher();
|
TestApplicationEventPublisher publisher = new TestApplicationEventPublisher();
|
||||||
ApplicationEventOutboundChannelAdapter adapter = new ApplicationEventOutboundChannelAdapter();
|
ApplicationEventPublishingMessageConsumer consumer = new ApplicationEventPublishingMessageConsumer();
|
||||||
adapter.setApplicationEventPublisher(publisher);
|
consumer.setApplicationEventPublisher(publisher);
|
||||||
assertNull(publisher.getLastEvent());
|
assertNull(publisher.getLastEvent());
|
||||||
Message<?> message = new StringMessage("testing");
|
Message<?> message = new StringMessage("testing");
|
||||||
adapter.onMessage(message);
|
consumer.onMessage(message);
|
||||||
ApplicationEvent event = publisher.getLastEvent();
|
ApplicationEvent event = publisher.getLastEvent();
|
||||||
assertEquals(MessagingEvent.class, event.getClass());
|
assertEquals(MessagingEvent.class, event.getClass());
|
||||||
assertEquals(message, ((MessagingEvent) event).getMessage());
|
assertEquals(message, ((MessagingEvent) event).getMessage());
|
||||||
Reference in New Issue
Block a user