use of org.springframework.messaging.MessagingException in project spring-cloud-consul by spring-cloud.
the class TestConsumer method run.
@Override
public void run(ApplicationArguments args) throws Exception {
logger.info("Consumer running with binder {}", binder);
SubscribableChannel consumerChannel = new ExecutorSubscribableChannel();
consumerChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
messagePayload = (String) message.getPayload();
logger.info("Received message: {}", messagePayload);
}
});
String group = null;
if (args.containsOption("group")) {
group = args.getOptionValues("group").get(0);
}
binder.bindConsumer(ConsulBinderTests.BINDING_NAME, group, consumerChannel, new ConsumerProperties());
isBound = true;
}
use of org.springframework.messaging.MessagingException in project spring-integration-samples by spring-projects.
the class GmailInboundImapIdleAdapterTestApp method main.
public static void main(String[] args) throws Exception {
@SuppressWarnings("resource") ClassPathXmlApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/gmail-imap-idle-config.xml");
DirectChannel inputChannel = ac.getBean("receiveChannel", DirectChannel.class);
inputChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
logger.info("Message: " + message);
}
});
}
use of org.springframework.messaging.MessagingException in project spring-integration-samples by spring-projects.
the class GmailInboundPop3AdapterTestApp method main.
public static void main(String[] args) throws Exception {
@SuppressWarnings("resource") ApplicationContext ac = new ClassPathXmlApplicationContext("/META-INF/spring/integration/gmail-pop3-config.xml");
DirectChannel inputChannel = ac.getBean("receiveChannel", DirectChannel.class);
inputChannel.subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
logger.info("Message: " + message);
}
});
}
use of org.springframework.messaging.MessagingException in project spring-cloud-stream by spring-cloud.
the class StreamListenerHandlerMethodTests method testMethodWithMultipleInputParameters.
@Test
public void testMethodWithMultipleInputParameters() throws Exception {
ConfigurableApplicationContext context = SpringApplication.run(TestMethodWithMultipleInputParameters.class, "--server.port=0", "--spring.jmx.enabled=false");
Processor processor = context.getBean(Processor.class);
StreamListenerTestUtils.FooInboundChannel1 inboundChannel2 = context.getBean(StreamListenerTestUtils.FooInboundChannel1.class);
final CountDownLatch latch = new CountDownLatch(2);
((SubscribableChannel) processor.output()).subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
Assert.isTrue(message.getPayload().equals("footesting") || message.getPayload().equals("BARTESTING"), "Assert failed");
latch.countDown();
}
});
processor.input().send(MessageBuilder.withPayload("{\"foo\":\"fooTESTing\"}").setHeader("contentType", "application/json").build());
inboundChannel2.input().send(MessageBuilder.withPayload("{\"bar\":\"bartestING\"}").setHeader("contentType", "application/json").build());
assertThat(latch.await(1, TimeUnit.SECONDS));
context.close();
}
use of org.springframework.messaging.MessagingException in project spring-cloud-stream by spring-cloud.
the class TestSupportBinder method bindProducer.
/**
* Registers a single subscriber to the channel, that enqueues messages for later
* retrieval and assertion in tests.
*/
@Override
public Binding<MessageChannel> bindProducer(String name, MessageChannel outboundBindTarget, ProducerProperties properties) {
final BlockingQueue<Message<?>> queue = messageCollector.register(outboundBindTarget, properties.isUseNativeEncoding());
((SubscribableChannel) outboundBindTarget).subscribe(new MessageHandler() {
@Override
public void handleMessage(Message<?> message) throws MessagingException {
queue.add(message);
}
});
this.messageChannels.put(name, outboundBindTarget);
return new TestBinding(outboundBindTarget, messageCollector);
}
Aggregations