Java Code Examples for org.springframework.messaging.support.MessageHeaderAccessor#setLeaveMutable()
The following examples show how to use
org.springframework.messaging.support.MessageHeaderAccessor#setLeaveMutable() .
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: AbstractMethodMessageHandler.java From spring-analysis-note with MIT License | 6 votes |
@Override public void handleMessage(Message<?> message) throws MessagingException { String destination = getDestination(message); if (destination == null) { return; } String lookupDestination = getLookupDestination(destination); if (lookupDestination == null) { return; } MessageHeaderAccessor headerAccessor = MessageHeaderAccessor.getMutableAccessor(message); headerAccessor.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, lookupDestination); headerAccessor.setLeaveMutable(true); message = MessageBuilder.createMessage(message.getPayload(), headerAccessor.getMessageHeaders()); if (logger.isDebugEnabled()) { logger.debug("Searching methods to handle " + headerAccessor.getShortLogMessage(message.getPayload()) + ", lookupDestination='" + lookupDestination + "'"); } handleMessageInternal(message, lookupDestination); headerAccessor.setImmutable(); }
Example 2
Source File: AbstractMethodMessageHandler.java From java-technology-stack with MIT License | 6 votes |
@Override public void handleMessage(Message<?> message) throws MessagingException { String destination = getDestination(message); if (destination == null) { return; } String lookupDestination = getLookupDestination(destination); if (lookupDestination == null) { return; } MessageHeaderAccessor headerAccessor = MessageHeaderAccessor.getMutableAccessor(message); headerAccessor.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, lookupDestination); headerAccessor.setLeaveMutable(true); message = MessageBuilder.createMessage(message.getPayload(), headerAccessor.getMessageHeaders()); if (logger.isDebugEnabled()) { logger.debug("Searching methods to handle " + headerAccessor.getShortLogMessage(message.getPayload()) + ", lookupDestination='" + lookupDestination + "'"); } handleMessageInternal(message, lookupDestination); headerAccessor.setImmutable(); }
Example 3
Source File: AbstractMethodMessageHandler.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public void handleMessage(Message<?> message) throws MessagingException { String destination = getDestination(message); if (destination == null) { return; } String lookupDestination = getLookupDestination(destination); if (lookupDestination == null) { return; } MessageHeaderAccessor headerAccessor = MessageHeaderAccessor.getMutableAccessor(message); headerAccessor.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, lookupDestination); headerAccessor.setLeaveMutable(true); message = MessageBuilder.createMessage(message.getPayload(), headerAccessor.getMessageHeaders()); if (logger.isDebugEnabled()) { logger.debug("Searching methods to handle " + headerAccessor.getShortLogMessage(message.getPayload())); } handleMessageInternal(message, lookupDestination); headerAccessor.setImmutable(); }
Example 4
Source File: MessagingRSocket.java From spring-analysis-note with MIT License | 5 votes |
private MessageHeaders createHeaders(String destination, @Nullable MonoProcessor<?> replyMono) { MessageHeaderAccessor headers = new MessageHeaderAccessor(); headers.setLeaveMutable(true); headers.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, destination); if (this.dataMimeType != null) { headers.setContentType(this.dataMimeType); } headers.setHeader(RSocketRequesterMethodArgumentResolver.RSOCKET_REQUESTER_HEADER, this.requester); if (replyMono != null) { headers.setHeader(RSocketPayloadReturnValueHandler.RESPONSE_HEADER, replyMono); } headers.setHeader(HandlerMethodReturnValueHandler.DATA_BUFFER_FACTORY_HEADER, this.bufferFactory); return headers.getMessageHeaders(); }
Example 5
Source File: SimpleMessageConverterTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void toMessageWithPayloadAndMutableHeaders() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders headers = accessor.getMessageHeaders(); Message<?> message = this.converter.toMessage("payload", headers); assertEquals("payload", message.getPayload()); assertSame(headers, message.getHeaders()); assertEquals("bar", message.getHeaders().get("foo")); }
Example 6
Source File: MessageMappingMessageHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
private Message<?> message(String destination, String... content) { Flux<DataBuffer> payload = Flux.fromIterable(Arrays.asList(content)).map(parts -> toDataBuffer(parts)); MessageHeaderAccessor headers = new MessageHeaderAccessor(); headers.setLeaveMutable(true); headers.setHeader(DestinationPatternsMessageCondition.LOOKUP_DESTINATION_HEADER, destination); return MessageBuilder.createMessage(payload, headers.getMessageHeaders()); }
Example 7
Source File: MessageSendingTemplateTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void convertAndSendPayloadAndMutableHeadersToDestination() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders messageHeaders = accessor.getMessageHeaders(); this.template.setMessageConverter(new StringMessageConverter()); this.template.convertAndSend("somewhere", "payload", messageHeaders); MessageHeaders actual = this.template.message.getHeaders(); assertSame(messageHeaders, actual); assertEquals(new MimeType("text", "plain", StandardCharsets.UTF_8), actual.get(MessageHeaders.CONTENT_TYPE)); assertEquals("bar", actual.get("foo")); }
Example 8
Source File: GenericMessagingTemplateTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void convertAndSendWithSimpMessageHeaders() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("key", "value"); accessor.setLeaveMutable(true); MessageHeaders headers = accessor.getMessageHeaders(); this.template.convertAndSend("channel", "data", headers); List<Message<byte[]>> messages = this.messageChannel.getMessages(); Message<byte[]> message = messages.get(0); assertSame(headers, message.getHeaders()); assertFalse(accessor.isMutable()); }
Example 9
Source File: SimpleMessageConverterTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void toMessageWithPayloadAndMutableHeaders() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders headers = accessor.getMessageHeaders(); Message<?> message = this.converter.toMessage("payload", headers); assertEquals("payload", message.getPayload()); assertSame(headers, message.getHeaders()); assertEquals("bar", message.getHeaders().get("foo")); }
Example 10
Source File: MessageSendingTemplateTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void convertAndSendPayloadAndMutableHeadersToDestination() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders messageHeaders = accessor.getMessageHeaders(); this.template.setMessageConverter(new StringMessageConverter()); this.template.convertAndSend("somewhere", "payload", messageHeaders); MessageHeaders actual = this.template.message.getHeaders(); assertSame(messageHeaders, actual); assertEquals(new MimeType("text", "plain", StandardCharsets.UTF_8), actual.get(MessageHeaders.CONTENT_TYPE)); assertEquals("bar", actual.get("foo")); }
Example 11
Source File: GenericMessagingTemplateTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void convertAndSendWithSimpMessageHeaders() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("key", "value"); accessor.setLeaveMutable(true); MessageHeaders headers = accessor.getMessageHeaders(); this.template.convertAndSend("channel", "data", headers); List<Message<byte[]>> messages = this.messageChannel.getMessages(); Message<byte[]> message = messages.get(0); assertSame(headers, message.getHeaders()); assertFalse(accessor.isMutable()); }
Example 12
Source File: SimpleMessageConverterTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void toMessageWithPayloadAndMutableHeaders() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders headers = accessor.getMessageHeaders(); Message<?> message = this.converter.toMessage("payload", headers); assertEquals("payload", message.getPayload()); assertSame(headers, message.getHeaders()); assertEquals("bar", message.getHeaders().get("foo")); }
Example 13
Source File: MessageSendingTemplateTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void convertAndSendPayloadAndMutableHeadersToDestination() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("foo", "bar"); accessor.setLeaveMutable(true); MessageHeaders messageHeaders = accessor.getMessageHeaders(); this.template.setMessageConverter(new StringMessageConverter()); this.template.convertAndSend("somewhere", "payload", messageHeaders); MessageHeaders actual = this.template.message.getHeaders(); assertSame(messageHeaders, actual); assertEquals(new MimeType("text", "plain", Charset.forName("UTF-8")), actual.get(MessageHeaders.CONTENT_TYPE)); assertEquals("bar", actual.get("foo")); }
Example 14
Source File: GenericMessagingTemplateTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void convertAndSendWithSimpMessageHeaders() { MessageHeaderAccessor accessor = new MessageHeaderAccessor(); accessor.setHeader("key", "value"); accessor.setLeaveMutable(true); MessageHeaders headers = accessor.getMessageHeaders(); this.template.convertAndSend("channel", "data", headers); List<Message<byte[]>> messages = this.messageChannel.getMessages(); Message<byte[]> message = messages.get(0); assertSame(headers, message.getHeaders()); assertFalse(accessor.isMutable()); }
Example 15
Source File: TracingChannelInterceptor.java From spring-cloud-sleuth with Apache License 2.0 | 4 votes |
private MessageHeaderAccessor mutableHeaderAccessor(Message<?> message) { MessageHeaderAccessor headers = MessageHeaderAccessor.getMutableAccessor(message); headers.setLeaveMutable(true); return headers; }