byte[] response = null; String corrId = UUID.randomUUID().toString(); BasicProperties props = new BasicProperties.Builder().correlationId(corrId).replyTo(replyQueue).build(); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DeflaterOutputStream defos = new DeflaterOutputStream(baos);
propertiesBuilder.replyTo(JsonFormat.printToString(senderServiceRef));
properties.replyTo(replyTo.toString());
propsBuilder.replyTo(replyTo);
.correlationId(corrId) .contentType("text/plain") .replyTo(replyQueueName) .build();
propsBuilder.replyTo(replyTo);
subject, new AMQP.BasicProperties.Builder() .replyTo(replyQueue) .correlationId(corrId) .headers(sendheaders)
BasicProperties props = new BasicProperties().builder().replyTo(Address.AMQ_RABBITMQ_REPLY_TO).build(); channel1.getChannel().basicPublish("", TEST_RELEASE_CONSUMER_Q, props, "foo".getBytes()); Channel replyChannel = connectionFactory.createConnection().createChannel(false);
builder.replyTo(message.getReplyTo()); builder.correlationId(message.getCorrelationId()); builder.contentEncoding(message.getContentEncoding());
@Override public Event request(Event request, int duration, TimeUnit timeUnit) throws InterruptedException { requireNonNull(request, "event must be defined."); connect(); EventBuilder eventBuilder = new EventBuilder(request); String correlationId = UUID.randomUUID().toString(); eventBuilder .setRequestReplyType(Event.RequestReplyType.REQUEST) .setReplyTo(localQueueName) .setCorrelationId(correlationId); ReplyEvent replyEvent = new ReplyEvent(correlationId); addEventRequest(replyEvent); String message = Event.convertToJson(eventBuilder.build()); AMQP.BasicProperties props = new AMQP.BasicProperties .Builder() .replyTo(localQueueName) .correlationId(correlationId) .deliveryMode(MessageProperties.PERSISTENT_TEXT_PLAIN.getDeliveryMode()) .build(); try { producer.publish(rabbitMqConfig.businessExchangeName(), message, null, props); } catch (Exception e) { LOGGER.error("Unable to publish request with correlationId {}.", correlationId, e); } return replyEvent.getReply(duration, timeUnit); }
@Override public BasicProperties fromMessageProperties(final MessageProperties source, final String charset) { BasicProperties.Builder target = new BasicProperties.Builder(); target.headers(this.convertHeadersIfNecessary(source.getHeaders())) .timestamp(source.getTimestamp()) .messageId(source.getMessageId()) .userId(source.getUserId()) .appId(source.getAppId()) .clusterId(source.getClusterId()) .type(source.getType()); MessageDeliveryMode deliveryMode = source.getDeliveryMode(); if (deliveryMode != null) { target.deliveryMode(MessageDeliveryMode.toInt(deliveryMode)); } target.expiration(source.getExpiration()) .priority(source.getPriority()) .contentType(source.getContentType()) .contentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (StringUtils.hasText(correlationId)) { target.correlationId(correlationId); } String replyTo = source.getReplyTo(); if (replyTo != null) { target.replyTo(replyTo); } return target.build(); }
builder.priority(0); builder.replyTo(toStr(message.properties().get(ReplyTo.name())));
@Override public BasicProperties fromMessageProperties(final MessageProperties source, final String charset) { BasicProperties.Builder target = new BasicProperties.Builder(); target.headers(this.convertHeadersIfNecessary(source.getHeaders())) .timestamp(source.getTimestamp()) .messageId(source.getMessageId()) .userId(source.getUserId()) .appId(source.getAppId()) .clusterId(source.getClusterId()) .type(source.getType()); MessageDeliveryMode deliveryMode = source.getDeliveryMode(); if (deliveryMode != null) { target.deliveryMode(MessageDeliveryMode.toInt(deliveryMode)); } target.expiration(source.getExpiration()) .priority(source.getPriority()) .contentType(source.getContentType()) .contentEncoding(source.getContentEncoding()); String correlationId = source.getCorrelationId(); if (StringUtils.hasText(correlationId)) { target.correlationId(correlationId); } String replyTo = source.getReplyTo(); if (replyTo != null) { target.replyTo(replyTo); } return target.build(); }
/** * Build and populate the AMQP.BasicProperties using the RabbitMQMessage * * @param message the RabbitMQMessage to be used to get the properties * @return AMQP.BasicProperties object */ private AMQP.BasicProperties.Builder buildBasicProperties(RabbitMQMessage message) { AMQP.BasicProperties.Builder builder = new AMQP.BasicProperties().builder(); builder.messageId(message.getMessageId()); builder.contentType(message.getContentType()); builder.replyTo(message.getReplyTo()); builder.correlationId(message.getCorrelationId()); builder.contentEncoding(message.getContentEncoding()); Map<String, Object> headers = message.getHeaders(); if (message.getSoapAction() != null) { headers.put(RabbitMQConstants.SOAP_ACTION, message.getSoapAction()); } builder.headers(headers); return builder; }
/** * Set AMQP reply-to property to direct-reply-to if necessary. * <p> * Set the <code>reply-to</code> property to <code>amq.rabbitmq.reply-to</code> * if the <code>JMSReplyTo</code> header is set to a destination with that * name. * <p> * For outbound RPC request. * * @param builder * @param msg * @throws JMSException * @since 1.11.0 */ private static void maybeSetReplyToPropertyToDirectReplyTo(AMQP.BasicProperties.Builder builder, RMQMessage msg) throws JMSException { if (msg.getJMSReplyTo() != null && msg.getJMSReplyTo() instanceof RMQDestination) { RMQDestination replyTo = (RMQDestination) msg.getJMSReplyTo(); if (DIRECT_REPLY_TO.equals(replyTo.getDestinationName())) { builder.replyTo(DIRECT_REPLY_TO); } } }
public static AMQP.BasicProperties box(Message msg) { AMQP.BasicProperties.Builder builder = new AMQP.BasicProperties.Builder(); return builder.messageId(String.valueOf(msg.getMessageId())) .appId(msg.getAppId()) .clusterId(msg.getClusterId()) .contentEncoding(msg.getContentEncoding()) .contentType(msg.getContentType()) .correlationId(msg.getCorrelationId()) .deliveryMode((int) msg.getDeliveryMode()) .expiration(msg.getExpiration()) .headers(msg.getHeaders()) .priority((int) msg.getPriority()) .replyTo(msg.getReplyTo()) .timestamp(new Date(msg.getTimestamp())) .type(msg.getType()) .userId(msg.getUserId()) .build(); }
public static AMQP.BasicProperties fromJson( JsonObject json ) { if ( json == null ) { return new AMQP.BasicProperties(); } return new AMQP.BasicProperties.Builder() .contentType(json.getString("contentType")) .contentEncoding(json.getString("contentEncoding")) .headers(asMap(json.getJsonObject("headers"))) .deliveryMode(json.getInteger("deliveryMode")) .priority(json.getInteger("priority")) .correlationId(json.getString("correlationId")) .replyTo(json.getString("replyTo")) .expiration(json.getString("expiration")) .messageId(json.getString("messageId")) .timestamp(parseDate(json.getString("timestamp"))) .type(json.getString("type")) .userId(json.getString("userId")) .appId(json.getString("appId")) .clusterId(json.getString("clusterId")).build(); }
public void setReplyTo(String replyTo) { message.getProperties().replyTo(replyTo); }
public BasicProperties toBasicProperties() { BasicProperties.Builder builder = new BasicProperties.Builder(); return builder.appId(appId).clusterId(clusterId).contentEncoding(contentEncoding).contentType(contentType).correlationId(correlationId) .deliveryMode(deliveryMode).expiration(expiration).headers(headers).messageId(messageId).priority(priority).replyTo(replyTo) .timestamp(timestamp).type(type).userId(userId).build(); }