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

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

Introduction

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

Prototype

public DirectChannel() 

Source Link

Document

Create a channel with default RoundRobinLoadBalancingStrategy

Usage

From source file:simple.flow.Application.java

@Bean
public MessageChannel requestChannel1() {
    return new DirectChannel();
}

From source file:mx.uaq.facturacion.enlace.system.EmailSystemTest.java

private DirectChannel loggerMessages(String channel) {
    DirectChannel directChannel = new DirectChannel();
    directChannel.subscribe((message) -> {
        System.out.println(channel + ": " + message.getPayload());
    });//from  w  w w . ja  v a  2  s .  com
    return directChannel;
}

From source file:simple.flow.Application.java

@Bean
public MessageChannel requestChannel2() {
    return new DirectChannel();
}

From source file:io.jmnarloch.spring.cloud.stream.binder.hermes.HermesClientBinderTest.java

@Test
public void shouldPublishMessageWithBytePayload() {

    // given//from   w  w  w  .  j ava  2s .c o  m
    DirectChannel output = new DirectChannel();

    ArgumentCaptor<URI> uriCaptor = ArgumentCaptor.forClass(URI.class);
    ArgumentCaptor<HermesMessage> messageCaptor = ArgumentCaptor.forClass(HermesMessage.class);

    // when
    Binding<MessageChannel> binding = binder.bindProducer(OUTPUT_NAME, output,
            new ExtendedProducerProperties<>(new HermesProducerProperties()));

    // then
    output.send(new GenericMessage<>(MESSAGE, json()));
    verify(hermesSender).send(uriCaptor.capture(), messageCaptor.capture());

    assertEquals("http://localhost:8080/topics/topic", uriCaptor.getValue().toString());
    assertArrayEquals(MESSAGE.getBytes(), messageCaptor.getValue().getBody());

    binding.unbind();
}

From source file:com.mine.cassandra.sink.CassandraSinkConfiguration.java

@Bean
public MessageChannel toSink() {
    return new DirectChannel();
}

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();/*  ww w  .  java2 s .  c  o m*/
}

From source file:org.springframework.cloud.netflix.hystrix.amqp.HystrixStreamAutoConfiguration.java

@Bean
public DirectChannel hystrixStream() {
    return new DirectChannel();
}

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.jmnarloch.spring.cloud.stream.binder.hermes.HermesClientBinderTest.java

@Test
public void shouldPublishMessageWithError() {

    // given/*from  www  .  j  ava 2 s.  co  m*/
    reset(hermesSender);
    final HermesResponse response = HermesResponseBuilder.hermesResponse().withHttpStatus(500).build();

    when(hermesSender.send(any(URI.class), any(HermesMessage.class)))
            .thenReturn(CompletableFuture.completedFuture(response));

    DirectChannel output = new DirectChannel();

    // when
    Binding<MessageChannel> binding = binder.bindProducer(OUTPUT_NAME, output,
            new ExtendedProducerProperties<>(new HermesProducerProperties()));

    // then
    output.send(new GenericMessage<>(MESSAGE, json()));
    verify(hermesSender, times(4)).send(any(URI.class), any(HermesMessage.class));
    binding.unbind();
}

From source file:ru.jts_dev.authserver.config.AuthIntegrationConfig.java

@Bean
public MessageChannel tcpInputChannel() {
    return new DirectChannel();
}