当前位置: 首页>>代码示例>>Java>>正文


Java MessageBuilder.fromMessage方法代码示例

本文整理汇总了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();
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:17,代码来源:TraceChannelInterceptor.java

示例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);
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:19,代码来源:MessagingSpanInjectorTests.java

示例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();
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:14,代码来源:MessagingMessageConverter.java

示例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);
}
 
开发者ID:reshmik,项目名称:Zipkin,代码行数:11,代码来源:MessagingSpanInjectorTests.java


注:本文中的org.springframework.messaging.support.MessageBuilder.fromMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。