Java Code Examples for org.springframework.messaging.simp.stomp.StompHeaderAccessor#setSubscriptionId()

The following examples show how to use org.springframework.messaging.simp.stomp.StompHeaderAccessor#setSubscriptionId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MessageBrokerConfigurationTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void clientOutboundChannelUsedByAnnotatedMethod() {
	ApplicationContext context = loadConfig(SimpleBrokerConfig.class);

	TestChannel channel = context.getBean("clientOutboundChannel", TestChannel.class);
	SimpAnnotationMethodMessageHandler messageHandler =
			context.getBean(SimpAnnotationMethodMessageHandler.class);

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSessionAttributes(new ConcurrentHashMap<>());
	headers.setSubscriptionId("subs1");
	headers.setDestination("/foo");
	Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();

	messageHandler.handleMessage(message);

	message = channel.messages.get(0);
	headers = StompHeaderAccessor.wrap(message);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals("/foo", headers.getDestination());
	assertEquals("bar", new String((byte[]) message.getPayload()));
}
 
Example 2
Source File: StompSubProtocolHandlerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Test
public void handleMessageToClientWithUserDestination() {

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
	headers.setMessageId("mess0");
	headers.setSubscriptionId("sub0");
	headers.setDestination("/queue/foo-user123");
	headers.setNativeHeader(StompHeaderAccessor.ORIGINAL_DESTINATION, "/user/queue/foo");
	Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(1, this.session.getSentMessages().size());
	WebSocketMessage<?> textMessage = this.session.getSentMessages().get(0);
	assertTrue(((String) textMessage.getPayload()).contains("destination:/user/queue/foo\n"));
	assertFalse(((String) textMessage.getPayload()).contains(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION));
}
 
Example 3
Source File: StompSubProtocolHandlerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void handleMessageToClientWithUserDestination() {

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
	headers.setMessageId("mess0");
	headers.setSubscriptionId("sub0");
	headers.setDestination("/queue/foo-user123");
	headers.setNativeHeader(StompHeaderAccessor.ORIGINAL_DESTINATION, "/user/queue/foo");
	Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(1, this.session.getSentMessages().size());
	WebSocketMessage<?> textMessage = this.session.getSentMessages().get(0);
	assertTrue(((String) textMessage.getPayload()).contains("destination:/user/queue/foo\n"));
	assertFalse(((String) textMessage.getPayload()).contains(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION));
}
 
Example 4
Source File: MessageBrokerConfigurationTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void clientOutboundChannelUsedByAnnotatedMethod() {
	ApplicationContext context = loadConfig(SimpleBrokerConfig.class);

	TestChannel channel = context.getBean("clientOutboundChannel", TestChannel.class);
	SimpAnnotationMethodMessageHandler messageHandler =
			context.getBean(SimpAnnotationMethodMessageHandler.class);

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSessionAttributes(new ConcurrentHashMap<>());
	headers.setSubscriptionId("subs1");
	headers.setDestination("/foo");
	Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();

	messageHandler.handleMessage(message);

	message = channel.messages.get(0);
	headers = StompHeaderAccessor.wrap(message);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals("/foo", headers.getDestination());
	assertEquals("bar", new String((byte[]) message.getPayload()));
}
 
Example 5
Source File: MessageBrokerConfigurationTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Test
public void clientOutboundChannelUsedByAnnotatedMethod() {
	TestChannel channel = this.simpleBrokerContext.getBean("clientOutboundChannel", TestChannel.class);
	SimpAnnotationMethodMessageHandler messageHandler = this.simpleBrokerContext.getBean(SimpAnnotationMethodMessageHandler.class);

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSessionAttributes(new ConcurrentHashMap<>());
	headers.setSubscriptionId("subs1");
	headers.setDestination("/foo");
	Message<?> message = MessageBuilder.withPayload(new byte[0]).setHeaders(headers).build();

	messageHandler.handleMessage(message);

	message = channel.messages.get(0);
	headers = StompHeaderAccessor.wrap(message);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals("/foo", headers.getDestination());
	assertEquals("bar", new String((byte[]) message.getPayload()));
}
 
Example 6
Source File: StompSubProtocolHandlerTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Test
public void handleMessageToClientWithUserDestination() {

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
	headers.setMessageId("mess0");
	headers.setSubscriptionId("sub0");
	headers.setDestination("/queue/foo-user123");
	headers.setNativeHeader(StompHeaderAccessor.ORIGINAL_DESTINATION, "/user/queue/foo");
	Message<byte[]> message = MessageBuilder.createMessage(EMPTY_PAYLOAD, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(1, this.session.getSentMessages().size());
	WebSocketMessage<?> textMessage = this.session.getSentMessages().get(0);
	assertTrue(((String) textMessage.getPayload()).contains("destination:/user/queue/foo\n"));
	assertFalse(((String) textMessage.getPayload()).contains(SimpMessageHeaderAccessor.ORIGINAL_DESTINATION));
}
 
Example 7
Source File: MessageBrokerConfigurationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void clientOutboundChannelUsedBySimpleBroker() {
	ApplicationContext context = loadConfig(SimpleBrokerConfig.class);

	TestChannel outboundChannel = context.getBean("clientOutboundChannel", TestChannel.class);
	SimpleBrokerMessageHandler broker = context.getBean(SimpleBrokerMessageHandler.class);

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSubscriptionId("subs1");
	headers.setDestination("/foo");
	Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());

	// subscribe
	broker.handleMessage(createConnectMessage("sess1", new long[] {0,0}));
	broker.handleMessage(message);

	headers = StompHeaderAccessor.create(StompCommand.SEND);
	headers.setSessionId("sess1");
	headers.setDestination("/foo");
	message = MessageBuilder.createMessage("bar".getBytes(), headers.getMessageHeaders());

	// message
	broker.handleMessage(message);

	message = outboundChannel.messages.get(1);
	headers = StompHeaderAccessor.wrap(message);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals("/foo", headers.getDestination());
	assertEquals("bar", new String((byte[]) message.getPayload()));
}
 
Example 8
Source File: WebSocketStompSession.java    From bearchoke with Apache License 2.0 5 votes vote down vote up
public void subscribe(String destination, String receiptId) {
	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSubscriptionId("sub" + this.subscriptionIndex.getAndIncrement());
	headers.setDestination(destination);
	if (receiptId != null) {
		headers.setReceipt(receiptId);
	}
	sendInternal(MessageBuilder.withPayload(EMPTY_PAYLOAD).setHeaders(headers).build());
}
 
Example 9
Source File: Stomp.java    From haven-platform with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 10
Source File: StompSubProtocolHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void handleMessageToClientWithBinaryWebSocketMessage() {

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
	headers.setMessageId("mess0");
	headers.setSubscriptionId("sub0");
	headers.setContentType(MimeTypeUtils.APPLICATION_OCTET_STREAM);
	headers.setDestination("/queue/foo");

	// Non-empty payload

	byte[] payload = new byte[1];
	Message<byte[]> message = MessageBuilder.createMessage(payload, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(1, this.session.getSentMessages().size());
	WebSocketMessage<?> webSocketMessage = this.session.getSentMessages().get(0);
	assertTrue(webSocketMessage instanceof BinaryMessage);

	// Empty payload

	payload = EMPTY_PAYLOAD;
	message = MessageBuilder.createMessage(payload, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(2, this.session.getSentMessages().size());
	webSocketMessage = this.session.getSentMessages().get(1);
	assertTrue(webSocketMessage instanceof TextMessage);
}
 
Example 11
Source File: MessageBrokerConfigurationTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Test
public void clientOutboundChannelUsedBySimpleBroker() {
	TestChannel channel = this.simpleBrokerContext.getBean("clientOutboundChannel", TestChannel.class);
	SimpleBrokerMessageHandler broker = this.simpleBrokerContext.getBean(SimpleBrokerMessageHandler.class);

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSubscriptionId("subs1");
	headers.setDestination("/foo");
	Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());

	// subscribe
	broker.handleMessage(message);

	headers = StompHeaderAccessor.create(StompCommand.SEND);
	headers.setSessionId("sess1");
	headers.setDestination("/foo");
	message = MessageBuilder.createMessage("bar".getBytes(), headers.getMessageHeaders());

	// message
	broker.handleMessage(message);

	message = channel.messages.get(0);
	headers = StompHeaderAccessor.wrap(message);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals("/foo", headers.getDestination());
	assertEquals("bar", new String((byte[]) message.getPayload()));
}
 
Example 12
Source File: StompSubProtocolHandlerTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void handleMessageToClientWithBinaryWebSocketMessage() {

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
	headers.setMessageId("mess0");
	headers.setSubscriptionId("sub0");
	headers.setContentType(MimeTypeUtils.APPLICATION_OCTET_STREAM);
	headers.setDestination("/queue/foo");

	// Non-empty payload

	byte[] payload = new byte[1];
	Message<byte[]> message = MessageBuilder.createMessage(payload, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(1, this.session.getSentMessages().size());
	WebSocketMessage<?> webSocketMessage = this.session.getSentMessages().get(0);
	assertTrue(webSocketMessage instanceof BinaryMessage);

	// Empty payload

	payload = EMPTY_PAYLOAD;
	message = MessageBuilder.createMessage(payload, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(2, this.session.getSentMessages().size());
	webSocketMessage = this.session.getSentMessages().get(1);
	assertTrue(webSocketMessage instanceof TextMessage);
}
 
Example 13
Source File: MessageBrokerConfigurationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void clientOutboundChannelUsedBySimpleBroker() {
	ApplicationContext context = loadConfig(SimpleBrokerConfig.class);

	TestChannel outboundChannel = context.getBean("clientOutboundChannel", TestChannel.class);
	SimpleBrokerMessageHandler broker = context.getBean(SimpleBrokerMessageHandler.class);

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSubscriptionId("subs1");
	headers.setDestination("/foo");
	Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());

	// subscribe
	broker.handleMessage(createConnectMessage("sess1", new long[] {0,0}));
	broker.handleMessage(message);

	headers = StompHeaderAccessor.create(StompCommand.SEND);
	headers.setSessionId("sess1");
	headers.setDestination("/foo");
	message = MessageBuilder.createMessage("bar".getBytes(), headers.getMessageHeaders());

	// message
	broker.handleMessage(message);

	message = outboundChannel.messages.get(1);
	headers = StompHeaderAccessor.wrap(message);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals("/foo", headers.getDestination());
	assertEquals("bar", new String((byte[]) message.getPayload()));
}
 
Example 14
Source File: BrokerStomp.java    From WeEvent with Apache License 2.0 5 votes vote down vote up
private void handleOnEvent(String headerIdStr,
                           String subscriptionId,
                           WeEvent event,
                           WebSocketSession session) {
    StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.MESSAGE);
    // package the return frame
    accessor.setSubscriptionId(headerIdStr);
    accessor.setNativeHeader("subscription-id", subscriptionId);
    accessor.setMessageId(headerIdStr);
    accessor.setDestination(event.getTopic());
    accessor.setContentType(new MimeType("text", "plain", StandardCharsets.UTF_8));

    // set custom properties in header
    for (Map.Entry<String, String> custom : event.getExtensions().entrySet()) {
        accessor.setNativeHeader(custom.getKey(), custom.getValue());
    }

    // set eventId in header
    accessor.setNativeHeader(WeEventConstants.EXTENSIONS_EVENT_ID, event.getEventId());

    // payload == content
    MessageHeaders headers = accessor.getMessageHeaders();
    Message<byte[]> message = MessageBuilder.createMessage(event.getContent(), headers);
    byte[] bytes = new StompEncoder().encode(message);

    // send to remote
    send2Remote(session, new TextMessage(bytes));
}
 
Example 15
Source File: StompSubProtocolHandlerTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void handleMessageToClientWithBinaryWebSocketMessage() {

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.MESSAGE);
	headers.setMessageId("mess0");
	headers.setSubscriptionId("sub0");
	headers.setContentType(MimeTypeUtils.APPLICATION_OCTET_STREAM);
	headers.setDestination("/queue/foo");

	// Non-empty payload

	byte[] payload = new byte[1];
	Message<byte[]> message = MessageBuilder.createMessage(payload, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(1, this.session.getSentMessages().size());
	WebSocketMessage<?> webSocketMessage = this.session.getSentMessages().get(0);
	assertTrue(webSocketMessage instanceof BinaryMessage);

	// Empty payload

	payload = EMPTY_PAYLOAD;
	message = MessageBuilder.createMessage(payload, headers.getMessageHeaders());
	this.protocolHandler.handleMessageToClient(this.session, message);

	assertEquals(2, this.session.getSentMessages().size());
	webSocketMessage = this.session.getSentMessages().get(1);
	assertTrue(webSocketMessage instanceof TextMessage);
}
 
Example 16
Source File: MessageBrokerConfigurationTests.java    From java-technology-stack with MIT License 4 votes vote down vote up
private void testDotSeparator(ApplicationContext context, boolean expectLeadingSlash) {
	MessageChannel inChannel = context.getBean("clientInboundChannel", MessageChannel.class);
	TestChannel outChannel = context.getBean("clientOutboundChannel", TestChannel.class);
	MessageChannel brokerChannel = context.getBean("brokerChannel", MessageChannel.class);

	inChannel.send(createConnectMessage("sess1", new long[] {0,0}));

	// 1. Subscribe to user destination

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSubscriptionId("subs1");
	headers.setDestination("/user/queue.q1");
	Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
	inChannel.send(message);

	// 2. Send message to user via inboundChannel

	headers = StompHeaderAccessor.create(StompCommand.SEND);
	headers.setSessionId("sess1");
	headers.setDestination("/user/sess1/queue.q1");
	message = MessageBuilder.createMessage("123".getBytes(), headers.getMessageHeaders());
	inChannel.send(message);

	assertEquals(2, outChannel.messages.size());
	Message<?> outputMessage = outChannel.messages.remove(1);
	headers = StompHeaderAccessor.wrap(outputMessage);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals(expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1", headers.getDestination());
	assertEquals("123", new String((byte[]) outputMessage.getPayload()));
	outChannel.messages.clear();

	// 3. Send message via broker channel

	SimpMessagingTemplate template = new SimpMessagingTemplate(brokerChannel);
	SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
	accessor.setSessionId("sess1");
	template.convertAndSendToUser("sess1", "queue.q1", "456".getBytes(), accessor.getMessageHeaders());

	assertEquals(1, outChannel.messages.size());
	outputMessage = outChannel.messages.remove(0);
	headers = StompHeaderAccessor.wrap(outputMessage);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals(expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1", headers.getDestination());
	assertEquals("456", new String((byte[]) outputMessage.getPayload()));

}
 
Example 17
Source File: BrokerStomp.java    From WeEvent with Apache License 2.0 4 votes vote down vote up
private void handleSubscribeMessage(StompHeaderAccessor stompHeaderAccessor, WebSocketSession session) {
    // subscribe command id
    String headerIdStr = stompHeaderAccessor.getFirstNativeHeader(StompHeaderAccessor.STOMP_ID_HEADER);

    // group
    String groupId = stompHeaderAccessor.getFirstNativeHeader(WeEventConstants.EVENT_GROUP_ID);
    if (StringUtils.isBlank(groupId)) {
        groupId = "";
    }

    // check if there hasn't the event, need use the last id
    String subEventId = stompHeaderAccessor.getFirstNativeHeader(WeEventConstants.EXTENSIONS_EVENT_ID);
    if (StringUtils.isBlank(subEventId)) {
        subEventId = WeEvent.OFFSET_LAST;
    }

    // subscription id
    String continueSubscriptionIdStr = stompHeaderAccessor.getFirstNativeHeader(WeEvent.WeEvent_SubscriptionId);
    if (StringUtils.isBlank(continueSubscriptionIdStr)) {
        continueSubscriptionIdStr = "";
    }

    // tag
    String tag = stompHeaderAccessor.getFirstNativeHeader(WeEvent.WeEvent_TAG);
    if (StringUtils.isBlank(tag)) {
        tag = "";
    }

    // is ephemeral
    boolean ephemeral = stompHeaderAccessor.getFirstNativeHeader(WeEvent.WeEvent_EPHEMERAL) != null;

    try {
        String simpDestination = stompHeaderAccessor.getDestination();
        String subscriptionId = handleSubscribe(session,
                simpDestination,
                groupId,
                headerIdStr,
                subEventId,
                continueSubscriptionIdStr,
                tag,
                ephemeral);

        // send response
        StompHeaderAccessor accessor = StompHeaderAccessor.create(StompCommand.RECEIPT);
        accessor.setDestination(simpDestination);
        // a unique identifier for that message and a subscription header matching the identifier of the subscription that is receiving the message.
        accessor.setReceiptId(headerIdStr);
        accessor.setSubscriptionId(subscriptionId);
        accessor.setNativeHeader("subscription-id", subscriptionId);
        sendSimpleMessage(session, accessor);
    } catch (BrokerException e) {
        handleErrorMessage(session, e, headerIdStr);
    }
}
 
Example 18
Source File: MessageBrokerConfigurationTests.java    From spring-analysis-note with MIT License 4 votes vote down vote up
private void testDotSeparator(ApplicationContext context, boolean expectLeadingSlash) {
	MessageChannel inChannel = context.getBean("clientInboundChannel", MessageChannel.class);
	TestChannel outChannel = context.getBean("clientOutboundChannel", TestChannel.class);
	MessageChannel brokerChannel = context.getBean("brokerChannel", MessageChannel.class);

	inChannel.send(createConnectMessage("sess1", new long[] {0,0}));

	// 1. Subscribe to user destination

	StompHeaderAccessor headers = StompHeaderAccessor.create(StompCommand.SUBSCRIBE);
	headers.setSessionId("sess1");
	headers.setSubscriptionId("subs1");
	headers.setDestination("/user/queue.q1");
	Message<?> message = MessageBuilder.createMessage(new byte[0], headers.getMessageHeaders());
	inChannel.send(message);

	// 2. Send message to user via inboundChannel

	headers = StompHeaderAccessor.create(StompCommand.SEND);
	headers.setSessionId("sess1");
	headers.setDestination("/user/sess1/queue.q1");
	message = MessageBuilder.createMessage("123".getBytes(), headers.getMessageHeaders());
	inChannel.send(message);

	assertEquals(2, outChannel.messages.size());
	Message<?> outputMessage = outChannel.messages.remove(1);
	headers = StompHeaderAccessor.wrap(outputMessage);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals(expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1", headers.getDestination());
	assertEquals("123", new String((byte[]) outputMessage.getPayload()));
	outChannel.messages.clear();

	// 3. Send message via broker channel

	SimpMessagingTemplate template = new SimpMessagingTemplate(brokerChannel);
	SimpMessageHeaderAccessor accessor = SimpMessageHeaderAccessor.create();
	accessor.setSessionId("sess1");
	template.convertAndSendToUser("sess1", "queue.q1", "456".getBytes(), accessor.getMessageHeaders());

	assertEquals(1, outChannel.messages.size());
	outputMessage = outChannel.messages.remove(0);
	headers = StompHeaderAccessor.wrap(outputMessage);

	assertEquals(SimpMessageType.MESSAGE, headers.getMessageType());
	assertEquals(expectLeadingSlash ? "/queue.q1-usersess1" : "queue.q1-usersess1", headers.getDestination());
	assertEquals("456", new String((byte[]) outputMessage.getPayload()));

}