Example usage for org.springframework.integration.channel QueueChannel QueueChannel

List of usage examples for org.springframework.integration.channel QueueChannel QueueChannel

Introduction

In this page you can find the example usage for org.springframework.integration.channel QueueChannel QueueChannel.

Prototype

public QueueChannel() 

Source Link

Document

Create a channel with "unbounded" queue capacity.

Usage

From source file:com.devnexus.ting.config.MailNotificationConfig.java

@Bean
public QueueChannel mailChannel() {
    return new QueueChannel();
}

From source file:com.devnexus.ting.config.MailNotificationConfig.java

@Bean
public QueueChannel registrationMailChannel() {
    return new QueueChannel();
}

From source file:com.devnexus.ting.config.MailNotificationConfig.java

@Bean
public QueueChannel acceptedSessionMailChannel() {
    return new QueueChannel();
}

From source file:multibinder.RabbitAndKafkaBinderApplicationTests.java

@Test
public void messagingWorks() throws Exception {
    // passing connection arguments arguments to the embedded Kafka instance
    ConfigurableApplicationContext context = SpringApplication.run(MultibinderApplication.class,
            "--spring.cloud.stream.kafka.binder.brokers=" + kafkaEmbedded.getBrokersAsString(),
            "--spring.cloud.stream.kafka.binder.zkNodes=" + kafkaEmbedded.getZookeeperConnectionString(),
            "--spring.cloud.stream.bindings.output.producer.requiredGroups=" + this.randomGroup);
    DirectChannel dataProducer = new DirectChannel();
    BinderFactory<?> binderFactory = context.getBean(BinderFactory.class);

    QueueChannel dataConsumer = new QueueChannel();

    ((RabbitMessageChannelBinder) binderFactory.getBinder("rabbit")).bindConsumer("dataOut", this.randomGroup,
            dataConsumer, new ExtendedConsumerProperties<>(new RabbitConsumerProperties()));

    ((KafkaMessageChannelBinder) binderFactory.getBinder("kafka")).bindProducer("dataIn", dataProducer,
            new ExtendedProducerProperties<>(new KafkaProducerProperties()));

    String testPayload = "testFoo" + this.randomGroup;
    dataProducer.send(MessageBuilder.withPayload(testPayload).build());

    Message<?> receive = dataConsumer.receive(10000);
    Assert.assertThat(receive, Matchers.notNullValue());
    Assert.assertThat(receive.getPayload(), CoreMatchers.equalTo(testPayload));
    context.close();/*from  w ww. j a v a  2  s . co m*/
}

From source file:multibinder.TwoKafkaBindersApplicationTest.java

@Test
public void messagingWorks() {
    DirectChannel dataProducer = new DirectChannel();
    ((KafkaMessageChannelBinder) binderFactory.getBinder("kafka1")).bindProducer("dataIn", dataProducer,
            new ExtendedProducerProperties<>(new KafkaProducerProperties()));

    QueueChannel dataConsumer = new QueueChannel();
    ((KafkaMessageChannelBinder) binderFactory.getBinder("kafka2")).bindConsumer("dataOut",
            UUID.randomUUID().toString(), dataConsumer,
            new ExtendedConsumerProperties<>(new KafkaConsumerProperties()));

    String testPayload = "testFoo" + UUID.randomUUID().toString();
    dataProducer.send(MessageBuilder.withPayload(testPayload).build());

    Message<?> receive = dataConsumer.receive(5000);
    Assert.assertThat(receive, Matchers.notNullValue());
    Assert.assertThat(receive.getPayload(), CoreMatchers.equalTo(testPayload));
}

From source file:io.spring.batch.configuration.JobConfiguration.java

@Bean
public QueueChannel inboundRequests() {
    return new QueueChannel();
}

From source file:nl.rav.comparision.integration.unitofwork.java.UnitOfWorkSpringTest.java

private void createRouteBuilder() {
    handler = new AbstractReplyProducingMessageHandler() {
        @Override/*from   w  w w.ja  v a 2  s .  c om*/
        protected Object handleRequestMessage(Message<?> requestMessage) {
            return "baz";
        }
    };
    AbstractReplyProducingMessageHandler handler2 = new AbstractReplyProducingMessageHandler() {
        @Override
        protected Object handleRequestMessage(Message<?> requestMessage) {
            if (doFail.get()) {
                throw new RuntimeException("qux");
            }
            return requestMessage.getPayload();
        }
    };

    SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor();
    taskExecutor.setThreadNamePrefix("test-");
    ExecutorChannel intermediate = new ExecutorChannel(taskExecutor);
    handler.setOutputChannel(intermediate);
    intermediate.subscribe(handler2);

    replies = new QueueChannel();
    handler2.setOutputChannel(replies);

    successChannel = new QueueChannel();
    failureChannel = new QueueChannel();
    ExpressionEvaluatingRequestHandlerAdvice advice = new ExpressionEvaluatingRequestHandlerAdvice();
    advice.setBeanFactory(mock(BeanFactory.class));
    advice.setSuccessChannel(successChannel);
    advice.setFailureChannel(failureChannel);
    advice.setOnSuccessExpression("'foo'");
    advice.setOnFailureExpression("'bar:' + #exception.message");

    List<Advice> adviceChain = new ArrayList<Advice>();
    adviceChain.add(advice);
    handler.setAdviceChain(adviceChain);
    handler.afterPropertiesSet();
    handler2.setAdviceChain(adviceChain);
    handler2.afterPropertiesSet();
}

From source file:org.springframework.cloud.stream.binder.AbstractBinderTests.java

@Test
public void testSendAndReceive() throws Exception {
    Binder binder = getBinder();/*from  w  w  w  .  ja v a2  s.  co m*/
    BindingProperties outputBindingProperties = createProducerBindingProperties(createProducerProperties());
    DirectChannel moduleOutputChannel = createBindableChannel("output", outputBindingProperties);
    QueueChannel moduleInputChannel = new QueueChannel();
    Binding<MessageChannel> producerBinding = binder.bindProducer("foo.0", moduleOutputChannel,
            outputBindingProperties.getProducer());
    Binding<MessageChannel> consumerBinding = binder.bindConsumer("foo.0", "test", moduleInputChannel,
            createConsumerProperties());
    Message<?> message = MessageBuilder.withPayload("foo").setHeader(MessageHeaders.CONTENT_TYPE, "foo/bar")
            .build();
    // Let the consumer actually bind to the producer before sending a msg
    binderBindUnbindLatency();
    moduleOutputChannel.send(message);
    Message<?> inbound = receive(moduleInputChannel);
    assertThat(inbound).isNotNull();
    assertThat(inbound.getPayload()).isEqualTo("foo");
    assertThat(inbound.getHeaders().get(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE)).isNull();
    assertThat(inbound.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo("foo/bar");
    producerBinding.unbind();
    consumerBinding.unbind();
}

From source file:org.springframework.cloud.stream.binder.AbstractBinderTests.java

@Test
public void testSendAndReceiveMultipleTopics() throws Exception {
    Binder binder = getBinder();/*  w  w  w  .  j  a  v  a 2 s . co  m*/

    DirectChannel moduleOutputChannel1 = createBindableChannel("output1",
            createProducerBindingProperties(createProducerProperties()));
    DirectChannel moduleOutputChannel2 = createBindableChannel("output2",
            createProducerBindingProperties(createProducerProperties()));

    QueueChannel moduleInputChannel = new QueueChannel();

    Binding<MessageChannel> producerBinding1 = binder.bindProducer("foo.x", moduleOutputChannel1,
            createProducerProperties());
    Binding<MessageChannel> producerBinding2 = binder.bindProducer("foo.y", moduleOutputChannel2,
            createProducerProperties());

    Binding<MessageChannel> consumerBinding1 = binder.bindConsumer("foo.x", "test", moduleInputChannel,
            createConsumerProperties());
    Binding<MessageChannel> consumerBinding2 = binder.bindConsumer("foo.y", "test", moduleInputChannel,
            createConsumerProperties());

    String testPayload1 = "foo" + UUID.randomUUID().toString();
    Message<?> message1 = MessageBuilder.withPayload(testPayload1.getBytes()).build();
    String testPayload2 = "foo" + UUID.randomUUID().toString();
    Message<?> message2 = MessageBuilder.withPayload(testPayload2.getBytes()).build();

    // Let the consumer actually bind to the producer before sending a msg
    binderBindUnbindLatency();
    moduleOutputChannel1.send(message1);
    moduleOutputChannel2.send(message2);

    Message<?>[] messages = new Message[2];
    messages[0] = receive(moduleInputChannel);
    messages[1] = receive(moduleInputChannel);

    assertThat(messages[0]).isNotNull();
    assertThat(messages[1]).isNotNull();
    assertThat(messages).extracting("payload").containsExactlyInAnyOrder(testPayload1.getBytes(),
            testPayload2.getBytes());

    producerBinding1.unbind();
    producerBinding2.unbind();

    consumerBinding1.unbind();
    consumerBinding2.unbind();
}

From source file:org.springframework.cloud.stream.binder.AbstractBinderTests.java

@Test
public void testSendAndReceiveNoOriginalContentType() throws Exception {
    Binder binder = getBinder();//from   ww  w.j a  v a2  s . c o m

    BindingProperties producerBindingProperties = createProducerBindingProperties(createProducerProperties());
    DirectChannel moduleOutputChannel = createBindableChannel("output", producerBindingProperties);
    QueueChannel moduleInputChannel = new QueueChannel();
    Binding<MessageChannel> producerBinding = binder.bindProducer("bar.0", moduleOutputChannel,
            producerBindingProperties.getProducer());
    Binding<MessageChannel> consumerBinding = binder.bindConsumer("bar.0", "test", moduleInputChannel,
            createConsumerProperties());
    binderBindUnbindLatency();

    Message<?> message = MessageBuilder.withPayload("foo").build();
    moduleOutputChannel.send(message);
    Message<?> inbound = receive(moduleInputChannel);
    assertThat(inbound).isNotNull();
    assertThat(inbound.getPayload()).isEqualTo("foo");
    assertThat(inbound.getHeaders().get(BinderHeaders.BINDER_ORIGINAL_CONTENT_TYPE)).isNull();
    assertThat(inbound.getHeaders().get(MessageHeaders.CONTENT_TYPE)).isEqualTo(MimeTypeUtils.TEXT_PLAIN_VALUE);
    producerBinding.unbind();
    consumerBinding.unbind();
}