当前位置: 首页>>代码示例>>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;未经允许,请勿转载。