當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。