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();
 }
コード例 #2
0
 private BasicProperties convertProperties(MessageProperties properties) {
   if (properties == null) {
     return null;
   }
   // TODO: Figure out a better way to share this data and not duplicate
   BasicProperties.Builder props = new BasicProperties.Builder();
   props.appId(properties.getAppId());
   // props.setClusterId(?);
   props.contentEncoding(properties.getContentEncoding());
   props.contentType(properties.getContentType());
   props.correlationId(properties.getCorrelationId());
   if (properties.getDeliveryMode() != null) {
     props.deliveryMode(properties.getDeliveryMode().getMode());
   }
   props.expiration(properties.getExpiration());
   props.headers(properties.getHeaders());
   props.messageId(properties.getMessageId());
   props.priority(properties.getPriority());
   props.replyTo(properties.getReplyTo());
   props.timestamp(properties.getTimestamp());
   props.type(properties.getType());
   props.userId(properties.getUserId());
   return props.build();
 }