Package org.springframework.messaging

Examples of org.springframework.messaging.SubscribableChannel


  public void testHappyPath() {

    // 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


  public void testHappyPath() {

    // 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

public class SockJsWebSocketHandlerTests {


  @Test
  public void getSubProtocols() throws Exception {
    SubscribableChannel channel = mock(SubscribableChannel.class);
    SubProtocolWebSocketHandler handler = new SubProtocolWebSocketHandler(channel, channel);
    StompSubProtocolHandler stompHandler = new StompSubProtocolHandler();
    handler.addProtocolHandler(stompHandler);

    TaskScheduler scheduler = mock(TaskScheduler.class);
View Full Code Here

  private UserSessionRegistry userSessionRegistry;


  @Before
  public void setup() {
    SubscribableChannel inChannel = Mockito.mock(SubscribableChannel.class);
    SubscribableChannel outChannel = Mockito.mock(SubscribableChannel.class);
    this.webSocketHandler = new SubProtocolWebSocketHandler(inChannel, outChannel);
    this.userSessionRegistry = new DefaultUserSessionRegistry();
    this.endpointRegistry = new WebMvcStompEndpointRegistry(this.webSocketHandler,
        new WebSocketTransportRegistration(), this.userSessionRegistry, Mockito.mock(TaskScheduler.class));
  }
View Full Code Here


  @Test
  public void test() {

    SubscribableChannel clientInboundChannel = new StubMessageChannel();
    MessageChannel clientOutboundChannel = new StubMessageChannel();
    SubscribableChannel brokerChannel = new StubMessageChannel();

    String[] destinationPrefixes = new String[] { "/foo", "/bar" };

    StompBrokerRelayRegistration registration = new StompBrokerRelayRegistration(
        clientInboundChannel, clientOutboundChannel, destinationPrefixes);
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

  private TestController testController;


  @Before
  public void setup() {
    SubscribableChannel channel = Mockito.mock(SubscribableChannel.class);
    SimpMessageSendingOperations brokerTemplate = new SimpMessagingTemplate(channel);

    this.messageHandler = new TestSimpAnnotationMethodMessageHandler(brokerTemplate, channel, channel);
    this.messageHandler.setApplicationContext(new StaticApplicationContext());
    this.messageHandler.setValidator(new StringTestValidator(TEST_INVALID_VALUE));
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);
      }
    });

    // TODO: handle Pollable ?
    Assert.isInstanceOf(SubscribableChannel.class, replies);
    final SubscribableChannel replyChannel = this.findOrCreateRequestReplyChannel("replier." + name);
    ((SubscribableChannel) replies).subscribe(new MessageHandler() {

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

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

TOP

Related Classes of org.springframework.messaging.SubscribableChannel

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.