Package org.springframework.messaging

Examples of org.springframework.messaging.MessageChannel.send()


    final GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext(configFilesChannelAdapterDemo);

    final MessageChannel stdinToJmsoutChannel = applicationContext.getBean("stdinToJmsoutChannel", MessageChannel.class);

    stdinToJmsoutChannel.send(MessageBuilder.withPayload("jms test").build());

    final QueueChannel queueChannel = applicationContext.getBean("queueChannel", QueueChannel.class);

    @SuppressWarnings("unchecked")
    Message<String> reply = (Message<String>) queueChannel.receive(20000);
View Full Code Here


    ConfigurableApplicationContext ac = new ClassPathXmlApplicationContext(
        "/META-INF/spring/integration/ControlBusDemo-context.xml");
    MessageChannel controlChannel = ac.getBean("controlChannel", MessageChannel.class);
    PollableChannel adapterOutputChanel = ac.getBean("adapterOutputChanel", PollableChannel.class);
    logger.info("Received before adapter started: " + adapterOutputChanel.receive(1000));
    controlChannel.send(new GenericMessage<String>("@inboundAdapter.start()"));
    logger.info("Received before adapter started: " + adapterOutputChanel.receive(1000));
    controlChannel.send(new GenericMessage<String>("@inboundAdapter.stop()"));
    logger.info("Received after adapter stopped: " + adapterOutputChanel.receive(1000));
    ac.close();
  }
View Full Code Here

    MessageChannel controlChannel = ac.getBean("controlChannel", MessageChannel.class);
    PollableChannel adapterOutputChanel = ac.getBean("adapterOutputChanel", PollableChannel.class);
    logger.info("Received before adapter started: " + adapterOutputChanel.receive(1000));
    controlChannel.send(new GenericMessage<String>("@inboundAdapter.start()"));
    logger.info("Received before adapter started: " + adapterOutputChanel.receive(1000));
    controlChannel.send(new GenericMessage<String>("@inboundAdapter.stop()"));
    logger.info("Received after adapter stopped: " + adapterOutputChanel.receive(1000));
    ac.close();
  }
}
View Full Code Here

  public static void main(String[] args) {
    AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/integration/helloWorldDemo.xml", HelloWorldApp.class);
    MessageChannel inputChannel = context.getBean("inputChannel", MessageChannel.class);
    PollableChannel outputChannel = context.getBean("outputChannel", PollableChannel.class);
    inputChannel.send(new GenericMessage<String>("World"));
    logger.info("==> HelloWorldDemo: " + outputChannel.receive(0).getPayload());
  }

}
View Full Code Here

    assertTrue(fileToSendB.exists());

    final Message<File> messageA = MessageBuilder.withPayload(fileToSendA).build();
    final Message<File> messageB = MessageBuilder.withPayload(fileToSendB).build();

    ftpChannel.send(messageA);
    ftpChannel.send(messageB);

    Thread.sleep(2000);

    assertTrue(new File(TestSuite.FTP_ROOT_DIR + File.separator + "a.txt").exists());
View Full Code Here

    final Message<File> messageA = MessageBuilder.withPayload(fileToSendA).build();
    final Message<File> messageB = MessageBuilder.withPayload(fileToSendB).build();

    ftpChannel.send(messageA);
    ftpChannel.send(messageB);

    Thread.sleep(2000);

    assertTrue(new File(TestSuite.FTP_ROOT_DIR + File.separator + "a.txt").exists());
    assertTrue(new File(TestSuite.FTP_ROOT_DIR + File.separator + "b.txt").exists());
View Full Code Here

  public void runDemo() throws Exception{
    ApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/integration/SendInstantMessageSample-context.xml");
   
    MessageChannel toUserChannel = context.getBean("toUserChannel", MessageChannel.class);
    Message<String> message = new GenericMessage<String>("Hello from Spring Integration XMPP");
    toUserChannel.send(message);
  }
}
View Full Code Here

    SubscribableChannel channel = new ExecutorSubscribableChannel(this.executor);
    channel.subscribe(new MessageHandler() {
      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
        replyChannel.send(new GenericMessage<String>("response"));
      }
    });

    String actual = this.template.convertSendAndReceive(channel, "request", String.class);
    assertEquals("response", actual);
View Full Code Here

      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        try {
          Thread.sleep(500);
          MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
          replyChannel.send(new GenericMessage<String>("response"));
          failure.set(new IllegalStateException("Expected exception"));
        }
        catch (InterruptedException e) {
          failure.set(e);
        }
View Full Code Here

    //sending 100,000 messages to Kafka server for topic test1
    for (int i = 0; i < 500; i++) {
      final User user = new User();
      user.setFirstName("fname" + i);
      user.setLastName("lname" + i);
      channel.send(
          MessageBuilder.withPayload(user)
              .setHeader("messageKey", String.valueOf(i))
              .setHeader("topic", "test1").build());

      LOG.info("message sent " + i);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.