private Map<String, String> buildAttributes(final BasicProperties properties) { final Map<String, String> attributes = new HashMap<>(); addAttribute(attributes, ATTRIBUTES_PREFIX + "appId", properties.getAppId()); addAttribute(attributes, ATTRIBUTES_PREFIX + "contentEncoding", properties.getContentEncoding()); addAttribute(attributes, ATTRIBUTES_PREFIX + "contentType", properties.getContentType()); addAttribute(attributes, ATTRIBUTES_PREFIX + "headers", properties.getHeaders()); addAttribute(attributes, ATTRIBUTES_PREFIX + "deliveryMode", properties.getDeliveryMode()); addAttribute(attributes, ATTRIBUTES_PREFIX + "priority", properties.getPriority()); addAttribute(attributes, ATTRIBUTES_PREFIX + "correlationId", properties.getCorrelationId()); addAttribute(attributes, ATTRIBUTES_PREFIX + "replyTo", properties.getReplyTo()); addAttribute(attributes, ATTRIBUTES_PREFIX + "expiration", properties.getExpiration()); addAttribute(attributes, ATTRIBUTES_PREFIX + "messageId", properties.getMessageId()); addAttribute(attributes, ATTRIBUTES_PREFIX + "timestamp", properties.getTimestamp() == null ? null : properties.getTimestamp().getTime()); addAttribute(attributes, ATTRIBUTES_PREFIX + "type", properties.getType()); addAttribute(attributes, ATTRIBUTES_PREFIX + "userId", properties.getUserId()); addAttribute(attributes, ATTRIBUTES_PREFIX + "clusterId", properties.getClusterId()); return attributes; }
String contentEncoding = props.getContentEncoding(); String contentType = props.getContentType(); String correlationId = props.getCorrelationId();
private static Map<String, Object> properties(final BasicProperties properties) { final HashMap<String, Object> result = new HashMap<>(); result.put(AppId.name(), properties.getAppId()); result.put(ContentEncoding.name(), properties.getContentEncoding()); result.put(ContentType.name(), properties.getContentType()); result.put(CorrelationId.name(), properties.getCorrelationId()); result.put(DeliveryMode.name(), properties.getDeliveryMode()); result.put(Expiration.name(), properties.getExpiration()); result.put(Priority.name(), properties.getPriority()); result.put(ReplyTo.name(), properties.getReplyTo()); result.put(Timestamp.name(), toLocalDateTime(properties.getTimestamp())); result.put(Type.name(), properties.getType()); result.put(UserId.name(), properties.getUserId()); return result; }
message.setContentEncoding(properties.getContentEncoding()); message.setCorrelationId(properties.getCorrelationId());
message.setContentEncoding(properties.getContentEncoding()); message.setCorrelationId(properties.getCorrelationId()); if (headers != null) {
target.setPriority(source.getPriority()); target.setContentType(source.getContentType()); target.setContentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (StringUtils.hasText(correlationId)) {
exchange.getIn().setHeader(RabbitMQConstants.CLUSTERID, properties.getClusterId()); if (properties.getContentEncoding() != null) { exchange.getIn().setHeader(RabbitMQConstants.CONTENT_ENCODING, properties.getContentEncoding());
target.setPriority(source.getPriority()); target.setContentType(source.getContentType()); target.setContentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (StringUtils.hasText(correlationId)) {
/** * Construct a new message * * @param consumerTag the <i>consumer tag</i> associated with the consumer * @param envelope packaging data for the message * @param properties content header data for the message * @param body the message body (opaque, client-specific byte array) */ RabbitMQMessageImpl(byte[] body, String consumerTag, com.rabbitmq.client.Envelope envelope, AMQP.BasicProperties properties) { this.body = Buffer.buffer(body); this.consumerTag = consumerTag; this.envelope = new EnvelopeImpl(envelope.getDeliveryTag(), envelope.isRedeliver(), envelope.getExchange(), envelope.getRoutingKey()); this.properties = new BasicPropertiesImpl( properties.getContentType(), properties.getContentEncoding(), properties.getHeaders(), properties.getDeliveryMode(), properties.getPriority(), properties.getCorrelationId(), properties.getReplyTo(), properties.getExpiration(), properties.getMessageId(), properties.getTimestamp(), properties.getType(), properties.getUserId(), properties.getAppId(), properties.getClusterId() ); }
public static Object parse(AMQP.BasicProperties properties, byte[] bytes) throws UnsupportedEncodingException { if (bytes == null) return null; if (properties != null) { String encoding = properties.getContentEncoding(); String ct = properties.getContentType(); if (ct == null) { return decode(encoding, bytes); } switch (ct) { case "application/json": return new JsonObject(decode(encoding, bytes)); case "application/octet-stream": return bytes; case "text/plain": default: return decode(encoding, bytes); } } else { return decode(null, bytes); } }
public static JsonObject toJson( AMQP.BasicProperties properties ) { if ( properties == null ) { return null; } JsonObject json = new JsonObject(); put( "contentType", properties.getContentType(), json ); put( "contentEncoding", properties.getContentEncoding(), json ); put( "headers", convertMapLongStringToString( properties.getHeaders() ), json ); put( "deliveryMode", properties.getDeliveryMode(), json ); put( "priority", properties.getPriority(), json ); put( "correlationId", properties.getCorrelationId(), json ); put( "replyTo", properties.getReplyTo(), json ); put( "expiration", properties.getExpiration(), json ); put( "messageId", properties.getMessageId(), json ); put( "timestamp", properties.getTimestamp(), json ); put( "type", properties.getType(), json ); put( "userId", properties.getUserId(), json ); put( "appId", properties.getAppId(), json ); put( "clusterId", properties.getClusterId(), json ); return json; }
private DeliveredMessage(QueueingConsumer.Delivery delivery) { super(delivery.getBody()); redelivery = delivery.getEnvelope().isRedeliver(); deliveryTag = delivery.getEnvelope().getDeliveryTag(); routingKey = delivery.getEnvelope().getRoutingKey(); exchange = delivery.getEnvelope().getExchange(); className = delivery.getProperties().getClassName(); clusterId = delivery.getProperties().getClusterId(); contentEncoding = delivery.getProperties().getContentEncoding(); contentType = delivery.getProperties().getContentType(); correlationId = delivery.getProperties().getCorrelationId(); deliveryMode = delivery.getProperties().getDeliveryMode(); expiration = delivery.getProperties().getExpiration(); headers = delivery.getProperties().getHeaders(); messageId = delivery.getProperties().getMessageId(); priority = delivery.getProperties().getPriority(); replyTo = delivery.getProperties().getReplyTo(); timestamp = delivery.getProperties().getTimestamp(); type = delivery.getProperties().getType(); userId = delivery.getProperties().getUserId(); }
/** * Extracts the message body's charset encoding * by looking it up in the message properties if * given there and choosing the default charset (UTF-8) * otherwise. * * @return The message body's charset encoding */ public Charset readCharset() { BasicProperties basicProperties = message.getBasicProperties(); if (basicProperties == null) { return Message.DEFAULT_MESSAGE_CHARSET; } String contentCharset = basicProperties.getContentEncoding(); if (contentCharset == null) { return Message.DEFAULT_MESSAGE_CHARSET; } return Charset.forName(contentCharset); }
protected void applyPropertiesData(Operation op, BasicProperties props) { OperationMap map = op.createMap("props"); map.putAnyNonEmpty("Type", props.getType()); map.putAnyNonEmpty("App Id", props.getAppId()); map.putAnyNonEmpty("User Id", props.getUserId()); map.put("Class Id", props.getClassId()); map.putAnyNonEmpty("Reply To", props.getReplyTo()); map.putAnyNonEmpty("Priority", props.getPriority()); map.putAnyNonEmpty("Class Name", props.getClassName()); map.putAnyNonEmpty("Timestamp", props.getTimestamp()); map.putAnyNonEmpty("Message Id", props.getMessageId()); map.putAnyNonEmpty("Expiration", props.getExpiration()); map.putAnyNonEmpty("Content Type", props.getContentType()); map.putAnyNonEmpty("Delivery Mode", props.getDeliveryMode()); map.putAnyNonEmpty("Correlation Id", props.getCorrelationId()); map.putAnyNonEmpty("Content Encoding", props.getContentEncoding()); updateHeadersMap(op, props.getHeaders()); }
public static Message unbox(AMQP.BasicProperties properties, Message msg) { //common properties msg.setCorrelationId(properties.getCorrelationId()); msg.setHeaders(properties.getHeaders()); msg.setTimestamp(properties.getTimestamp().getTime()); String msgIdStr = properties.getMessageId(); if (msgIdStr != null && !msgIdStr.isEmpty()) msg.setMessageId(Long.parseLong(msgIdStr)); else logger.error("[unbox] illegal message id (can not be null) "); msg.setContentEncoding(properties.getContentEncoding()); msg.setContentType(properties.getContentType()); msg.setAppId(properties.getAppId()); msg.setReplyTo(properties.getReplyTo()); return msg; }
public static MessageProperties valueOf(BasicProperties bp) { MessageProperties mp = new MessageProperties(); mp.setAppId(bp.getAppId()); mp.setClusterId(bp.getClusterId()); mp.setContentEncoding(bp.getContentEncoding()); mp.setContentType(bp.getContentType()); mp.setCorrelationId(bp.getCorrelationId()); mp.setDeliveryMode(bp.getDeliveryMode()); mp.setExpiration(bp.getExpiration()); mp.setHeaders(bp.getHeaders()); mp.setMessageId(bp.getMessageId()); mp.setPriority(bp.getPriority()); mp.setReplyTo(bp.getReplyTo()); mp.setTimestamp(bp.getTimestamp()); mp.setType(bp.getType()); mp.setUserId(bp.getUserId()); return mp; }