Package org.springframework.messaging

Examples of org.springframework.messaging.MessageChannel


  @Override
  public void bindRequestor(final String name, MessageChannel requests, final MessageChannel replies,
      Properties properties) {
    validateConsumerProperties(name, properties, Collections.emptySet());
    final MessageChannel requestChannel = this.findOrCreateRequestReplyChannel("requestor." + name);
    // TODO: handle Pollable ?
    Assert.isInstanceOf(SubscribableChannel.class, requests);
    ((SubscribableChannel) requests).subscribe(new MessageHandler() {

      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        requestChannel.send(message);
      }
    });

    ExecutorChannel replyChannel = this.findOrCreateRequestReplyChannel("replier." + name);
    replyChannel.subscribe(new MessageHandler() {
View Full Code Here


  }

  @Override
  public void unbindProducer(String name, MessageChannel channel) {
    this.requestReplyChannels.remove("replier." + name);
    MessageChannel requestChannel = this.requestReplyChannels.remove("requestor." + name);
    if (requestChannel == null) {
      super.unbindProducer(name, channel);
    }
  }
View Full Code Here

    Module module = moduleFactory.createModule(compositeDescriptor, deploymentProperties);
    assertTrue(module instanceof CompositeModule);
    module.initialize();
    module.start();
    assertEquals(processor, module.getType());
    MessageChannel input = module.getComponent("input", MessageChannel.class);
    assertNotNull(input);
    SubscribableChannel output = module.getComponent("output", SubscribableChannel.class);
    assertNotNull(output);
    final AtomicReference<Message<?>> result = new AtomicReference<Message<?>>();
    output.subscribe(new MessageHandler() {

      @Override
      public void handleMessage(Message<?> message) {
        result.set(message);
      }
    });
    input.send(MessageBuilder.withPayload("foo").build());
    Message<?> message = result.get();
    assertEquals("foo12", message.getPayload());
  }
View Full Code Here

    singleNodeApplication.pluginContext().getBean("queue:y", MessageChannel.class);
    assertFalse(singleNodeApplication.pluginContext().containsBean("queue:z"));

    testChannel.send(MessageBuilder.withPayload("z").build());
    Thread.sleep(2000);
    MessageChannel y3 = singleNodeApplication.pluginContext().getBean("queue:y", MessageChannel.class);
    MessageChannel z3 = singleNodeApplication.pluginContext().getBean("queue:z", MessageChannel.class);
    assertNotNull(y3);
    assertNotNull(z3);

    verifyDynamicProperties(bus, "queue");
View Full Code Here

    singleNodeApplication.pluginContext().getBean("topic:y", MessageChannel.class);
    assertFalse(singleNodeApplication.pluginContext().containsBean("topic:z"));

    testChannel.send(MessageBuilder.withPayload("z").build());
    Thread.sleep(2000);
    MessageChannel y3 = singleNodeApplication.pluginContext().getBean("topic:y", MessageChannel.class);
    MessageChannel z3 = singleNodeApplication.pluginContext().getBean("topic:z", MessageChannel.class);
    assertNotNull(y3);
    assertNotNull(z3);

    QueueChannel consumer = new QueueChannel();
    bus.bindPubSubConsumer("topic:y", consumer, null);
View Full Code Here

  protected void sendMessageAndVerifyOutput(String streamName, Message<?> message, MessageTest test) {
    Assert.notNull(streamName, "streamName cannot be null");
    Assert.notNull(test, "test cannot be null");
    Assert.notNull(message, "message cannot be null");

    MessageChannel producer = getSourceOutputChannel(streamName);
    SubscribableChannel consumer = getSinkInputChannel(streamName);
    consumer.subscribe(test);
    producer.send(message);
    assertTrue(test.getMessageHandled());
  }
View Full Code Here

    deployStream(
        tapName,
        tapChannel + " > sink");

    MessageChannel producer = getSourceOutputChannel(streamName);
    SubscribableChannel consumer = getSinkInputChannel(tapName);
    SubscribableChannel streamConsumer = getSinkInputChannel(streamName);

    // Add a dummy consumer to the stream in case there is none
    streamConsumer.subscribe(new MessageHandler() {

      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
      }
    });

    consumer.subscribe(test);
    producer.send(message);
    assertTrue(test.getMessageHandled());

    undeployStream(tapName);
  }
View Full Code Here

  @Test
  public void testWritesWithRollover() throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/xd/integration/hadoop/config/HdfsOutboundChannelAdapterIntegrationTests.xml");
    MessageChannel channel = context.getBean("hdfsOut", MessageChannel.class);
    channel.send(MessageBuilder.withPayload("foo").build());
    channel.send(MessageBuilder.withPayload("bar").build());
    FileSystem fileSystem = context.getBean("hadoopFs", FileSystem.class);
    String path = context.getBean("path", String.class);
    context.close();
    Path basepath = new Path(path + "/testdir/");
    Path filepath0 = new Path(basepath, "testfile-0");
View Full Code Here

  @Test
  public void testWritesWithPartition() throws Exception {

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/xd/integration/hadoop/config/HdfsOutboundChannelAdapterIntegrationPartitionTests.xml");
    MessageChannel channel = context.getBean("hdfsOut", MessageChannel.class);

    FileSystem fileSystem = context.getBean("hadoopFs", FileSystem.class);
    String path = context.getBean("path", String.class);
    String YYYYMM = new SimpleDateFormat("yyyy/MM").format(new Date());
    Path basepath = new Path(path + "/testdir2/");
    Path filepath0 = new Path(basepath, YYYYMM + "/0_hash/foos_list/testfile-0");
    Path filepath1 = new Path(basepath, YYYYMM + "/0_hash/bars_list/testfile-0");

    fileSystem.delete(basepath, true);

    channel.send(MessageBuilder.withPayload("foo").build());
    channel.send(MessageBuilder.withPayload("bar").build());
    context.close();
    assertTrue(fileSystem.exists(basepath));
    assertTrue(fileSystem.exists(filepath0));
    assertTrue(fileSystem.exists(filepath1));
    BufferedReader reader0 = new BufferedReader(new InputStreamReader(fileSystem.open(filepath0)));
View Full Code Here

  @Test
  public void testWritingDataset() throws Exception {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
        "org/springframework/xd/integration/hadoop/config/DatasetOutboundChannelAdapterPartitionedIntegrationTests.xml");
    MessageChannel channel = context.getBean("datasetOut", MessageChannel.class);
    TestPojo t1 = new TestPojo();
    t1.setId(1);
    t1.setTimestamp(System.currentTimeMillis());
    t1.setDescription("foo");
    channel.send(MessageBuilder.withPayload(Collections.singletonList(t1)).build());
    TestPojo t2 = new TestPojo();
    t2.setId(2);
    t2.setTimestamp(System.currentTimeMillis());
    t2.setDescription("x"); //TODO: this is temporary, due to changes in Kite SDK 0.17.0
    channel.send(MessageBuilder.withPayload(Collections.singletonList(t2)).build());

    DatasetOperations datasetOperations = context.getBean("datasetOperations", DatasetOperations.class);
    String path = context.getBean("path", String.class);
    assertTrue("Dataset path created", new File(path).exists());
    assertTrue("Dataset storage created",
View Full Code Here

TOP

Related Classes of org.springframework.messaging.MessageChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.