本文整理汇总了Java中org.springframework.integration.channel.DirectChannel.subscribe方法的典型用法代码示例。如果您正苦于以下问题:Java DirectChannel.subscribe方法的具体用法?Java DirectChannel.subscribe怎么用?Java DirectChannel.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.integration.channel.DirectChannel
的用法示例。
在下文中一共展示了DirectChannel.subscribe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Before
public void setUp() {
messages.clear();
this.connectionFactory = redisAvailableRule.getResource();
DirectChannel outputChannel = new DirectChannel();
outputChannel.setBeanFactory(BinderTestUtils.MOCK_BF);
outputChannel.subscribe(new TestMessageHandler());
this.currentQueueName = QUEUE_NAME + ":" + System.nanoTime();
adapter = new RedisQueueMessageDrivenEndpoint(currentQueueName, connectionFactory);
adapter.setBeanFactory(BinderTestUtils.MOCK_BF);
adapter.setOutputChannel(outputChannel);
String multiplier = System.getenv("REDIS_TIMEOUT_MULTIPLIER");
if (multiplier != null) {
timeoutMultiplier = Double.parseDouble(multiplier);
}
}
开发者ID:spring-cloud,项目名称:spring-cloud-stream-binder-redis,代码行数:20,代码来源:RedisQueueInboundChannelAdapterTests.java
示例2: testMessageFlow
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testMessageFlow() throws Exception {
setUp("SqsInboundChannelAdapterParserTests.xml", getClass(),
"sqsInboundChannelAdapter");
@SuppressWarnings("unchecked")
BlockingQueue<String> testQueue = (BlockingQueue<String>) context
.getBean("testQueue");
DirectChannel out = (DirectChannel) context.getBean("out");
out.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message)
throws MessagingException {
assertEquals("Hello, World", message.getPayload());
}
});
testQueue
.add("{\"payload\": \"Hello, World\", \"payloadClazz\": \"java.lang.String\", \"headers\": {}, \"properties\": {}}");
}
示例3: testMessageDrivenFlow
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testMessageDrivenFlow() throws Exception {
setUp("SqsChannelParserTests.xml", getClass(), "sqsChannel");
recvMessage = null;
DirectChannel log = (DirectChannel) context.getBean("log");
log.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message)
throws MessagingException {
recvMessage = (String) message.getPayload();
}
});
String payload = "Hello, World";
MessageChannel channel = (MessageChannel) context.getBean("sqsChannel");
channel.send(MessageBuilder.withPayload(payload).build());
Thread.sleep(1000);
assertEquals(payload, recvMessage);
}
示例4: testAutoCreateTopicsDisabledOnBinderStillWorksAsLongAsBrokerCreatesTopic
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void testAutoCreateTopicsDisabledOnBinderStillWorksAsLongAsBrokerCreatesTopic() throws Exception {
KafkaBinderConfigurationProperties configurationProperties = createConfigurationProperties();
configurationProperties.setAutoCreateTopics(false);
Binder binder = getBinder(configurationProperties);
BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
DirectChannel output = createBindableChannel("output", producerBindingProperties);
ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties = createConsumerProperties();
DirectChannel input = createBindableChannel("input", createConsumerBindingProperties(consumerProperties));
String testTopicName = "createdByBroker-" + System.currentTimeMillis();
Binding<MessageChannel> producerBinding = binder.bindProducer(testTopicName, output,
producerBindingProperties.getProducer());
String testPayload = "foo1-" + UUID.randomUUID().toString();
output.send(new GenericMessage<>(testPayload));
Binding<MessageChannel> consumerBinding = binder.bindConsumer(testTopicName, "test", input, consumerProperties);
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Message<String>> inboundMessageRef = new AtomicReference<>();
input.subscribe(message1 -> {
try {
inboundMessageRef.set((Message<String>) message1);
}
finally {
latch.countDown();
}
});
Assert.isTrue(latch.await(5, TimeUnit.SECONDS), "Failed to receive message");
assertThat(inboundMessageRef.get()).isNotNull();
assertThat(inboundMessageRef.get().getPayload()).isEqualTo(testPayload);
producerBinding.unbind();
consumerBinding.unbind();
}
示例5: testSendingOneWayMessage
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testSendingOneWayMessage() throws Exception {
final CountDownLatch latch = new CountDownLatch(1);
DirectChannel channelA = getMandatoryBean(DirectChannel.class, "channelA");
channelA.subscribe(new MessageHandler() {
public void handleMessage(Message<?> message) {
latch.countDown();
assertEquals("We should get the message from channelA", message.getPayload(), "Willem");
}
});
template.sendBody("direct:OneWay", "Willem");
assertTrue(latch.await(1, TimeUnit.SECONDS));
}
示例6: testNonDurablePubSubWithAutoBindDLQ
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testNonDurablePubSubWithAutoBindDLQ() throws Exception {
RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
RabbitTestBinder binder = getBinder();
ExtendedConsumerProperties<RabbitConsumerProperties> consumerProperties = createConsumerProperties();
consumerProperties.getExtension().setPrefix(TEST_PREFIX);
consumerProperties.getExtension().setAutoBindDlq(true);
consumerProperties.getExtension().setDurableSubscription(false);
consumerProperties.setMaxAttempts(1); // disable retry
BindingProperties bindingProperties = createConsumerBindingProperties(consumerProperties);
DirectChannel moduleInputChannel = createBindableChannel("input", bindingProperties);
moduleInputChannel.setBeanName("nondurabletest");
moduleInputChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
throw new RuntimeException("foo");
}
});
Binding<MessageChannel> consumerBinding = binder.bindConsumer("nondurabletest.0", "tgroup", moduleInputChannel,
consumerProperties);
consumerBinding.unbind();
assertThat(admin.getQueueProperties(TEST_PREFIX + "nondurabletest.0.dlq")).isNull();
}
示例7: testSendPojoReceivePojoWithStreamListenerDefaultContentType
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendPojoReceivePojoWithStreamListenerDefaultContentType()
throws Exception {
StreamListenerMessageHandler handler = this.buildStreamListener(
AbstractBinderTests.class, "echoStation", Station.class);
Binder binder = getBinder();
BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);
BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());
DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);
Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0a",
getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0a",
getDestinationNameDelimiter()), "test-1", moduleInputChannel, consumerBindingProperties.getConsumer());
Station station = new Station();
Message<?> message = MessageBuilder.withPayload(station).build();
moduleInputChannel.subscribe(handler);
moduleOutputChannel.send(message);
QueueChannel replyChannel = (QueueChannel) handler.getOutputChannel();
Message<?> replyMessage = replyChannel.receive(5000);
assertTrue(replyMessage.getPayload() instanceof Station);
producerBinding.unbind();
consumerBinding.unbind();
}
示例8: testSendPojoReceivePojoKryoWithStreamListener
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendPojoReceivePojoKryoWithStreamListener() throws Exception {
StreamListenerMessageHandler handler = this.buildStreamListener(
AbstractBinderTests.class, "echoStation", Station.class);
Binder binder = getBinder();
BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);
BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());
DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);
Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0b",
getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0b",
getDestinationNameDelimiter()), "test-2", moduleInputChannel, consumerBindingProperties.getConsumer());
Station station = new Station();
Message<?> message = MessageBuilder.withPayload(station).setHeader(
MessageHeaders.CONTENT_TYPE, MessageConverterUtils.X_JAVA_OBJECT).build();
moduleInputChannel.subscribe(handler);
moduleOutputChannel.send(message);
QueueChannel replyChannel = (QueueChannel) handler.getOutputChannel();
Message<?> replyMessage = replyChannel.receive(5000);
assertTrue(replyMessage.getPayload() instanceof Station);
producerBinding.unbind();
consumerBinding.unbind();
}
示例9: testSendJsonReceivePojoWithStreamListener
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendJsonReceivePojoWithStreamListener() throws Exception {
StreamListenerMessageHandler handler = this.buildStreamListener(
AbstractBinderTests.class, "echoStation", Station.class);
Binder binder = getBinder();
BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);
BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());
DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);
Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0d",
getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0d",
getDestinationNameDelimiter()), "test-4", moduleInputChannel, consumerBindingProperties.getConsumer());
String value = "{\"readings\":[{\"stationid\":\"fgh\","
+ "\"customerid\":\"12345\",\"timestamp\":null},{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";
Message<?> message = MessageBuilder.withPayload(value)
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
.build();
moduleInputChannel.subscribe(handler);
moduleOutputChannel.send(message);
QueueChannel channel = (QueueChannel) handler.getOutputChannel();
Message<Station> reply = (Message<Station>) channel.receive(5000);
assertNotNull(reply);
assertTrue(reply.getPayload() instanceof Station);
producerBinding.unbind();
consumerBinding.unbind();
}
示例10: testSendJsonReceiveJsonWithStreamListener
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
@Test
public void testSendJsonReceiveJsonWithStreamListener() throws Exception {
StreamListenerMessageHandler handler = this.buildStreamListener(
AbstractBinderTests.class, "echoStationString", String.class);
Binder binder = getBinder();
BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);
BindingProperties consumerBindingProperties = createConsumerBindingProperties(createConsumerProperties());
DirectChannel moduleInputChannel = createBindableChannel("input", consumerBindingProperties);
Binding<MessageChannel> producerBinding = binder.bindProducer(String.format("bad%s0e",
getDestinationNameDelimiter()), moduleOutputChannel, producerBindingProperties.getProducer());
Binding<MessageChannel> consumerBinding = binder.bindConsumer(String.format("bad%s0e",
getDestinationNameDelimiter()), "test-5", moduleInputChannel, consumerBindingProperties.getConsumer());
String value = "{\"readings\":[{\"stationid\":\"fgh\","
+ "\"customerid\":\"12345\",\"timestamp\":null},{\"stationid\":\"hjk\",\"customerid\":\"222\",\"timestamp\":null}]}";
Message<?> message = MessageBuilder.withPayload(value)
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.APPLICATION_JSON)
.build();
moduleInputChannel.subscribe(handler);
moduleOutputChannel.send(message);
QueueChannel channel = (QueueChannel) handler.getOutputChannel();
Message<String> reply = (Message<String>) channel.receive(5000);
assertNotNull(reply);
assertTrue(reply.getPayload() instanceof String);
producerBinding.unbind();
consumerBinding.unbind();
}
示例11: testPolling
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testPolling() throws Exception {
payload = null;
ackCallback = null;
context = new ClassPathXmlApplicationContext(
"SqsPollingInboundChannelAdapterParserTests.xml", getClass());
@SuppressWarnings("unchecked")
BlockingQueue<String> testQueue = (BlockingQueue<String>) context
.getBean("testQueue");
DirectChannel out = (DirectChannel) context.getBean("out");
out.subscribe(new MessageHandler() {
@SuppressWarnings("unchecked")
@Override
public void handleMessage(Message<?> message)
throws MessagingException {
payload = (String) message.getPayload();
ackCallback = (Callable<String>) message.getHeaders().get(
SqsHeaders.ACK_CALLBACK);
}
});
testQueue
.add("{\"payload\": \"Hello, World\", \"payloadClazz\": \"java.lang.String\", \"headers\": {}, \"properties\": {}}");
Thread.sleep(2500);
assertEquals("Hello, World", payload);
assertNotNull(ackCallback);
assertTrue(ackCallback.call().isEmpty());
}
示例12: testPartitionedModuleJava
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
@Override
public void testPartitionedModuleJava() throws Exception {
KinesisTestBinder binder = getBinder();
ExtendedConsumerProperties<KinesisConsumerProperties> consumerProperties = createConsumerProperties();
consumerProperties.setConcurrency(2);
consumerProperties.setInstanceCount(3);
consumerProperties.setInstanceIndex(0);
consumerProperties.setPartitioned(true);
final List<Message<?>> results = new ArrayList<>();
final CountDownLatch receiveLatch = new CountDownLatch(3);
MessageHandler receivingHandler = message -> {
results.add(message);
receiveLatch.countDown();
};
DirectChannel input0 = createBindableChannel("test.input0J", new BindingProperties());
input0.subscribe(receivingHandler);
Binding<MessageChannel> input0Binding = binder.bindConsumer("partJ.0", "testPartitionedModuleJava", input0,
consumerProperties);
consumerProperties.setInstanceIndex(1);
DirectChannel input1 = createBindableChannel("test.input1J", new BindingProperties());
input1.subscribe(receivingHandler);
Binding<MessageChannel> input1Binding = binder.bindConsumer("partJ.0", "testPartitionedModuleJava", input1,
consumerProperties);
consumerProperties.setInstanceIndex(2);
DirectChannel input2 = createBindableChannel("test.input2J", new BindingProperties());
input2.subscribe(receivingHandler);
Binding<MessageChannel> input2Binding = binder.bindConsumer("partJ.0", "testPartitionedModuleJava", input2,
consumerProperties);
ExtendedProducerProperties<KinesisProducerProperties> producerProperties = createProducerProperties();
producerProperties.setPartitionKeyExtractorClass(PartitionTestSupport.class);
producerProperties.setPartitionSelectorClass(PartitionTestSupport.class);
producerProperties.setPartitionCount(3);
DirectChannel output = createBindableChannel("test.output",
createProducerBindingProperties(producerProperties));
Binding<MessageChannel> outputBinding = binder.bindProducer("partJ.0", output, producerProperties);
if (usesExplicitRouting()) {
Object endpoint = extractEndpoint(outputBinding);
assertThat(getEndpointRouting(endpoint))
.contains(getExpectedRoutingBaseDestination("partJ.0", "testPartitionedModuleJava")
+ "-' + headers['" + BinderHeaders.PARTITION_HEADER + "']");
}
output.send(new GenericMessage<>(2));
output.send(new GenericMessage<>(1));
output.send(new GenericMessage<>(0));
assertThat(receiveLatch.await(20, TimeUnit.SECONDS)).isTrue();
assertThat(results).extracting("payload").containsExactlyInAnyOrder("0", "1", "2");
input0Binding.unbind();
input1Binding.unbind();
input2Binding.unbind();
outputBinding.unbind();
}
示例13: testAutoBindDLQwithRepublish
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
public void testAutoBindDLQwithRepublish() throws Exception {
// pre-declare the queue with dead-lettering, users can also use a policy
RabbitAdmin admin = new RabbitAdmin(this.rabbitAvailableRule.getResource());
Map<String, Object> args = new HashMap<String, Object>();
args.put("x-dead-letter-exchange", TEST_PREFIX + "DLX");
args.put("x-dead-letter-routing-key", TEST_PREFIX + "dlqpubtest.default");
Queue queue = new Queue(TEST_PREFIX + "dlqpubtest.default", true, false, false, args);
admin.declareQueue(queue);
RabbitTestBinder binder = getBinder();
ExtendedConsumerProperties<RabbitConsumerProperties> consumerProperties = createConsumerProperties();
consumerProperties.getExtension().setPrefix(TEST_PREFIX);
consumerProperties.getExtension().setAutoBindDlq(true);
consumerProperties.getExtension().setRepublishToDlq(true);
consumerProperties.setMaxAttempts(1); // disable retry
consumerProperties.getExtension().setDurableSubscription(true);
DirectChannel moduleInputChannel = createBindableChannel("input", createConsumerBindingProperties(consumerProperties));
moduleInputChannel.setBeanName("dlqPubTest");
moduleInputChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
throw new RuntimeException("foo");
}
});
Binding<MessageChannel> consumerBinding = binder.bindConsumer("foo.dlqpubtest", "foo", moduleInputChannel,
consumerProperties);
RabbitTemplate template = new RabbitTemplate(this.rabbitAvailableRule.getResource());
template.convertAndSend("", TEST_PREFIX + "foo.dlqpubtest.foo", "foo");
int n = 0;
while (n++ < 100) {
org.springframework.amqp.core.Message deadLetter = template.receive(TEST_PREFIX + "foo.dlqpubtest.foo.dlq");
if (deadLetter != null) {
assertThat(new String(deadLetter.getBody())).isEqualTo("foo");
assertThat(deadLetter.getMessageProperties().getHeaders()).containsKey(("x-exception-stacktrace"));
break;
}
Thread.sleep(100);
}
assertThat(n).isLessThan(100);
consumerBinding.unbind();
}
示例14: testTrustedPackages
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@SuppressWarnings({"rawtypes", "unchecked"})
@Test
public void testTrustedPackages() throws Exception {
Binder binder = getBinder();
BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);
ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties = createConsumerProperties();
consumerProperties.getExtension().setTrustedPackages(new String[]{"org.springframework.util"});
DirectChannel moduleInputChannel = createBindableChannel("input", createConsumerBindingProperties(consumerProperties));
Binding<MessageChannel> producerBinding = binder.bindProducer("bar.0", moduleOutputChannel,
producerBindingProperties.getProducer());
Binding<MessageChannel> consumerBinding = binder.bindConsumer("bar.0",
"testSendAndReceiveNoOriginalContentType", moduleInputChannel, consumerProperties);
binderBindUnbindLatency();
Message<?> message = org.springframework.integration.support.MessageBuilder.withPayload("foo")
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN)
.setHeader("foo", MimeTypeUtils.TEXT_PLAIN)
.build();
moduleOutputChannel.send(message);
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Message<String>> inboundMessageRef = new AtomicReference<>();
moduleInputChannel.subscribe(message1 -> {
try {
inboundMessageRef.set((Message<String>) message1);
}
finally {
latch.countDown();
}
});
Assert.isTrue(latch.await(5, TimeUnit.SECONDS), "Failed to receive message");
Assertions.assertThat(inboundMessageRef.get()).isNotNull();
Assertions.assertThat(inboundMessageRef.get().getPayload()).isEqualTo("foo");
Assertions.assertThat(inboundMessageRef.get().getHeaders().get(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE)).isNull();
Assertions.assertThat(inboundMessageRef.get().getHeaders().get(MessageHeaders.CONTENT_TYPE))
.isEqualTo(MimeTypeUtils.TEXT_PLAIN);
Assertions.assertThat(inboundMessageRef.get().getHeaders().get("foo")).isInstanceOf(MimeType.class);
MimeType actual = (MimeType) inboundMessageRef.get().getHeaders().get("foo");
Assertions.assertThat(actual).isEqualTo(MimeTypeUtils.TEXT_PLAIN);
producerBinding.unbind();
consumerBinding.unbind();
}
示例15: testSendAndReceiveNoOriginalContentType
import org.springframework.integration.channel.DirectChannel; //导入方法依赖的package包/类
@Test
@Override
@SuppressWarnings("unchecked")
public void testSendAndReceiveNoOriginalContentType() throws Exception {
Binder binder = getBinder();
BindingProperties producerBindingProperties = createProducerBindingProperties(
createProducerProperties());
DirectChannel moduleOutputChannel = createBindableChannel("output",
producerBindingProperties);
ExtendedConsumerProperties<KafkaConsumerProperties> consumerProperties = createConsumerProperties();
DirectChannel moduleInputChannel = createBindableChannel("input", createConsumerBindingProperties(consumerProperties));
Binding<MessageChannel> producerBinding = binder.bindProducer("bar.0",
moduleOutputChannel, producerBindingProperties.getProducer());
consumerProperties.getExtension().setTrustedPackages(new String[]{"org.springframework.util"});
Binding<MessageChannel> consumerBinding = binder.bindConsumer("bar.0",
"testSendAndReceiveNoOriginalContentType", moduleInputChannel,
consumerProperties);
binderBindUnbindLatency();
//TODO: Will have to fix the MimeType to convert to byte array once this issue has been resolved:
//https://github.com/spring-projects/spring-kafka/issues/424
Message<?> message = org.springframework.integration.support.MessageBuilder.withPayload("foo")
.setHeader(MessageHeaders.CONTENT_TYPE, MimeTypeUtils.TEXT_PLAIN).build();
moduleOutputChannel.send(message);
CountDownLatch latch = new CountDownLatch(1);
AtomicReference<Message<String>> inboundMessageRef = new AtomicReference<>();
moduleInputChannel.subscribe(message1 -> {
try {
inboundMessageRef.set((Message<String>) message1);
}
finally {
latch.countDown();
}
});
Assert.isTrue(latch.await(5, TimeUnit.SECONDS), "Failed to receive message");
assertThat(inboundMessageRef.get()).isNotNull();
assertThat(inboundMessageRef.get().getPayload()).isEqualTo("foo");
assertThat(inboundMessageRef.get().getHeaders().get(MessageHeaders.CONTENT_TYPE))
.isEqualTo(MimeTypeUtils.TEXT_PLAIN);
producerBinding.unbind();
consumerBinding.unbind();
}