Package org.springframework.amqp.rabbit.support

Examples of org.springframework.amqp.rabbit.support.DefaultMessagePropertiesConverter


            }
          }
        });

    BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
        new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
        AcknowledgeMode.AUTO, true, 20, "good", "bad");

    blockingQueueConsumer.start();

    verify(channel).basicQos(20);
View Full Code Here


  private void testRequeueOrNotDefaultYes(Exception ex, boolean expectedRequeue) throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Channel channel = mock(Channel.class);
    BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
        new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
        AcknowledgeMode.AUTO, true, 1, "testQ");
    testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
  }
View Full Code Here

  private void testRequeueOrNotDefaultNo(Exception ex, boolean expectedRequeue) throws Exception {
    ConnectionFactory connectionFactory = mock(ConnectionFactory.class);
    Channel channel = mock(Channel.class);
    BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
        new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
        AcknowledgeMode.AUTO, true, 1, false, "testQ");
    testRequeueOrNotGuts(ex, expectedRequeue, channel, blockingQueueConsumer);
  }
View Full Code Here

    connectionFactory.setHost("localhost");
    connectionFactory.setPort(BrokerTestUtils.getPort());
    template.setConnectionFactory(connectionFactory);

    BlockingQueueConsumer blockingQueueConsumer = new BlockingQueueConsumer(connectionFactory,
        new DefaultMessagePropertiesConverter(), new ActiveObjectCounter<BlockingQueueConsumer>(),
        AcknowledgeMode.AUTO, true, 1, queue.getName());
    blockingQueueConsumer.start();

    // TODO: make this into a proper assertion. An exception can be thrown here by the Rabbit client and printed to
    // stderr without being rethrown (so hard to make a test fail).
View Full Code Here

          correlationId.set(basicProps.getCorrelationId());
        }
        else {
          correlationId.set((String) basicProps.getHeaders().get(CORRELATION_HEADER));
        }
        MessageProperties springProps = new DefaultMessagePropertiesConverter()
            .toMessageProperties(basicProps, null, "UTF-8");
        Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
        template.onMessage(replyMessage);
        return null;
      }}
View Full Code Here

    doAnswer(new Answer<Object>() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        BasicProperties basicProps = (BasicProperties) invocation.getArguments()[3];
        replyTo.set(basicProps.getReplyTo());
        correlationId.set(basicProps.getCorrelationId());
        MessageProperties springProps = new DefaultMessagePropertiesConverter()
            .toMessageProperties(basicProps, null, "UTF-8");
        Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
        template.onMessage(replyMessage);
        return null;
      }}
View Full Code Here

    doAnswer(new Answer<Object>() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        BasicProperties basicProps = (BasicProperties) invocation.getArguments()[3];
        nestedReplyTo.add(basicProps.getReplyTo());
        nestedCorrelation.add(basicProps.getCorrelationId());
        MessageProperties springProps = new DefaultMessagePropertiesConverter()
            .toMessageProperties(basicProps, null, "UTF-8");
        Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
        if (count.incrementAndGet() < 2) {
          Message anotherMessage = new Message("Second".getBytes(), springProps);
          template.setReplyQueue(new Queue("replyTo3"));
View Full Code Here

      public Object answer(InvocationOnMock invocation) throws Throwable {
        BasicProperties basicProps = (BasicProperties) invocation.getArguments()[3];
        replyTo.set(basicProps.getReplyTo());
        correlationId.set((String) basicProps.getHeaders().get(CORRELATION_HEADER));

        MessageProperties springProps = new DefaultMessagePropertiesConverter()
            .toMessageProperties(basicProps, null, "UTF-8");
        Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
        template.onMessage(replyMessage);
        return null;
      }}
View Full Code Here

    doAnswer(new Answer<Object>() {
      public Object answer(InvocationOnMock invocation) throws Throwable {
        BasicProperties basicProps = (BasicProperties) invocation.getArguments()[3];
        nestedReplyTo.add(basicProps.getReplyTo());
        nestedCorrelation.add(basicProps.getCorrelationId());
        MessageProperties springProps = new DefaultMessagePropertiesConverter()
            .toMessageProperties(basicProps, null, "UTF-8");
        Message replyMessage = new Message("!dlrow olleH".getBytes(), springProps);
        if (count.incrementAndGet() < 2) {
          Message anotherMessage = new Message("Second".getBytes(), springProps);
          template.setReplyQueue(new Queue("replyTo3"));
View Full Code Here

  }

  @Test
  public void testSendAndReceiveInCallback() throws Exception {
    template.convertAndSend(ROUTE, "message");
    final MessagePropertiesConverter messagePropertiesConverter = new DefaultMessagePropertiesConverter();
    String result = template.execute(new ChannelCallback<String>() {

      @Override
      public String doInRabbit(Channel channel) throws Exception {
        // We need noAck=false here for the message to be expicitly
        // acked
        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));
      }
View Full Code Here

TOP

Related Classes of org.springframework.amqp.rabbit.support.DefaultMessagePropertiesConverter

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.