List of usage examples for com.rabbitmq.client Envelope isRedeliver
public boolean isRedeliver()
From source file:org.apache.axis2.transport.amqp.common.AMQPUtils.java
License:Apache License
/** * Extract transport level headers for AMQP from the given message into a Map * /*from w w w . j av a 2 s.c o m*/ * @param message * the AMQP message * @return a Map of the transport headers * @throws AxisFault */ public static Map<String, Object> getTransportHeaders(AMQPMessage message) throws AxisFault { // create a Map to hold transport headers Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> headers = message.getProperties().getHeaders(); BasicProperties msg_prop = message.getProperties(); Envelope msg_env = message.getEnvelope(); // correlation ID if (msg_prop.getCorrelationId() != null) { map.put(AMQPConstants.AMQP_CORRELATION_ID, msg_prop.getCorrelationId()); } // set the delivery mode as persistent or not map.put(AMQPConstants.AMQP_DELIVERY_MODE, Integer.toString(msg_prop.getDeliveryMode())); // FIXME ? Extract destination from... where? /*// destination name if (message.getAMQPDestination() != null) { Destination dest = message.getAMQPDestination(); map.put(AMQPConstants.AMQP_DESTINATION, dest instanceof Queue ? ((Queue) dest).getQueueName() : ((Topic) dest).getTopicName()); }*/ // expiration map.put(AMQPConstants.AMQP_EXPIRATION, msg_prop.getExpiration()); // if a AMQP message ID is found if (msg_prop.getMessageId() != null) { map.put(AMQPConstants.AMQP_MESSAGE_ID, msg_prop.getMessageId()); } // priority map.put(AMQPConstants.AMQP_PRIORITY, Long.toString(msg_prop.getPriority())); // redelivered map.put(AMQPConstants.AMQP_REDELIVERED, Boolean.toString(msg_env.isRedeliver())); // replyto destination name if (msg_prop.getReplyTo() != null) { Destination dest = DestinationFactory.parseAddress(msg_prop.getReplyTo()); map.put(AMQPConstants.AMQP_REPLY_TO, dest); } // priority map.put(AMQPConstants.AMQP_TIMESTAMP, Long.toString(msg_prop.getTimestamp().getTime())); // message type if (msg_prop.getType() != null) { map.put(AMQPConstants.AMQP_TYPE, msg_prop.getType()); } // any other transport properties / headers Set<String> e = null; e = msg_prop.getHeaders().keySet(); for (String headerName : e) { Object o = headers.get(e); if (o instanceof String) map.put(headerName, (String) o); if (o instanceof Boolean) map.put(headerName, (Boolean) o); if (o instanceof Integer) map.put(headerName, (Integer) o); if (o instanceof Long) map.put(headerName, (Long) o); if (o instanceof Double) map.put(headerName, (Double) o); if (o instanceof Float) map.put(headerName, (Float) o); } return map; }
From source file:org.mule.transport.amqp.AmqpMuleMessageFactory.java
License:Open Source License
private void addEnvelopeProperties(final Map<String, Object> messageProperties, final Envelope envelope) { if (envelope == null) return;//from www.j av a2 s .c o m putIfNonNull(messageProperties, AmqpConstants.DELIVERY_TAG, envelope.getDeliveryTag()); putIfNonNull(messageProperties, AmqpConstants.REDELIVER, envelope.isRedeliver()); putIfNonNull(messageProperties, AmqpConstants.EXCHANGE, envelope.getExchange()); putIfNonNull(messageProperties, AmqpConstants.ROUTING_KEY, envelope.getRoutingKey()); }
From source file:org.mule.transport.amqp.AmqpMuleMessageFactoryTestCase.java
License:Open Source License
public static void checkInboundProperties(final AmqpMessage amqpMessage, final MuleMessage muleMessage) { assertEquals(amqpMessage.getConsumerTag(), muleMessage.getProperty(AmqpConstants.CONSUMER_TAG, PropertyScope.INBOUND)); final Envelope envelope = amqpMessage.getEnvelope(); assertEquals(envelope.getDeliveryTag(), muleMessage.getProperty(AmqpConstants.DELIVERY_TAG, PropertyScope.INBOUND)); assertEquals(envelope.isRedeliver(), muleMessage.getProperty(AmqpConstants.REDELIVER, PropertyScope.INBOUND)); assertEquals(envelope.getExchange(), muleMessage.getProperty(AmqpConstants.EXCHANGE, PropertyScope.INBOUND)); assertEquals(envelope.getRoutingKey(), muleMessage.getProperty(AmqpConstants.ROUTING_KEY, PropertyScope.INBOUND)); final BasicProperties amqpProperties = amqpMessage.getProperties(); assertEquals(amqpProperties.getAppId(), muleMessage.getProperty(AmqpConstants.APP_ID, PropertyScope.INBOUND)); assertEquals(amqpProperties.getContentEncoding(), muleMessage.getProperty(AmqpConstants.CONTENT_ENCODING, PropertyScope.INBOUND)); assertEquals(amqpProperties.getContentType(), muleMessage.getProperty(AmqpConstants.CONTENT_TYPE, PropertyScope.INBOUND)); assertEquals(amqpProperties.getCorrelationId(), muleMessage.getProperty(AmqpConstants.CORRELATION_ID, PropertyScope.INBOUND)); assertEquals(amqpProperties.getCorrelationId(), muleMessage.getCorrelationId()); assertEquals(amqpProperties.getDeliveryMode(), muleMessage.getProperty(AmqpConstants.DELIVERY_MODE, PropertyScope.INBOUND)); assertEquals(amqpProperties.getExpiration(), muleMessage.getProperty(AmqpConstants.EXPIRATION, PropertyScope.INBOUND)); assertEquals(amqpProperties.getMessageId(), muleMessage.getProperty(AmqpConstants.MESSAGE_ID, PropertyScope.INBOUND)); assertEquals(amqpProperties.getMessageId(), muleMessage.getUniqueId()); assertEquals(amqpProperties.getPriority(), muleMessage.getProperty(AmqpConstants.PRIORITY, PropertyScope.INBOUND)); assertEquals(amqpProperties.getReplyTo(), muleMessage.getProperty(AmqpConstants.REPLY_TO, PropertyScope.INBOUND)); assertEquals(amqpProperties.getReplyTo(), muleMessage.getReplyTo()); assertEquals(amqpProperties.getTimestamp(), muleMessage.getProperty(AmqpConstants.TIMESTAMP, PropertyScope.INBOUND)); assertEquals(amqpProperties.getType(), muleMessage.getProperty(AmqpConstants.TYPE, PropertyScope.INBOUND)); assertEquals(amqpProperties.getUserId(), muleMessage.getProperty(AmqpConstants.USER_ID, PropertyScope.INBOUND)); for (final Entry<String, Object> header : amqpProperties.getHeaders().entrySet()) { assertEquals(header.getValue(), muleMessage.getProperty(header.getKey(), PropertyScope.INBOUND)); }/*from w w w.j ava2s .c o m*/ }
From source file:org.mule.transport.amqp.internal.domain.AmqpMuleMessageFactory.java
License:Open Source License
private void addEnvelopeProperties(final Envelope envelope, final Map<String, Object> messageProperties) { if (envelope == null) return;//from w w w. ja va 2 s.com putIfNonNull(AmqpConnector.MESSAGE_PROPERTY_DELIVERY_TAG, envelope.getDeliveryTag(), messageProperties); putIfNonNull(AmqpConnector.MESSAGE_PROPERTY_REDELIVER, envelope.isRedeliver(), messageProperties); putIfNonNull(AmqpConnector.EXCHANGE, envelope.getExchange(), messageProperties); putIfNonNull(AmqpConnector.MESSAGE_PROPERTY_ROUTING_KEY, envelope.getRoutingKey(), messageProperties); }
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)); }//from ww w . j a va 2 s . 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 . co m*/ 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 va 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; }