Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.Message


        GetResponse response = channel.basicGet(ROUTE, false);
        MessageProperties messageProps = messagePropertiesConverter.toMessageProperties(
            response.getProps(), response.getEnvelope(), "UTF-8");
        // Explicit ack
        channel.basicAck(response.getEnvelope().getDeliveryTag(), false);
        return (String) new SimpleMessageConverter().fromMessage(new Message(response.getBody(), messageProps));
      }
    });
    assertEquals("message", result);
    result = (String) template.receiveAndConvert(ROUTE);
    assertEquals(null, result);
View Full Code Here


    // Set up a consumer to respond to our producer
    Future<Message> received = executor.submit(new Callable<Message>() {

      @Override
      public Message call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive();
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return message;
      }

    });
    Message message = new Message("test-message".getBytes(), new MessageProperties());
    Message reply = template.sendAndReceive(message);
    assertEquals(new String(message.getBody()), new String(received.get(1000, TimeUnit.MILLISECONDS).getBody()));
    assertNotNull("Reply is expected", reply);
    assertEquals(new String(message.getBody()), new String(reply.getBody()));
    // Message was consumed so nothing left on queue
    reply = template.receive();
    assertEquals(null, reply);
    cachingConnectionFactory.destroy();
  }
View Full Code Here

    // Set up a consumer to respond to our producer
    Future<Message> received = executor.submit(new Callable<Message>() {

      @Override
      public Message call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive();
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return message;
      }

    });
    Message message = new Message("test-message".getBytes(), new MessageProperties());
    Message reply = template.sendAndReceive(message);
    assertEquals(new String(message.getBody()), new String(received.get(1000, TimeUnit.MILLISECONDS).getBody()));
    assertNotNull("Reply is expected", reply);
    assertEquals(new String(message.getBody()), new String(reply.getBody()));
    // Message was consumed so nothing left on queue
    reply = template.receive();
    assertEquals(null, reply);

    assertTrue(execConfiguredOk.get());
View Full Code Here

    // Set up a consumer to respond to our producer
    Future<Message> received = executor.submit(new Callable<Message>() {

      @Override
      public Message call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive(ROUTE);
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return message;
      }

    });
    Message message = new Message("test-message".getBytes(), new MessageProperties());
    Message reply = template.sendAndReceive(ROUTE, message);
    assertEquals(new String(message.getBody()), new String(received.get(1000, TimeUnit.MILLISECONDS).getBody()));
    assertNotNull("Reply is expected", reply);
    assertEquals(new String(message.getBody()), new String(reply.getBody()));
    // Message was consumed so nothing left on queue
    reply = template.receive(ROUTE);
    assertEquals(null, reply);
    cachingConnectionFactory.destroy();
  }
View Full Code Here

    // Set up a consumer to respond to our producer
    Future<Message> received = executor.submit(new Callable<Message>() {

      @Override
      public Message call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive(ROUTE);
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return message;
      }

    });
    Message message = new Message("test-message".getBytes(), new MessageProperties());
    Message reply = template.sendAndReceive("", ROUTE, message);
    assertEquals(new String(message.getBody()), new String(received.get(1000, TimeUnit.MILLISECONDS).getBody()));
    assertNotNull("Reply is expected", reply);
    assertEquals(new String(message.getBody()), new String(reply.getBody()));
    // Message was consumed so nothing left on queue
    reply = template.receive(ROUTE);
    assertEquals(null, reply);
    cachingConnectionFactory.destroy();
  }
View Full Code Here

    // Set up a consumer to respond to our producer
    Future<String> received = executor.submit(new Callable<String>() {

      @Override
      public String call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive();
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return (String) template.getMessageConverter().fromMessage(message);
      }

    });
    String result = (String) template.convertSendAndReceive("message");
View Full Code Here

    // Set up a consumer to respond to our producer
    Future<String> received = executor.submit(new Callable<String>() {

      @Override
      public String call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive(ROUTE);
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return (String) template.getMessageConverter().fromMessage(message);
      }

    });
    String result = (String) template.convertSendAndReceive(ROUTE, "message");
View Full Code Here

    // Set up a consumer to respond to our producer
    Future<String> received = executor.submit(new Callable<String>() {

      @Override
      public String call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive(ROUTE);
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return (String) template.getMessageConverter().fromMessage(message);
      }

    });
    String result = (String) template.convertSendAndReceive("", ROUTE, "message");
View Full Code Here

    // Set up a consumer to respond to our producer
    Future<String> received = executor.submit(new Callable<String>() {

      @Override
      public String call() throws Exception {
        Message message = null;
        for (int i = 0; i < 10; i++) {
          message = template.receive();
          if (message != null) {
            break;
          }
          Thread.sleep(100L);
        }
        assertNotNull("No message received", message);
        template.send(message.getMessageProperties().getReplyTo(), message);
        return (String) template.getMessageConverter().fromMessage(message);
      }

    });
    String result = (String) template.convertSendAndReceive((Object) "message", new MessagePostProcessor() {
      @Override
      public Message postProcessMessage(Message message) throws AmqpException {
        try {
          byte[] newBody = new String(message.getBody(), "UTF-8").toUpperCase().getBytes("UTF-8");
          return new Message(newBody, message.getMessageProperties());
        }
        catch (Exception e) {
          throw new AmqpException("unexpected failure in test", e);
        }
      }
View Full Code Here

    Envelope envelope = delivery.getEnvelope();

    MessageProperties messageProperties = this.messagePropertiesConverter.toMessageProperties(
        delivery.getProperties(), envelope, "UTF-8");
    messageProperties.setMessageCount(0);
    Message message = new Message(body, messageProperties);
    if (logger.isDebugEnabled()) {
      logger.debug("Received message: " + message);
    }
    deliveryTags.add(messageProperties.getDeliveryTag());
    return message;
View Full Code Here

TOP

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

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.