use of org.springframework.jms.support.converter.MappingJackson2MessageConverter in project spring-integration by spring-projects.
the class DefaultJmsHeaderMapperTests method testJsonHeaderMapping.
@Test
public void testJsonHeaderMapping() throws JMSException {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("javatype");
Session session = Mockito.mock(Session.class);
Mockito.doAnswer(invocation -> new StubTextMessage(invocation.getArgument(0))).when(session).createTextMessage(Mockito.anyString());
javax.jms.Message request = converter.toMessage(new Foo(), session);
DefaultJmsHeaderMapper mapper = new DefaultJmsHeaderMapper();
Map<String, Object> headers = mapper.toHeaders(request);
javax.jms.Message reply = converter.toMessage("foo", session);
mapper.fromHeaders(new MessageHeaders(headers), reply);
Object result = converter.fromMessage(reply);
assertThat(result, instanceOf(String.class));
}
use of org.springframework.jms.support.converter.MappingJackson2MessageConverter in project av-service by dvoraka.
the class JmsBridgeOutputConfig method outMessageConverter.
@Bean
public MessageConverter outMessageConverter() {
MappingJackson2MessageConverter messageConverter = new MappingJackson2MessageConverter();
messageConverter.setTypeIdPropertyName("typeId");
return messageConverter;
}
use of org.springframework.jms.support.converter.MappingJackson2MessageConverter in project av-service by dvoraka.
the class JmsServerConfig method fileServerMessageConverter.
@Bean
public MessageConverter fileServerMessageConverter() {
MappingJackson2MessageConverter messageConverter = new MappingJackson2MessageConverter();
messageConverter.setTypeIdPropertyName("typeId");
return messageConverter;
}
use of org.springframework.jms.support.converter.MappingJackson2MessageConverter in project spring-framework by spring-projects.
the class MessagingMessageListenerAdapterTests method testReplyWithJackson.
public TextMessage testReplyWithJackson(String methodName, String replyContent) throws JMSException {
Queue replyDestination = mock(Queue.class);
Session session = mock(Session.class);
MessageProducer messageProducer = mock(MessageProducer.class);
TextMessage responseMessage = mock(TextMessage.class);
given(session.createTextMessage(replyContent)).willReturn(responseMessage);
given(session.createProducer(replyDestination)).willReturn(messageProducer);
MessagingMessageListenerAdapter listener = getPayloadInstance("Response", methodName, Message.class);
MappingJackson2MessageConverter messageConverter = new MappingJackson2MessageConverter();
messageConverter.setTargetType(MessageType.TEXT);
listener.setMessageConverter(messageConverter);
listener.setDefaultResponseDestination(replyDestination);
listener.onMessage(mock(jakarta.jms.Message.class), session);
verify(session, times(0)).createQueue(anyString());
verify(session).createTextMessage(replyContent);
verify(messageProducer).send(responseMessage);
verify(messageProducer).close();
return responseMessage;
}
use of org.springframework.jms.support.converter.MappingJackson2MessageConverter in project cas by apereo.
the class JmsTicketRegistryConfiguration method jacksonJmsMessageTicketRegistryConverter.
@Bean
@RefreshScope(proxyMode = ScopedProxyMode.DEFAULT)
public MessageConverter jacksonJmsMessageTicketRegistryConverter() {
val converter = new MappingJackson2MessageConverter();
val mapper = JacksonObjectMapperFactory.builder().defaultTypingEnabled(true).defaultViewInclusion(false).writeDatesAsTimestamps(true).build().toObjectMapper();
converter.setObjectMapper(mapper);
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("@class");
return converter;
}
Aggregations