Package org.springframework.amqp.core

Examples of org.springframework.amqp.core.Address


   * @see #setResponseRoutingKey(String)
   * @see org.springframework.amqp.core.Message#getMessageProperties()
   * @see org.springframework.amqp.core.MessageProperties#getReplyTo()
   */
  protected Address getReplyToAddress(Message request) throws Exception {
    Address replyTo = request.getMessageProperties().getReplyToAddress();
    if (replyTo == null) {
      if (this.responseExchange == null) {
        throw new AmqpException(
            "Cannot determine ReplyTo message property value: " +
                "Request message does not contain reply-to property, " +
                "and no default response Exchange was set.");
      }
      replyTo = new Address(this.responseExchange, this.responseRoutingKey);
    }
    return replyTo;
  }
View Full Code Here


                      final String replyRoutingKey) throws AmqpException {
    return this.receiveAndReply(queueName, callback, new ReplyToAddressCallback<S>() {

      @Override
      public Address getReplyToAddress(Message request, S reply) {
        return new Address(replyExchange, replyRoutingKey);
      }

    });
  }
View Full Code Here

              throw e;
            }
          }

          if (reply != null) {
            Address replyTo = replyToAddressCallback.getReplyToAddress(receiveMessage, reply);

            Message replyMessage = RabbitTemplate.this.convertMessageIfNecessary(reply);

            MessageProperties receiveMessageProperties = receiveMessage.getMessageProperties();
            MessageProperties replyMessageProperties = replyMessage.getMessageProperties();

            Object correlation = RabbitTemplate.this.correlationKey == null
                ? receiveMessageProperties.getCorrelationId()
                : receiveMessageProperties.getHeaders().get(RabbitTemplate.this.correlationKey);

            if (RabbitTemplate.this.correlationKey == null || correlation == null) {
              // using standard correlationId property
              if (correlation == null) {
                String messageId = receiveMessageProperties.getMessageId();
                if (messageId != null) {
                  correlation = messageId.getBytes(RabbitTemplate.this.encoding);
                }
              }
              replyMessageProperties.setCorrelationId((byte[]) correlation);
            }
            else {
              replyMessageProperties.setHeader(RabbitTemplate.this.correlationKey, correlation);
            }

            // 'doSend()' takes care about 'channel.txCommit()'.
            RabbitTemplate.this.doSend(channel, replyTo.getExchangeName(), replyTo.getRoutingKey(), replyMessage, null);
          }
          else if (channelLocallyTransacted) {
            channel.txCommit();
          }
View Full Code Here

   * @throws AmqpException if no {@link Address} can be determined
   * @see org.springframework.amqp.core.Message#getMessageProperties()
   * @see org.springframework.amqp.core.MessageProperties#getReplyTo()
   */
  private Address getReplyToAddress(Message request) throws AmqpException {
    Address replyTo = request.getMessageProperties().getReplyToAddress();
    if (replyTo == null) {
      if (this.exchange == null) {
        throw new AmqpException(
            "Cannot determine ReplyTo message property value: "
                + "Request message does not contain reply-to property, and no default Exchange was set.");
      }
      replyTo = new Address(this.exchange, this.routingKey);
    }
    return replyTo;
  }
View Full Code Here

    AmqpTemplate directForwardingTemplate = new AbstractAmqpTemplate() {
      @Override
      public Object convertSendAndReceive(Object payload) throws AmqpException {
        MessageConverter messageConverter = serviceExporter.getMessageConverter();

        Address replyTo = new Address("fakeExchangeName", "fakeRoutingKey");
        MessageProperties messageProperties = new MessageProperties();
        messageProperties.setReplyToAddress(replyTo);
        Message message = messageConverter.toMessage(payload, messageProperties);

        serviceExporter.onMessage(message);
View Full Code Here

  @Test
  public void fromBodyAndMessageCloned() {
    byte[] bytes = "foo".getBytes();
    MessageProperties properties = new MessageProperties();
    Address replyTo = new Address("address");
    Message message1 = MessageBuilder.withClonedBody(bytes)
        .andProperties(this.setAll(MessagePropertiesBuilder.fromClonedProperties(properties))
            .setReplyToAddress(replyTo)
            .setReplyToAddressIfAbsent(new Address("addressxxxx"))
            .build())
        .build();
    assertNotSame(bytes, message1.getBody());
    assertTrue(Arrays.equals(bytes, message1.getBody()));
    assertEquals(replyTo.toString(), message1.getMessageProperties().getReplyToAddress().toString());

    Address foo = new Address("foo");
    Message message2 = MessageBuilder.fromClonedMessage(message1)
        .setReplyToAddress(foo)
        .build();
    assertNotSame(message1.getBody(), message2.getBody());
    assertTrue(Arrays.equals(bytes, message2.getBody()));
    assertEquals(message1.getMessageProperties(), MessageBuilder.fromMessage(message2)
        .setReplyToAddress(replyTo).build().getMessageProperties());
    assertEquals(foo.toString(), message2.getMessageProperties().getReplyToAddress().toString());

    Message message3 = MessageBuilder.fromClonedMessage(message1)
        .setReplyToAddressIfAbsent(foo)
        .build();
    assertEquals(replyTo.toString(), message3.getMessageProperties().getReplyToAddress().toString());

    Message message4 = MessageBuilder.fromClonedMessage(message1)
        .setReplyToAddress(null)
        .setReplyToAddressIfAbsent(foo)
        .build();
    assertEquals(foo.toString(), message4.getMessageProperties().getReplyToAddress().toString());
  }
View Full Code Here

  private MessageConverter messageConverter = new SimpleMessageConverter();

  @Override
  public void onMessage(Message message) {
    Address replyToAddress = message.getMessageProperties().getReplyToAddress();
    if (replyToAddress == null) {
      throw new AmqpRejectAndDontRequeueException("No replyToAddress in inbound AMQP Message");
    }

    Object invocationRaw = messageConverter.fromMessage(message);
View Full Code Here

TOP

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

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.