List of usage examples for com.rabbitmq.client BasicProperties getMessageId
public abstract String getMessageId();
From source file:org.mule.transport.amqp.internal.domain.AmqpMuleMessageFactoryTestCase.java
License:Open Source License
public static void checkInboundProperties(final AmqpMessage amqpMessage, final MuleMessage muleMessage) { assertEquals(amqpMessage.getConsumerTag(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_CONSUMER_TAG, PropertyScope.INBOUND)); final Envelope envelope = amqpMessage.getEnvelope(); assertEquals(envelope.getDeliveryTag(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_DELIVERY_TAG, PropertyScope.INBOUND)); assertEquals(envelope.isRedeliver(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_REDELIVER, PropertyScope.INBOUND)); assertEquals(envelope.getExchange(), muleMessage.getProperty(AmqpConnector.EXCHANGE, PropertyScope.INBOUND)); assertEquals(envelope.getRoutingKey(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_ROUTING_KEY, PropertyScope.INBOUND)); final BasicProperties amqpProperties = amqpMessage.getProperties(); assertEquals(amqpProperties.getAppId(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_APP_ID, PropertyScope.INBOUND)); assertEquals(amqpProperties.getContentEncoding(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_CONTENT_ENCODING, PropertyScope.INBOUND)); assertEquals(amqpProperties.getContentType(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_CONTENT_TYPE, PropertyScope.INBOUND)); assertEquals(amqpProperties.getClusterId(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_CLUSTER_ID, PropertyScope.INBOUND)); assertEquals(amqpProperties.getCorrelationId(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_CORRELATION_ID, PropertyScope.INBOUND)); assertEquals(amqpProperties.getCorrelationId(), muleMessage.getCorrelationId()); assertEquals(amqpProperties.getDeliveryMode(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_DELIVERY_MODE, PropertyScope.INBOUND)); assertEquals(amqpProperties.getExpiration(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_EXPIRATION, PropertyScope.INBOUND)); assertEquals(amqpProperties.getMessageId(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_MESSAGE_ID, PropertyScope.INBOUND)); assertEquals(amqpProperties.getMessageId(), muleMessage.getUniqueId()); assertEquals(amqpProperties.getPriority(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_PRIORITY, PropertyScope.INBOUND)); assertEquals(amqpProperties.getReplyTo(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_REPLY_TO, PropertyScope.INBOUND)); assertEquals(amqpProperties.getReplyTo(), muleMessage.getReplyTo()); assertEquals(amqpProperties.getTimestamp(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_TIMESTAMP, PropertyScope.INBOUND)); assertEquals(amqpProperties.getType(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_TYPE, PropertyScope.INBOUND)); assertEquals(amqpProperties.getUserId(), muleMessage.getProperty(AmqpConnector.MESSAGE_PROPERTY_USER_ID, PropertyScope.INBOUND)); for (final Entry<String, Object> header : amqpProperties.getHeaders().entrySet()) { assertEquals(header.getValue(), muleMessage.getProperty(header.getKey(), PropertyScope.INBOUND)); }/*w w w . j a v a2s. c o m*/ }
From source file:org.springframework.amqp.rabbit.support.DefaultMessagePropertiesConverter.java
License:Apache License
public MessageProperties toMessageProperties(final BasicProperties source, final Envelope envelope, final String charset) { MessageProperties target = new MessageProperties(); Map<String, Object> headers = source.getHeaders(); if (!CollectionUtils.isEmpty(headers)) { for (Map.Entry<String, Object> entry : headers.entrySet()) { Object value = entry.getValue(); if (value instanceof LongString) { value = this.convertLongString((LongString) value, charset); }//from www . j a v a 2 s . com target.setHeader(entry.getKey(), value); } } target.setTimestamp(source.getTimestamp()); target.setMessageId(source.getMessageId()); target.setUserId(source.getUserId()); target.setAppId(source.getAppId()); target.setClusterId(source.getClusterId()); target.setType(source.getType()); Integer deliverMode = source.getDeliveryMode(); if (deliverMode != null) { target.setDeliveryMode(MessageDeliveryMode.fromInt(deliverMode)); } target.setExpiration(source.getExpiration()); target.setPriority(source.getPriority()); target.setContentType(source.getContentType()); target.setContentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (correlationId != null) { try { target.setCorrelationId(source.getCorrelationId().getBytes(charset)); } catch (UnsupportedEncodingException ex) { throw new AmqpUnsupportedEncodingException(ex); } } String replyTo = source.getReplyTo(); if (replyTo != null) { target.setReplyTo(replyTo); } if (envelope != null) { target.setReceivedExchange(envelope.getExchange()); target.setReceivedRoutingKey(envelope.getRoutingKey()); target.setRedelivered(envelope.isRedeliver()); target.setDeliveryTag(envelope.getDeliveryTag()); } return target; }
From source file:org.springframework.amqp.rabbit.support.RabbitUtils.java
License:Apache License
public static MessageProperties createMessageProperties(final BasicProperties source, final Envelope envelope, final String charset) { MessageProperties target = new MessageProperties(); Map<String, Object> headers = source.getHeaders(); if (!CollectionUtils.isEmpty(headers)) { for (Map.Entry<String, Object> entry : headers.entrySet()) { target.setHeader(entry.getKey(), entry.getValue()); }//from w ww.j a v a 2 s . c o m } target.setTimestamp(source.getTimestamp()); target.setMessageId(source.getMessageId()); target.setUserId(source.getUserId()); target.setAppId(source.getAppId()); target.setClusterId(source.getClusterId()); target.setType(source.getType()); Integer deliverMode = source.getDeliveryMode(); if (deliverMode != null) { target.setDeliveryMode(MessageDeliveryMode.fromInt(deliverMode)); } target.setExpiration(source.getExpiration()); target.setPriority(source.getPriority()); target.setContentType(source.getContentType()); target.setContentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (correlationId != null) { try { target.setCorrelationId(source.getCorrelationId().getBytes(charset)); } catch (UnsupportedEncodingException ex) { throw new AmqpUnsupportedEncodingException(ex); } } String replyTo = source.getReplyTo(); if (replyTo != null) { target.setReplyTo(new Address(replyTo)); } if (envelope != null) { target.setReceivedExchange(envelope.getExchange()); target.setReceivedRoutingKey(envelope.getRoutingKey()); target.setRedelivered(envelope.isRedeliver()); target.setDeliveryTag(envelope.getDeliveryTag()); } // TODO: what about messageCount? return target; }