Tabnine Logo
MessageProperties.getCorrelationId
Code IndexAdd Tabnine to your IDE (free)

How to use
getCorrelationId
method
in
org.springframework.amqp.core.MessageProperties

Best Java code snippets using org.springframework.amqp.core.MessageProperties.getCorrelationId (Showing top 20 results out of 315)

origin: spring-projects/spring-integration

  headers.put(AmqpHeaders.CONTENT_TYPE, contentType);
String correlationId = amqpMessageProperties.getCorrelationId();
if (StringUtils.hasText(correlationId)) {
  headers.put(AmqpHeaders.CORRELATION_ID, correlationId);
origin: com.dell.cpsd.common.messaging/common-rabbitmq

  /**
   * {@inheritDoc}
   */
  @Override
  public Message postProcessMessage(final Message message) throws AmqpException
  {
    if (message == null)
    {
      return message;
    }

    final MessageProperties messageProperties = message.getMessageProperties();

    messageProperties.setTimestamp(this.properties.getTimestamp());

    final byte[] correlationId = this.properties.getCorrelationId();
    messageProperties.setCorrelationId(correlationId);

    messageProperties.setCorrelationIdString(this.properties.getCorrelationIdString());

    messageProperties.setReplyTo(this.properties.getReplyTo());
    messageProperties.setExpiration(this.properties.getExpiration());

    return message;
  }
}
origin: spring-projects/spring-integration

assertEquals(99L, amqpProperties.getContentLength());
assertEquals("test.contentType", amqpProperties.getContentType());
assertEquals(testCorrelationId, amqpProperties.getCorrelationId());
assertEquals(Integer.valueOf(1234), amqpProperties.getDelay());
assertEquals(MessageDeliveryMode.NON_PERSISTENT, amqpProperties.getDeliveryMode());
origin: spring-projects/spring-amqp

public MessageBuilderSupport<T> setCorrelationIdIfAbsent(String correlationId) {
  if (this.properties.getCorrelationId() == null) {
    this.properties.setCorrelationId(correlationId);
  }
  return this;
}
origin: eclipse/hawkbit

private static boolean isCorrelationIdNotEmpty(final Message message) {
  return StringUtils.hasLength(message.getMessageProperties().getCorrelationId());
}
origin: eclipse/hawkbit

protected static boolean isCorrelationIdEmpty(final Message message) {
  return !StringUtils.hasLength(message.getMessageProperties().getCorrelationId());
}
origin: org.springframework.amqp/spring-rabbit

@Override
public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
  MessageProperties messageProperties = message.getMessageProperties();
  String correlationId = messageProperties.getCorrelationId();
  if (StringUtils.hasText(correlationId)) {
    RabbitFuture<?> future = this.pending.remove(correlationId);
    if (future != null) {
      future.setException(new AmqpMessageReturnedException("Message returned", message, replyCode, replyText,
          exchange, routingKey));
    }
    else {
      if (this.logger.isWarnEnabled()) {
        this.logger.warn("No pending reply - perhaps timed out? Message returned: " + message);
      }
    }
  }
}
origin: spring-projects/spring-amqp

@Override
public void returnedMessage(Message message, int replyCode, String replyText, String exchange, String routingKey) {
  MessageProperties messageProperties = message.getMessageProperties();
  String correlationId = messageProperties.getCorrelationId();
  if (StringUtils.hasText(correlationId)) {
    RabbitFuture<?> future = this.pending.remove(correlationId);
    if (future != null) {
      future.setException(new AmqpMessageReturnedException("Message returned", message, replyCode, replyText,
          exchange, routingKey));
    }
    else {
      if (this.logger.isWarnEnabled()) {
        this.logger.warn("No pending reply - perhaps timed out? Message returned: " + message);
      }
    }
  }
}
origin: spring-projects/spring-amqp

private String getOrSetCorrelationIdAndSetReplyTo(Message message) {
  String correlationId;
  MessageProperties messageProperties = message.getMessageProperties();
  Assert.notNull(messageProperties, "the message properties cannot be null");
  String currentCorrelationId = messageProperties.getCorrelationId();
  if (!StringUtils.hasText(currentCorrelationId)) {
    correlationId = UUID.randomUUID().toString();
    messageProperties.setCorrelationId(correlationId);
    Assert.isNull(messageProperties.getReplyTo(), "'replyTo' property must be null");
  }
  else {
    correlationId = currentCorrelationId;
  }
  messageProperties.setReplyTo(this.replyAddress);
  return correlationId;
}
origin: org.springframework.amqp/spring-rabbit

private String getOrSetCorrelationIdAndSetReplyTo(Message message) {
  String correlationId;
  MessageProperties messageProperties = message.getMessageProperties();
  Assert.notNull(messageProperties, "the message properties cannot be null");
  String currentCorrelationId = messageProperties.getCorrelationId();
  if (!StringUtils.hasText(currentCorrelationId)) {
    correlationId = UUID.randomUUID().toString();
    messageProperties.setCorrelationId(correlationId);
    Assert.isNull(messageProperties.getReplyTo(), "'replyTo' property must be null");
  }
  else {
    correlationId = currentCorrelationId;
  }
  messageProperties.setReplyTo(this.replyAddress);
  return correlationId;
}
origin: societe-generale/rabbitmq-advanced-spring-boot-starter

@Override
public Message postProcessMessage(final Message message) {
 MessageProperties messageProperties = message.getMessageProperties();
 String correlationId = messageProperties.getCorrelationId();
 if (correlationId == null) {
  correlationId = (tracer!=null && tracer.currentSpan()!=null)?
      tracer.currentSpan().context().traceIdString():UUID.randomUUID().toString();
  messageProperties.setCorrelationId(correlationId);
 }
 messageProperties.getHeaders().put("correlation-id", correlationId);
 return message;
}
origin: spring-projects/spring-amqp

@Nullable
private Message exchangeMessages(final String exchange, final String routingKey, final Message message,
    final CorrelationData correlationData, Channel channel, final PendingReply pendingReply, String messageTag)
    throws Exception { // NOSONAR TODO: change to IOException, InterruptedException in 2.2.
  Message reply;
  boolean mandatory = isMandatoryFor(message);
  if (mandatory && this.returnCallback == null) {
    message.getMessageProperties().getHeaders().put(RETURN_CORRELATION_KEY, messageTag);
  }
  doSend(channel, exchange, routingKey, message, mandatory, correlationData);
  reply = this.replyTimeout < 0 ? pendingReply.get() : pendingReply.get(this.replyTimeout, TimeUnit.MILLISECONDS);
  if (this.logger.isDebugEnabled()) {
    this.logger.debug("Reply: " + reply);
  }
  if (reply == null) {
    replyTimedOut(message.getMessageProperties().getCorrelationId());
  }
  return reply;
}
origin: org.springframework.amqp/spring-rabbit

@Nullable
private Message exchangeMessages(final String exchange, final String routingKey, final Message message,
    final CorrelationData correlationData, Channel channel, final PendingReply pendingReply, String messageTag)
    throws Exception { // NOSONAR TODO: change to IOException, InterruptedException in 2.2.
  Message reply;
  boolean mandatory = isMandatoryFor(message);
  if (mandatory && this.returnCallback == null) {
    message.getMessageProperties().getHeaders().put(RETURN_CORRELATION_KEY, messageTag);
  }
  doSend(channel, exchange, routingKey, message, mandatory, correlationData);
  reply = this.replyTimeout < 0 ? pendingReply.get() : pendingReply.get(this.replyTimeout, TimeUnit.MILLISECONDS);
  if (this.logger.isDebugEnabled()) {
    this.logger.debug("Reply: " + reply);
  }
  if (reply == null) {
    replyTimedOut(message.getMessageProperties().getCorrelationId());
  }
  return reply;
}
origin: eclipse/hawkbit

protected void sendPingReponseToDmfReceiver(final Message ping, final String tenant, final String virtualHost) {
  final Message message = MessageBuilder.withBody(String.valueOf(System.currentTimeMillis()).getBytes())
      .setContentType(MessageProperties.CONTENT_TYPE_TEXT_PLAIN)
      .setCorrelationId(ping.getMessageProperties().getCorrelationId())
      .setHeader(MessageHeaderKey.TYPE, MessageType.PING_RESPONSE).setHeader(MessageHeaderKey.TENANT, tenant)
      .build();
  amqpSenderService.sendMessage(message,
      IpUtil.createAmqpUri(virtualHost, ping.getMessageProperties().getReplyTo()));
}
origin: Bluelock/camel-spring-amqp

public static SpringAMQPMessage setBasicPropertiesToHeaders(SpringAMQPMessage msg, Message amqpMessage) {
  msg.getHeaders().put(MESSAGE_ID, amqpMessage.getMessageProperties().getMessageId());
  byte[] correlationId = amqpMessage.getMessageProperties().getCorrelationId();
  msg.getHeaders().put(CORRELATION_ID, correlationId == null ? null : new String(correlationId));
  msg.getHeaders().put(CONTENT_ENCODING, amqpMessage.getMessageProperties().getContentEncoding());
  msg.getHeaders().put(CONTENT_TYPE, amqpMessage.getMessageProperties().getContentType());
  msg.getHeaders().put(EXPIRATION, amqpMessage.getMessageProperties().getExpiration());
  msg.getHeaders().put(PRIORITY, amqpMessage.getMessageProperties().getPriority());
  msg.getHeaders().put(REPLY_TO, amqpMessage.getMessageProperties().getReplyTo());
  msg.getHeaders().put(DELIVERY_MODE, MessageDeliveryMode.toInt(amqpMessage.getMessageProperties().getDeliveryMode()));
  msg.getHeaders().put(TYPE, amqpMessage.getMessageProperties().getType());
  return msg;
}

origin: com.bluelock/camel-spring-amqp

public static SpringAMQPMessage setBasicPropertiesToHeaders(SpringAMQPMessage msg, Message amqpMessage) {
  msg.getHeaders().put(MESSAGE_ID, amqpMessage.getMessageProperties().getMessageId());
  byte[] correlationId = amqpMessage.getMessageProperties().getCorrelationId();
  msg.getHeaders().put(CORRELATION_ID, correlationId == null ? null : new String(correlationId));
  msg.getHeaders().put(CONTENT_ENCODING, amqpMessage.getMessageProperties().getContentEncoding());
  msg.getHeaders().put(CONTENT_TYPE, amqpMessage.getMessageProperties().getContentType());
  msg.getHeaders().put(EXPIRATION, amqpMessage.getMessageProperties().getExpiration());
  msg.getHeaders().put(PRIORITY, amqpMessage.getMessageProperties().getPriority());
  msg.getHeaders().put(REPLY_TO, amqpMessage.getMessageProperties().getReplyTo());
  msg.getHeaders().put(DELIVERY_MODE, MessageDeliveryMode.toInt(amqpMessage.getMessageProperties().getDeliveryMode()));
  msg.getHeaders().put(TYPE, amqpMessage.getMessageProperties().getType());
  return msg;
}

origin: org.springframework.amqp/spring-rabbit

/**
 * Post-process the given response message before it will be sent.
 * <p>
 * The default implementation sets the response's correlation id to the request message's correlation id, if any;
 * otherwise to the request message id.
 * @param request the original incoming Rabbit message
 * @param response the outgoing Rabbit message about to be sent
 */
protected void postProcessResponse(Message request, Message response) {
  String correlation = request.getMessageProperties().getCorrelationId();
  if (correlation == null) {
    String messageId = request.getMessageProperties().getMessageId();
    if (messageId != null) {
      correlation = messageId;
    }
  }
  response.getMessageProperties().setCorrelationId(correlation);
}
origin: spring-projects/spring-amqp

/**
 * Post-process the given response message before it will be sent.
 * <p>
 * The default implementation sets the response's correlation id to the request message's correlation id, if any;
 * otherwise to the request message id.
 * @param request the original incoming Rabbit message
 * @param response the outgoing Rabbit message about to be sent
 */
protected void postProcessResponse(Message request, Message response) {
  String correlation = request.getMessageProperties().getCorrelationId();
  if (correlation == null) {
    String messageId = request.getMessageProperties().getMessageId();
    if (messageId != null) {
      correlation = messageId;
    }
  }
  response.getMessageProperties().setCorrelationId(correlation);
}
origin: spring-projects/spring-amqp

private void send(Object object, Address replyToAddress, Message requestMessage) {
  Message message = this.messageConverter.toMessage(object, new MessageProperties());
  message.getMessageProperties().setCorrelationId(requestMessage.getMessageProperties().getCorrelationId());
  getAmqpTemplate().send(replyToAddress.getExchangeName(), replyToAddress.getRoutingKey(), message);
}
origin: spring-projects/spring-amqp

@Test
public void testMessageCustomCorrelation() throws Exception {
  Message message = getFooMessage();
  message.getMessageProperties().setCorrelationId("foo");
  ListenableFuture<Message> future = this.asyncTemplate.sendAndReceive(message);
  Message result = checkMessageResult(future, "FOO");
  assertEquals("foo", result.getMessageProperties().getCorrelationId());
}
org.springframework.amqp.coreMessagePropertiesgetCorrelationId

Javadoc

Get the correlation id.

Popular methods of MessageProperties

  • getDeliveryTag
  • <init>
  • setHeader
  • getHeaders
  • setExpiration
  • setContentType
  • getReplyTo
  • getMessageId
  • getReceivedRoutingKey
  • setCorrelationId
  • setDeliveryMode
  • setReplyTo
  • setDeliveryMode,
  • setReplyTo,
  • getConsumerQueue,
  • getReceivedExchange,
  • getContentType,
  • getExpiration,
  • setContentEncoding,
  • setMessageId,
  • getAppId

Popular in Java

  • Parsing JSON documents to java classes using gson
  • getApplicationContext (Context)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • requestLocationUpdates (LocationManager)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • JTable (javax.swing)
  • Option (scala)
  • Top plugins for WebStorm
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now