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


Java StompHeaderAccessor.setLeaveMutable方法代码示例

本文整理汇总了Java中org.springframework.messaging.simp.stomp.StompHeaderAccessor.setLeaveMutable方法的典型用法代码示例。如果您正苦于以下问题:Java StompHeaderAccessor.setLeaveMutable方法的具体用法?Java StompHeaderAccessor.setLeaveMutable怎么用?Java StompHeaderAccessor.setLeaveMutable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.messaging.simp.stomp.StompHeaderAccessor的用法示例。


在下文中一共展示了StompHeaderAccessor.setLeaveMutable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleMessageFromBrokerWithoutActiveSession

import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
@Test
public void handleMessageFromBrokerWithoutActiveSession() {
	this.handler.setBroadcastDestination("/topic/unresolved");
	given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true);

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.MESSAGE);
	accessor.setSessionId("system123");
	accessor.setDestination("/topic/unresolved");
	accessor.setNativeHeader(ORIGINAL_DESTINATION, "/user/joe/queue/foo");
	accessor.setLeaveMutable(true);
	byte[] payload = "payload".getBytes(Charset.forName("UTF-8"));
	this.handler.handleMessage(MessageBuilder.createMessage(payload, accessor.getMessageHeaders()));

	// No re-broadcast
	verifyNoMoreInteractions(this.brokerChannel);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:17,代码来源:UserDestinationMessageHandlerTests.java

示例2: handleClientMessageProcessingError

import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
@Override
public Message<byte[]> handleClientMessageProcessingError(Message<byte[]> clientMessage, Throwable ex) {
	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.ERROR);
	accessor.setMessage(ex.getMessage());
	accessor.setLeaveMutable(true);

	StompHeaderAccessor clientHeaderAccessor = null;
	if (clientMessage != null) {
		clientHeaderAccessor = MessageHeaderAccessor.getAccessor(clientMessage, StompHeaderAccessor.class);
		String receiptId = clientHeaderAccessor.getReceipt();
		if (receiptId != null) {
			accessor.setReceiptId(receiptId);
		}
	}

	return handleInternal(accessor, EMPTY_PAYLOAD, ex, clientHeaderAccessor);
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:18,代码来源:StompSubProtocolErrorHandler.java

示例3: handleMessageFromBrokerWithActiveSession

import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
@Test
public void handleMessageFromBrokerWithActiveSession() {

	TestSimpUser simpUser = new TestSimpUser("joe");
	simpUser.addSessions(new TestSimpSession("123"));
	when(this.registry.getUser("joe")).thenReturn(simpUser);

	this.handler.setBroadcastDestination("/topic/unresolved");
	given(this.brokerChannel.send(Mockito.any(Message.class))).willReturn(true);

	StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.MESSAGE);
	accessor.setSessionId("system123");
	accessor.setDestination("/topic/unresolved");
	accessor.setNativeHeader(ORIGINAL_DESTINATION, "/user/joe/queue/foo");
	accessor.setNativeHeader("customHeader", "customHeaderValue");
	accessor.setLeaveMutable(true);
	byte[] payload = "payload".getBytes(Charset.forName("UTF-8"));
	this.handler.handleMessage(MessageBuilder.createMessage(payload, accessor.getMessageHeaders()));

	ArgumentCaptor<Message> captor = ArgumentCaptor.forClass(Message.class);
	Mockito.verify(this.brokerChannel).send(captor.capture());
	assertNotNull(captor.getValue());
	SimpMessageHeaderAccessor headers = SimpMessageHeaderAccessor.wrap(captor.getValue());
	assertEquals("/queue/foo-user123", headers.getDestination());
	assertEquals("/user/queue/foo", headers.getFirstNativeHeader(ORIGINAL_DESTINATION));
	assertEquals("customHeaderValue", headers.getFirstNativeHeader("customHeader"));
	assertArrayEquals(payload, (byte[]) captor.getValue().getPayload());
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:29,代码来源:UserDestinationMessageHandlerTests.java

示例4: createHeaders

import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
public static StompHeaderAccessor createHeaders(String sessionId, String subscriptionId) {
    StompHeaderAccessor mha = StompHeaderAccessor.create(StompCommand.MESSAGE);
    mha.setLeaveMutable(true);
    mha.setMessageTypeIfNotSet(SimpMessageType.MESSAGE);
    mha.setSubscriptionId(subscriptionId);
    mha.setSessionId(sessionId);
    mha.setContentType(MimeTypeUtils.APPLICATION_JSON);
    return mha;
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:10,代码来源:Stomp.java

示例5: sendToSession

import org.springframework.messaging.simp.stomp.StompHeaderAccessor; //导入方法依赖的package包/类
public void sendToSession(String dest, Object msg) {
    StompHeaderAccessor sha = StompHeaderAccessor.create(StompCommand.MESSAGE);
    sha.setLeaveMutable(true);
    sha.setSessionId(sessionId);
    this.template.convertAndSendToUser(sessionId, "/queue/" + dest, msg, sha.getMessageHeaders());
}
 
开发者ID:codeabovelab,项目名称:haven-platform,代码行数:7,代码来源:Stomp.java


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