本文整理汇总了Java中org.springframework.messaging.support.MessageBuilder.fromMessage方法的典型用法代码示例。如果您正苦于以下问题:Java MessageBuilder.fromMessage方法的具体用法?Java MessageBuilder.fromMessage怎么用?Java MessageBuilder.fromMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.messaging.support.MessageBuilder
的用法示例。
在下文中一共展示了MessageBuilder.fromMessage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: preSend
import org.springframework.messaging.support.MessageBuilder; //导入方法依赖的package包/类
@Override
public Message<?> preSend(Message<?> message, MessageChannel channel) {
Span parentSpan = getTracer().isTracing() ? getTracer().getCurrentSpan()
: buildSpan(message);
String name = getMessageChannelName(channel);
Span span = startSpan(parentSpan, name, message);
MessageBuilder<?> messageBuilder = MessageBuilder.fromMessage(message);
if (message.getHeaders().containsKey(MESSAGE_SENT_FROM_CLIENT)) {
span.logEvent(Span.SERVER_RECV);
} else {
span.logEvent(Span.CLIENT_SEND);
messageBuilder.setHeader(MESSAGE_SENT_FROM_CLIENT, true);
}
getSpanInjector().inject(span, messageBuilder);
return messageBuilder.build();
}
示例2: nativeSpanHeadersAdded
import org.springframework.messaging.support.MessageBuilder; //导入方法依赖的package包/类
@Test
public void nativeSpanHeadersAdded() {
Span span = Span.builder().name("http:foo").spanId(1L).traceId(2L).build();
MessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
Message<String> messageToBuild = MessageBuilder.createMessage("Hello World",
accessor.getMessageHeaders());
MessageBuilder<String> messageBuilder = MessageBuilder
.fromMessage(messageToBuild);
this.messagingSpanInjector.inject(span, messageBuilder);
Message<String> message = messageBuilder.build();
assertThat(message.getHeaders())
.containsKey(NativeMessageHeaderAccessor.NATIVE_HEADERS);
MessageHeaderAccessor natives = NativeMessageHeaderAccessor
.getMutableAccessor(message);
assertThat(natives.getMessageHeaders()).containsKey(Span.SPAN_ID_NAME);
}
示例3: fromMessage
import org.springframework.messaging.support.MessageBuilder; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public Object fromMessage(javax.jms.Message message) throws JMSException, MessageConversionException {
if (message == null) {
return null;
}
Map<String, Object> mappedHeaders = this.headerMapper.toHeaders(message);
Object convertedObject = extractPayload(message);
MessageBuilder<Object> builder = (convertedObject instanceof org.springframework.messaging.Message) ?
MessageBuilder.fromMessage((org.springframework.messaging.Message<Object>) convertedObject) :
MessageBuilder.withPayload(convertedObject);
return builder.copyHeadersIfAbsent(mappedHeaders).build();
}
示例4: spanHeadersAdded
import org.springframework.messaging.support.MessageBuilder; //导入方法依赖的package包/类
@Test
public void spanHeadersAdded() {
Span span = Span.builder().name("http:foo").spanId(1L).traceId(2L).build();
Message<?> message = new GenericMessage<>("Hello World");
MessageBuilder<?> messageBuilder = MessageBuilder.fromMessage(message);
this.messagingSpanInjector.inject(span, messageBuilder);
assertThat(messageBuilder.build().getHeaders()).containsKey(Span.SPAN_ID_NAME);
}