org.springframework.jms.support.converter.MessagingMessageConverter Java Examples

The following examples show how to use org.springframework.jms.support.converter.MessagingMessageConverter. 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: JmsMessagingTemplate.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	Assert.notNull(this.jmsTemplate, "Property 'connectionFactory' or 'jmsTemplate' is required");
	if (!this.converterSet && this.jmsTemplate.getMessageConverter() != null) {
		((MessagingMessageConverter) this.jmsMessageConverter)
				.setPayloadConverter(this.jmsTemplate.getMessageConverter());
	}
}
 
Example #2
Source File: JmsListenerContainerFactoryIntegrationTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void messagingMessageConverterCanBeUsed() throws JMSException {
	MessagingMessageConverter converter = new MessagingMessageConverter();
	converter.setPayloadConverter(new UpperCaseMessageConverter());
	this.containerFactory.setMessageConverter(converter);
	testMessageConverterIsUsed();
}
 
Example #3
Source File: JmsMessagingTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Test
public void customConverterAlwaysTakesPrecedence() {
	MessageConverter messageConverter = mock(MessageConverter.class);
	given(this.jmsTemplate.getMessageConverter()).willReturn(messageConverter);
	MessageConverter customMessageConverter = mock(MessageConverter.class);
	JmsMessagingTemplate messagingTemplate = new JmsMessagingTemplate();
	messagingTemplate.setJmsMessageConverter(
			new MessagingMessageConverter(customMessageConverter));
	messagingTemplate.setJmsTemplate(this.jmsTemplate);
	messagingTemplate.afterPropertiesSet();
	assertPayloadConverter(messagingTemplate, customMessageConverter);
}
 
Example #4
Source File: JmsMessagingTemplateTests.java    From spring-analysis-note with MIT License 5 votes vote down vote up
private void assertPayloadConverter(JmsMessagingTemplate messagingTemplate,
		MessageConverter messageConverter) {
	MessageConverter jmsMessageConverter = messagingTemplate.getJmsMessageConverter();
	assertNotNull(jmsMessageConverter);
	assertEquals(MessagingMessageConverter.class, jmsMessageConverter.getClass());
	assertSame(messageConverter, new DirectFieldAccessor(jmsMessageConverter)
			.getPropertyValue("payloadConverter"));
}
 
Example #5
Source File: JmsMessagingTemplate.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() {
	Assert.notNull(this.jmsTemplate, "Property 'connectionFactory' or 'jmsTemplate' is required");
	if (!this.converterSet && this.jmsTemplate.getMessageConverter() != null) {
		((MessagingMessageConverter) this.jmsMessageConverter)
				.setPayloadConverter(this.jmsTemplate.getMessageConverter());
	}
}
 
Example #6
Source File: JmsListenerContainerFactoryIntegrationTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void messagingMessageConverterCanBeUsed() throws JMSException {
	MessagingMessageConverter converter = new MessagingMessageConverter();
	converter.setPayloadConverter(new UpperCaseMessageConverter());
	this.containerFactory.setMessageConverter(converter);
	testMessageConverterIsUsed();
}
 
Example #7
Source File: JmsMessagingTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Test
public void customConverterAlwaysTakesPrecedence() {
	MessageConverter messageConverter = mock(MessageConverter.class);
	given(this.jmsTemplate.getMessageConverter()).willReturn(messageConverter);
	MessageConverter customMessageConverter = mock(MessageConverter.class);
	JmsMessagingTemplate messagingTemplate = new JmsMessagingTemplate();
	messagingTemplate.setJmsMessageConverter(
			new MessagingMessageConverter(customMessageConverter));
	messagingTemplate.setJmsTemplate(this.jmsTemplate);
	messagingTemplate.afterPropertiesSet();
	assertPayloadConverter(messagingTemplate, customMessageConverter);
}
 
Example #8
Source File: JmsMessagingTemplateTests.java    From java-technology-stack with MIT License 5 votes vote down vote up
private void assertPayloadConverter(JmsMessagingTemplate messagingTemplate,
		MessageConverter messageConverter) {
	MessageConverter jmsMessageConverter = messagingTemplate.getJmsMessageConverter();
	assertNotNull(jmsMessageConverter);
	assertEquals(MessagingMessageConverter.class, jmsMessageConverter.getClass());
	assertSame(messageConverter, new DirectFieldAccessor(jmsMessageConverter)
			.getPropertyValue("payloadConverter"));
}
 
Example #9
Source File: AbstractAdaptableMessageListener.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Return the {@link MessagingMessageConverter} for this listener,
 * being able to convert {@link org.springframework.messaging.Message}.
 */
protected final MessagingMessageConverter getMessagingMessageConverter() {
	return this.messagingMessageConverter;
}
 
Example #10
Source File: AbstractAdaptableMessageListener.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Return the {@link MessagingMessageConverter} for this listener,
 * being able to convert {@link org.springframework.messaging.Message}.
 */
protected final MessagingMessageConverter getMessagingMessageConverter() {
	return this.messagingMessageConverter;
}
 
Example #11
Source File: AbstractAdaptableMessageListener.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Return the {@link MessagingMessageConverter} for this listener,
 * being able to convert {@link org.springframework.messaging.Message}.
 */
protected final MessagingMessageConverter getMessagingMessageConverter() {
	return this.messagingMessageConverter;
}