當前位置: 首頁>>代碼示例>>Java>>正文


Java MessageBuilder.setHeader方法代碼示例

本文整理匯總了Java中org.springframework.messaging.support.MessageBuilder.setHeader方法的典型用法代碼示例。如果您正苦於以下問題:Java MessageBuilder.setHeader方法的具體用法?Java MessageBuilder.setHeader怎麽用?Java MessageBuilder.setHeader使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.springframework.messaging.support.MessageBuilder的用法示例。


在下文中一共展示了MessageBuilder.setHeader方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMqttQualityOfServiceHeader

import org.springframework.messaging.support.MessageBuilder; //導入方法依賴的package包/類
@Test
public void testMqttQualityOfServiceHeader()
{
    Assert.assertEquals(MqttQualityOfService.QOS_2,
        MqttHeaderHelper.getMqttQualityOfServiceHeaderValue(null,
            MqttQualityOfService.QOS_2.getLevelIdentifier()));
    MessageBuilder<String> builder = MessageBuilder.withPayload("See QoS header");
    Assert.assertEquals(MqttQualityOfService.QOS_2,
        MqttHeaderHelper.getMqttQualityOfServiceHeaderValue(builder.build(),
            MqttQualityOfService.QOS_2.getLevelIdentifier()));
    builder.setHeader(MqttHeaderHelper.QOS, "blah!");
    Assert.assertEquals(MqttQualityOfService.QOS_2,
        MqttHeaderHelper.getMqttQualityOfServiceHeaderValue(builder.build(),
            MqttQualityOfService.QOS_2.getLevelIdentifier()));
    builder.setHeader(MqttHeaderHelper.QOS, MqttQualityOfService.QOS_1.getLevelIdentifier());
    Assert.assertEquals(MqttQualityOfService.QOS_1,
        MqttHeaderHelper.getMqttQualityOfServiceHeaderValue(builder.build(),
            MqttQualityOfService.QOS_2.getLevelIdentifier()));
}
 
開發者ID:christophersmith,項目名稱:summer-mqtt,代碼行數:20,代碼來源:MqttHeaderHelperTest.java

示例2: 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

示例3: testTopicHeader

import org.springframework.messaging.support.MessageBuilder; //導入方法依賴的package包/類
@Test
public void testTopicHeader()
{
    Assert.assertNull(MqttHeaderHelper.getTopicHeaderValue(null));
    MessageBuilder<String> builder = MessageBuilder.withPayload("See topic header");
    Assert.assertNull(MqttHeaderHelper.getTopicHeaderValue(builder.build()));
    builder.setHeader(MqttHeaderHelper.TOPIC, TOPIC);
    Assert.assertEquals(TOPIC, MqttHeaderHelper.getTopicHeaderValue(builder.build()));
}
 
開發者ID:christophersmith,項目名稱:summer-mqtt,代碼行數:10,代碼來源:MqttHeaderHelperTest.java

示例4: testRetainedHeader

import org.springframework.messaging.support.MessageBuilder; //導入方法依賴的package包/類
@Test
public void testRetainedHeader()
{
    Assert.assertFalse(MqttHeaderHelper.getRetainedHeaderValue(null));
    MessageBuilder<String> builder = MessageBuilder.withPayload("See retained header");
    Assert.assertFalse(MqttHeaderHelper.getRetainedHeaderValue(builder.build()));
    builder.setHeader(MqttHeaderHelper.RETAINED, "foo");
    Assert.assertFalse(MqttHeaderHelper.getRetainedHeaderValue(builder.build()));
    builder.setHeader(MqttHeaderHelper.RETAINED, true);
    Assert.assertTrue(MqttHeaderHelper.getRetainedHeaderValue(builder.build()));
}
 
開發者ID:christophersmith,項目名稱:summer-mqtt,代碼行數:12,代碼來源:MqttHeaderHelperTest.java

示例5: testCorrelationIdHeader

import org.springframework.messaging.support.MessageBuilder; //導入方法依賴的package包/類
@Test
public void testCorrelationIdHeader()
{
    Assert.assertNull(MqttHeaderHelper.getCorrelationIdHeaderValue(null));
    MessageBuilder<String> builder = MessageBuilder.withPayload("See Correlation ID header");
    Assert.assertNull(MqttHeaderHelper.getCorrelationIdHeaderValue(builder.build()));
    builder.setHeader(MqttHeaderHelper.CORRELATION_ID, "foo");
    Assert.assertSame("foo", MqttHeaderHelper.getCorrelationIdHeaderValue(builder.build()));
}
 
開發者ID:christophersmith,項目名稱:summer-mqtt,代碼行數:10,代碼來源:MqttHeaderHelperTest.java

示例6: message

import org.springframework.messaging.support.MessageBuilder; //導入方法依賴的package包/類
private Message<byte[]> message(SimpMessageType messageType) {
	MessageBuilder<byte[]> builder = MessageBuilder.withPayload(new byte[0]);
	if (messageType != null) {
		builder.setHeader(SimpMessageHeaderAccessor.MESSAGE_TYPE_HEADER, messageType);
	}
	return builder.build();
}
 
開發者ID:langtianya,項目名稱:spring4-understanding,代碼行數:8,代碼來源:SimpMessageTypeMessageConditionTests.java

示例7: forPayload

import org.springframework.messaging.support.MessageBuilder; //導入方法依賴的package包/類
private static Message<?> forPayload(String metricName, Object payload) {
	MessageBuilder<Object> builder = MessageBuilder.withPayload(payload);
	builder.setHeader(METRIC_NAME, metricName);
	return builder.build();
}
 
開發者ID:vikrammane23,項目名稱:https-github.com-g0t4-jenkins2-course-spring-boot,代碼行數:6,代碼來源:MetricMessage.java


注:本文中的org.springframework.messaging.support.MessageBuilder.setHeader方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。