本文整理汇总了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()));
}
示例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();
}
示例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()));
}
示例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()));
}
示例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()));
}
示例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();
}
示例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