Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.MessageProperties


    log.warn("This is a WARN message with properties");
    log.error("This is an ERROR message with properties", new RuntimeException("Test exception"));
    MDC.remove(propertyName);

    assertTrue(testListener.getLatch().await(5, TimeUnit.SECONDS));
    MessageProperties messageProperties = testListener.getMessageProperties();
    assertNotNull(messageProperties);
    assertNotNull(messageProperties.getHeaders().get(propertyName));
    assertEquals(propertyValue, messageProperties.getHeaders().get(propertyName));
    Object location = messageProperties.getHeaders().get("location");
    assertNotNull(location);
    assertThat(location, instanceOf(String.class));
    assertThat((String) location,
        startsWith("org.springframework.amqp.rabbit.logback.AmqpAppenderIntegrationTests.testAppenderWithProps()"));
  }
View Full Code Here


  @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

  @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

  @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

  @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

  @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

    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

    String responseExchange = "fooQueue";
    String responseRoutingKey = "abc-1234";

    listener.setResponseExchange(responseExchange);
    listener.setResponseRoutingKey(responseRoutingKey);
    MessageProperties properties = new MessageProperties();
    properties.setCorrelationId(correlationId.getBytes(SimpleMessageConverter.DEFAULT_CHARSET));
    org.springframework.amqp.core.Message message = createTextMessage(body, properties);

    processAndReply(listener, message, responseExchange, responseRoutingKey, false, correlationId);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

    MessagingMessageListenerAdapter listener = createDefaultInstance(org.springframework.amqp.core.Message.class);
    listener.setMessageConverter(null);
    listener.setResponseExchange("fooQueue");
    String body = "echo text";

    org.springframework.amqp.core.Message message = createTextMessage(body, new MessageProperties());


    processAndReply(listener, message, "fooQueue", "", false, null);
    assertDefaultListenerMethodInvocation();
  }
View Full Code Here

    MessagingMessageListenerAdapter listener = createDefaultInstance(org.springframework.amqp.core.Message.class);
    listener.setMessageConverter(null);
    listener.setResponseExchange("fooQueue");
    String body = "echo text";

    org.springframework.amqp.core.Message message = createTextMessage(body, new MessageProperties());

    try {
      processAndReply(listener, message, "fooQueue", "", false, null);
      fail("Should have fail. Not converter and the reply is not a message");
    }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.core.MessageProperties

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.