updateBuilderFromAttribute(flowFile, "expiration", builder::expiration); updateBuilderFromAttribute(flowFile, "messageId", builder::messageId); updateBuilderFromAttribute(flowFile, "timestamp", ts -> builder.timestamp(new Date(Long.parseLong(ts)))); updateBuilderFromAttribute(flowFile, "type", builder::type); updateBuilderFromAttribute(flowFile, "userId", builder::userId);
@Override public CompletableFuture<Void> sendAsync(Optional<String> key, byte[] payload) { BasicProperties.Builder builder = defaultProperties.builder().timestamp(new Date()); if (messagePersistence) { builder.deliveryMode(2); } BasicProperties props = builder.build(); CompletableFuture<Void> future = new CompletableFuture<>(); long msgId = channel.getNextPublishSeqNo(); ackSet.add(msgId); futureConcurrentHashMap.putIfAbsent(msgId, future); try { channel.basicPublish(exchange, key.orElse(""), props, payload); } catch (Exception e) { future.completeExceptionally(e); } return future; }
appId(appId). type(type). timestamp(timestamp). headers(map). build();
properties.timestamp(convertTimestamp(timestamp));
propsBuilder.timestamp(timestamp);
propsBuilder.timestamp(timestamp);
builder.timestamp(new SimpleDateFormat("dd/MM/yyyy").parse(message.getTimestamp())); } catch (ParseException e) { log.warn(message.getTimestamp() + " Can not be parsed as a Date");
propertiesBuilder.contentEncoding("gzip"); propertiesBuilder.messageId(messageid); propertiesBuilder.timestamp(new Date(message.getJavaTimestamp())); BasicProperties properties = propertiesBuilder.build();
propertiesBuilder.contentEncoding("gzip"); propertiesBuilder.messageId(messageid); propertiesBuilder.timestamp(new Date(message.getJavaTimestamp())); BasicProperties properties = propertiesBuilder.build();
builder.timestamp(toDate(message.properties().get(Timestamp.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(); }
@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(); }
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(); }
/** * Publishes a message via the given channel while using the specified delivery options. * * @param channel The channel used to publish the message on * @param deliveryOptions The delivery options to use * @throws IOException */ public void publish(Channel channel, DeliveryOptions deliveryOptions) throws IOException { // Assure to have a timestamp if (basicProperties.getTimestamp() == null) { basicProperties.builder().timestamp(new Date()); } boolean mandatory = deliveryOptions == DeliveryOptions.MANDATORY; boolean immediate = deliveryOptions == DeliveryOptions.IMMEDIATE; LOGGER.info("Publishing message to exchange '{}' with routing key '{}' (deliveryOptions: {}, persistent: {})", new Object[] { exchange, routingKey, deliveryOptions, basicProperties.getDeliveryMode() == 2 }); channel.basicPublish(exchange, routingKey, mandatory, immediate, basicProperties, bodyContent); LOGGER.info("Successfully published message to exchange '{}' with routing key '{}'", exchange, routingKey); }
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 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(); }