Package org.springframework.messaging

Examples of org.springframework.messaging.SubscribableChannel.subscribe()


    // add a listener to this channel, otherwise there is not one defined
    // the reason we use a listener here is so we can assert truths on the
    // message and/or payload
    SubscribableChannel channel = (SubscribableChannel) incomingServerChannel;
    channel.subscribe(new AbstractReplyProducingMessageHandler() {

      @Override
      protected Object handleRequestMessage(Message<?> requestMessage) {
        byte[] payload = (byte[]) requestMessage.getPayload();
View Full Code Here


    // add a listener to this channel, otherwise there is not one defined
    // the reason we use a listener here is so we can assert truths on the
    // message and/or payload
    SubscribableChannel channel = (SubscribableChannel) incomingServerChannel;
    channel.subscribe(new AbstractReplyProducingMessageHandler(){

      @Override
      protected Object handleRequestMessage(Message<?> requestMessage) {
        CustomOrder payload = (CustomOrder) requestMessage.getPayload();
View Full Code Here

  @Test
  public void sendAndReceive() {

    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"));
      }
View Full Code Here

    this.template.setReceiveTimeout(1);
    this.template.setThrowExceptionOnLateReply(true);

    SubscribableChannel channel = new ExecutorSubscribableChannel(this.executor);
    channel.subscribe(new MessageHandler() {
      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        try {
          Thread.sleep(500);
          MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
View Full Code Here

  @Override
  public void bindReplier(String name, final MessageChannel requests, MessageChannel replies,
      Properties properties) {
    validateConsumerProperties(name, properties, Collections.emptySet());
    SubscribableChannel requestChannel = this.findOrCreateRequestReplyChannel("requestor." + name);
    requestChannel.subscribe(new MessageHandler() {

      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        requests.send(message);
      }
View Full Code Here

    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);
      }
View Full Code Here

    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());
  }

  protected void sendPayloadAndVerifyOutput(String streamName, Object payload, MessageTest test) {
View Full Code Here

    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 {
      }
    });
View Full Code Here

    MessageChannel input = context.getBean("input", MessageChannel.class);
    SubscribableChannel output = context.getBean("output", SubscribableChannel.class);

    final AtomicBoolean handled = new AtomicBoolean();
    output.subscribe(new MessageHandler() {
      @Override
      public void handleMessage(Message<?> message) throws MessagingException {
        handled.set(true);
        assertEquals("foohellobar", message.getPayload());
      }
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.