Examples of MessagingMessageListenerAdapter


Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    // Resolve the container and invoke a message on it

    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    endpoint.setupListenerContainer(container);
    MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener();

    MessageProperties properties = new MessageProperties();
    properties.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN);
    Message amqpMessage = new Message("Hello".getBytes(), properties);

    try {
      listener.onMessage(amqpMessage, mock(Channel.class));
    }
    catch (Exception e) {
      fail("should not have failed to process simple message but got " + e.getMessage());
    }
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    MethodRabbitListenerEndpoint endpoint = (MethodRabbitListenerEndpoint)
        simpleFactory.getListenerContainers().get(0).getEndpoint();

    SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
    endpoint.setupListenerContainer(container);
    MessagingMessageListenerAdapter listener = (MessagingMessageListenerAdapter) container.getMessageListener();

    MessageProperties properties = new MessageProperties();
    properties.setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN);
    Message amqpMessage = new Message("failValidation".getBytes(), properties);

    listener.onMessage(amqpMessage, mock(Channel.class));
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertNotNull(endpoint.createMessageListener(container));
  }

  @Test
  public void resolveMessageAndSession() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(
        org.springframework.amqp.core.Message.class, Channel.class);

    Channel channel = mock(Channel.class);
    listener.onMessage(createTextMessage("test"), channel);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void resolveGenericMessage() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(Message.class);

    Channel channel = mock(Channel.class);
    listener.onMessage(createTextMessage("test"), channel);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void resolveHeaderAndPayload() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class);

    Channel channel = mock(Channel.class);
    MessageProperties properties = new MessageProperties();
    properties.setHeader("myCounter", 55);
    org.springframework.amqp.core.Message message = createTextMessage("my payload", properties);
    listener.onMessage(message, channel);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void resolveCustomHeaderNameAndPayload() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, int.class);

    Channel channel = mock(Channel.class);
    MessageProperties properties = new MessageProperties();
    properties.setHeader("myCounter", 24);
    org.springframework.amqp.core.Message message = createTextMessage("my payload", properties);
    listener.onMessage(message, channel);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void resolveHeaders() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(String.class, Map.class);

    Channel channel = mock(Channel.class);
    MessageProperties properties = new MessageProperties();
    properties.setHeader("customInt", 1234);
    properties.setMessageId("abcd-1234");
    org.springframework.amqp.core.Message message = createTextMessage("my payload", properties);
    listener.onMessage(message, channel);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void resolveMessageHeaders() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(MessageHeaders.class);

    Channel channel = mock(Channel.class);
    MessageProperties properties = new MessageProperties();
    properties.setHeader("customLong", 4567L);
    properties.setType("myMessageType");
    org.springframework.amqp.core.Message message = createTextMessage("my payload", properties);
    listener.onMessage(message, channel);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void resolveRabbitMessageHeaderAccessor() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(AmqpMessageHeaderAccessor.class);

    Channel channel = mock(Channel.class);
    MessageProperties properties = new MessageProperties();
    properties.setHeader("customBoolean", true);
    properties.setAppId("myAppId");
    org.springframework.amqp.core.Message message = createTextMessage("my payload", properties);
    listener.onMessage(message, channel);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

Examples of org.springframework.amqp.rabbit.listener.adapter.MessagingMessageListenerAdapter

    assertDefaultListenerMethodInvocation();
  }

  @Test
  public void resolveObjectPayload() throws Exception {
    MessagingMessageListenerAdapter listener = createDefaultInstance(MyBean.class);
    MyBean myBean = new MyBean();
    myBean.name = "myBean name";

    Channel channel = mock(Channel.class);
    MessageProperties messageProperties = new MessageProperties();
    messageProperties.setContentType(MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT);
    org.springframework.amqp.core.Message message =
        new org.springframework.amqp.core.Message(SerializationUtils.serialize(myBean), messageProperties);
    listener.onMessage(message, channel);
    assertDefaultListenerMethodInvocation();
  }
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.