List of usage examples for org.springframework.integration.endpoint EventDrivenConsumer start
@Override public final void start()
From source file:com.apress.prospringintegration.endpoints.eventdrivenconsumer.Main.java
public static void main(String[] args) { ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext( "event-driven-consumer.xml"); applicationContext.start();/* w w w.j a v a 2s . c o m*/ ProblemReporter problemReporter = applicationContext.getBean(ProblemReporter.class); TicketGenerator ticketGenerator = applicationContext.getBean(TicketGenerator.class); TicketMessageHandler ticketMessageHandler = applicationContext.getBean(TicketMessageHandler.class); DirectChannel channel = applicationContext.getBean("ticketChannel", DirectChannel.class); EventDrivenConsumer eventDrivenConsumer = new EventDrivenConsumer(channel, ticketMessageHandler); eventDrivenConsumer.start(); List<Ticket> tickets = ticketGenerator.createTickets(); int count = 0; while (count++ < 5) { for (Ticket ticket : tickets) { problemReporter.openTicket(ticket); } } }
From source file:io.jmnarloch.spring.cloud.stream.binder.hermes.HermesClientBinder.java
@Override protected Binding<MessageChannel> doBindProducer(String name, MessageChannel channel, ExtendedProducerProperties<HermesProducerProperties> properties) { Assert.isInstanceOf(SubscribableChannel.class, channel); logger.debug("Binding Hermes client to topic " + name); final MessageHandler handler = new HermesSendingHandler(name); final EventDrivenConsumer consumer = createConsumer(name, (SubscribableChannel) channel, handler); consumer.start(); return toBinding(name, channel, consumer); }
From source file:org.springframework.integration.handler.AsyncHandlerTests.java
@Test public void testGateway() throws Exception { this.whichTest = 0; GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class); gpfb.setBeanFactory(mock(BeanFactory.class)); DirectChannel input = new DirectChannel(); gpfb.setDefaultRequestChannel(input); gpfb.setDefaultReplyTimeout(10000L); gpfb.afterPropertiesSet();//ww w . j av a2 s . c o m Foo foo = (Foo) gpfb.getObject(); this.handler.setOutputChannel(null); EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler); consumer.afterPropertiesSet(); consumer.start(); this.latch.countDown(); String result = foo.exchange("foo"); assertEquals("reply", result); }
From source file:org.springframework.integration.handler.AsyncHandlerTests.java
@Test public void testGatewayWithException() throws Exception { this.whichTest = 0; GatewayProxyFactoryBean gpfb = new GatewayProxyFactoryBean(Foo.class); gpfb.setBeanFactory(mock(BeanFactory.class)); DirectChannel input = new DirectChannel(); gpfb.setDefaultRequestChannel(input); gpfb.setDefaultReplyTimeout(10000L); gpfb.afterPropertiesSet();/* w ww. ja v a2 s. c o m*/ Foo foo = (Foo) gpfb.getObject(); this.handler.setOutputChannel(null); EventDrivenConsumer consumer = new EventDrivenConsumer(input, this.handler); consumer.afterPropertiesSet(); consumer.start(); this.latch.countDown(); try { foo.exchange("foo"); } catch (MessagingException e) { assertThat(e.getClass().getSimpleName(), equalTo("RuntimeException")); assertThat(e.getMessage(), equalTo("foo")); } }
From source file:org.springframework.integration.x.gemfire.GemFireMessageBus.java
private void doRegisterProducer(final String name, MessageChannel moduleOutputChannel, MessageHandler handler) { Assert.isInstanceOf(SubscribableChannel.class, moduleOutputChannel); EventDrivenConsumer consumer = new EventDrivenConsumer((SubscribableChannel) moduleOutputChannel, handler); consumer.setBeanName("outbound." + name); consumer.afterPropertiesSet();// w ww . ja v a 2 s. c o m addBinding(Binding.forProducer(moduleOutputChannel, consumer)); consumer.start(); }
From source file:org.springframework.integration.x.rabbit.RabbitChannelRegistry.java
@Override public void createOutbound(final String name, MessageChannel moduleOutputChannel, boolean aliasHint) { Assert.isInstanceOf(SubscribableChannel.class, moduleOutputChannel); MessageHandler handler = new CompositeHandler(name); EventDrivenConsumer consumer = new EventDrivenConsumer((SubscribableChannel) moduleOutputChannel, handler); consumer.setBeanName("outbound." + name); consumer.afterPropertiesSet();//from ww w. jav a 2 s .co m this.lifecycleBeans.add(consumer); consumer.start(); }
From source file:org.springframework.integration.x.rabbit.RabbitMessageBus.java
private void doRegisterProducer(final String name, MessageChannel moduleOutputChannel, MessageHandler delegate, String replyTo) {//from ww w.ja v a 2 s . c o m Assert.isInstanceOf(SubscribableChannel.class, moduleOutputChannel); MessageHandler handler = new SendingHandler(delegate, replyTo); EventDrivenConsumer consumer = new EventDrivenConsumer((SubscribableChannel) moduleOutputChannel, handler); consumer.setBeanName("outbound." + name); consumer.afterPropertiesSet(); addBinding(Binding.forProducer(moduleOutputChannel, consumer)); consumer.start(); }
From source file:org.springframework.integration.x.redis.RedisChannelRegistry.java
@Override public void outbound(final String name, MessageChannel channel) { Assert.isInstanceOf(SubscribableChannel.class, channel); MessageHandler handler = new CompositeHandler(name, this.redisTemplate.getConnectionFactory()); EventDrivenConsumer consumer = new EventDrivenConsumer((SubscribableChannel) channel, handler); consumer.setBeanName("outbound." + name); consumer.afterPropertiesSet();//www . java 2s. c om this.lifecycleBeans.add(consumer); consumer.start(); }