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; }
byte[] pngBys = draw(conf, width, height, profile, skin, params); if (Visage.trace) Visage.log.finest("Got png bytes"); parent.channel.basicPublish("", props.getReplyTo(), replyProps, buildResponse(0, pngBys)); if (Visage.trace) Visage.log.finest("Published response"); parent.channel.basicAck(delivery.getEnvelope().getDeliveryTag(), false);
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; }
replyChannel.basicPublish("", request.getProps().getReplyTo(), new BasicProperties(), "bar".getBytes()); replyChannel.close(); assertTrue(latch.await(10, TimeUnit.SECONDS));
doAnswer(invocation -> { BasicProperties basicProps = invocation.getArgument(3); replyTo.set(basicProps.getReplyTo()); if (standardHeader) { correlationId.set(basicProps.getCorrelationId());
doAnswer(invocation -> { BasicProperties basicProps = invocation.getArgument(3); nestedReplyTo.add(basicProps.getReplyTo()); nestedCorrelation.add(basicProps.getCorrelationId()); MessageProperties springProps = new DefaultMessagePropertiesConverter()
target.setCorrelationId(source.getCorrelationId()); String replyTo = source.getReplyTo(); if (replyTo != null) { target.setReplyTo(replyTo);
doAnswer(invocation -> { BasicProperties basicProps = invocation.getArgument(3); nestedReplyTo.add(basicProps.getReplyTo()); nestedCorrelation.add(basicProps.getCorrelationId()); MessageProperties springProps = new DefaultMessagePropertiesConverter()
exchange.getIn().setHeader(RabbitMQConstants.PRIORITY, properties.getPriority()); if (properties.getReplyTo() != null) { exchange.getIn().setHeader(RabbitMQConstants.REPLY_TO, properties.getReplyTo());
doAnswer(invocation -> { BasicProperties basicProps = invocation.getArgument(3); replyTo.set(basicProps.getReplyTo()); correlationId.set((String) basicProps.getHeaders().get(CORRELATION_HEADER));
/** * 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() ); }
protected void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties, byte[] body) throws IOException { String correlationId = properties.getCorrelationId(); String replyTo = properties.getReplyTo(); if (correlationId != null && replyTo != null) { // decode the event T event = this.transcoder.decodeFromBytes(body); // handle the event R response = this.handler.handleDevliery(event); // ack the event this.channel.basicAck(envelope.getDeliveryTag(), false); // send the response if (response != null) { this.channel.basicPublish( "", replyTo, new BasicProperties("application/json", null, null, 1, null, correlationId, null, null, null, null, null, null, null, null), this.responseTranscoder.encodeAsBytes(response) ); } } else { logger.warn("Ignoring request without correlationId or replyTo"); } }
doAnswer(invocation -> { BasicProperties basicProps = invocation.getArgument(3); replyTo.set(basicProps.getReplyTo()); correlationId.set(basicProps.getCorrelationId()); MessageProperties springProps = new DefaultMessagePropertiesConverter()
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(); }
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()); }
private static RMQMessage convertAmqpMessage(RMQSession session, RMQDestination dest, GetResponse response, ReceivingContextConsumer receivingContextConsumer) throws JMSException { try { BasicProperties props = response.getProps(); RMQMessage message = RMQMessage.isAmqpTextMessage(props.getHeaders()) ? new RMQTextMessage() : new RMQBytesMessage(); message = RMQMessage.fromAmqpMessage(response.getBody(), message); // Deserialize the message payload from the byte[] body message.setSession(session); // Insert session in received message for Message.acknowledge message.setJMSRedelivered(response.getEnvelope().isRedeliver()); // Set the redelivered flag message.setRabbitDeliveryTag(response.getEnvelope().getDeliveryTag()); // Insert delivery tag in received message for Message.acknowledge message.setJMSDestination(dest); // We cannot know the original destination, so set local one message.setJMSPropertiesFromAmqpProperties(props); message.setReadonly(true); // Set readOnly - mandatory for received messages maybeSetupDirectReplyTo(message, response.getProps().getReplyTo()); receivingContextConsumer.accept(new ReceivingContext(message)); return message; } catch (IOException x) { throw new RMQJMSException(x); } }
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; }
static RMQMessage convertJmsMessage(RMQSession session, GetResponse response, ReceivingContextConsumer receivingContextConsumer) throws JMSException { // Deserialize the message payload from the byte[] body RMQMessage message = fromMessage(response.getBody(), session.getTrustedPackages()); message.setSession(session); // Insert session in received message for Message.acknowledge message.setJMSRedelivered(response.getEnvelope().isRedeliver()); // Set the redelivered flag message.setRabbitDeliveryTag(response.getEnvelope().getDeliveryTag()); // Insert delivery tag in received message for Message.acknowledge // message.setJMSDestination(dest); // DO NOT set the destination bug#57214768 // JMSProperties already set message.setReadonly(true); // Set readOnly - mandatory for received messages maybeSetupDirectReplyTo(message, response.getProps().getReplyTo()); receivingContextConsumer.accept(new ReceivingContext(message)); return message; }
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; }