Package org.springframework.messaging.support

Examples of org.springframework.messaging.support.ExecutorSubscribableChannel


  }

  @Test
  public void handleMessageFromClientWithImmutableMessageInterceptor() {
    AtomicReference<Boolean> mutable = new AtomicReference<>();
    ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel();
    channel.addInterceptor(new ChannelInterceptorAdapter() {
      @Override
      public Message<?> preSend(Message<?> message, MessageChannel channel) {
        mutable.set(MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class).isMutable());
        return message;
      }
    });
    channel.addInterceptor(new ImmutableMessageChannelInterceptor());

    StompSubProtocolHandler handler = new StompSubProtocolHandler();
    handler.afterSessionStarted(this.session, channel);

    TextMessage message = StompTextMessageBuilder.create(StompCommand.CONNECT).build();
View Full Code Here


  }

  @Test
  public void handleMessageFromClientWithoutImmutableMessageInterceptor() {
    AtomicReference<Boolean> mutable = new AtomicReference<>();
    ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel();
    channel.addInterceptor(new ChannelInterceptorAdapter() {
      @Override
      public Message<?> preSend(Message<?> message, MessageChannel channel) {
        mutable.set(MessageHeaderAccessor.getAccessor(message, MessageHeaderAccessor.class).isMutable());
        return message;
      }
View Full Code Here

  static class TestMessageBrokerConfiguration extends DelegatingWebSocketMessageBrokerConfiguration {

    @Override
    @Bean
    public AbstractSubscribableChannel clientInboundChannel() {
      return new ExecutorSubscribableChannel(); // synchronous
    }
View Full Code Here

    }

    @Override
    @Bean
    public AbstractSubscribableChannel clientOutboundChannel() {
      return new ExecutorSubscribableChannel(); // synchronous
    }
View Full Code Here

  @Before
  public void setup() {

    TestMessageChannelDestinationResolver resolver = new TestMessageChannelDestinationResolver();

    this.myChannel = new ExecutorSubscribableChannel();
    resolver.registerMessageChannel("myChannel", this.myChannel);

    this.template = new TestDestinationResolvingMessagingTemplate();
    this.template.setDestinationResolver(resolver);
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

    final CountDownLatch latch = new CountDownLatch(1);

    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

  @Before
  public void setUp() throws Exception {
    logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
    this.port = SocketUtils.findAvailableTcpPort(61613);
    this.responseChannel = new ExecutorSubscribableChannel();
    this.responseHandler = new TestMessageHandler();
    this.responseChannel.subscribe(this.responseHandler);
    this.eventPublisher = new TestEventPublisher();
    startActiveMqBroker();
    createAndStartRelay();
View Full Code Here

  }


  @Bean
  public AbstractSubscribableChannel clientInboundChannel() {
    ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientInboundChannelExecutor());
    ChannelRegistration reg = getClientInboundChannelRegistration();
    channel.setInterceptors(reg.getInterceptors());
    return channel;
  }
View Full Code Here

  protected void configureClientInboundChannel(ChannelRegistration registration) {
  }

  @Bean
  public AbstractSubscribableChannel clientOutboundChannel() {
    ExecutorSubscribableChannel channel = new ExecutorSubscribableChannel(clientOutboundChannelExecutor());
    ChannelRegistration reg = getClientOutboundChannelRegistration();
    channel.setInterceptors(reg.getInterceptors());
    return channel;
  }
View Full Code Here

TOP

Related Classes of org.springframework.messaging.support.ExecutorSubscribableChannel

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.