Java Code Examples for org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory

The following examples show how to use org.springframework.messaging.handler.annotation.support.DefaultMessageHandlerMethodFactory. These examples are extracted from open source projects. 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
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	if (beanFactory != null) {
		defaultFactory.setBeanFactory(beanFactory);
	}
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example 2
@Test
public void validatePayloadValid() throws JMSException {
	String methodName = "validatePayload";

	DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
	customFactory.setValidator(testValidator("invalid value"));
	initializeFactory(customFactory);

	Method method = getListenerMethod(methodName, String.class);
	MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
	Session session = mock(Session.class);
	listener.onMessage(createSimpleJmsTextMessage("test"), session); // test is a valid value
	assertListenerMethodInvocation(this.sample, methodName);
}
 
Example 3
@Test
public void validatePayloadInvalid() throws JMSException {
	DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
	customFactory.setValidator(testValidator("invalid value"));

	Method method = getListenerMethod("validatePayload", String.class);
	MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
	Session session = mock(Session.class);

	// test is an invalid value
	assertThatExceptionOfType(ListenerExecutionFailedException.class).isThrownBy(() ->
			listener.onMessage(createSimpleJmsTextMessage("invalid value"), session));

}
 
Example 4
private MessagingMessageListenerAdapter createInstance(
		DefaultMessageHandlerMethodFactory factory, Method method, MessageListenerContainer container) {

	MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
	endpoint.setBean(this.sample);
	endpoint.setMethod(method);
	endpoint.setMessageHandlerMethodFactory(factory);
	return endpoint.createMessageListener(container);
}
 
Example 5
private MethodJmsListenerEndpoint createMethodJmsEndpoint(DefaultMessageHandlerMethodFactory factory, Method method) {
	MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
	endpoint.setBean(listener);
	endpoint.setMethod(method);
	endpoint.setMessageHandlerMethodFactory(factory);
	return endpoint;
}
 
Example 6
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	if (beanFactory != null) {
		defaultFactory.setBeanFactory(beanFactory);
	}
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example 7
@Test
public void validatePayloadValid() throws JMSException {
	String methodName = "validatePayload";

	DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
	customFactory.setValidator(testValidator("invalid value"));
	initializeFactory(customFactory);

	Method method = getListenerMethod(methodName, String.class);
	MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
	Session session = mock(Session.class);
	listener.onMessage(createSimpleJmsTextMessage("test"), session); // test is a valid value
	assertListenerMethodInvocation(this.sample, methodName);
}
 
Example 8
@Test
public void validatePayloadInvalid() throws JMSException {
	DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
	customFactory.setValidator(testValidator("invalid value"));

	Method method = getListenerMethod("validatePayload", String.class);
	MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
	Session session = mock(Session.class);

	this.thrown.expect(ListenerExecutionFailedException.class);
	listener.onMessage(createSimpleJmsTextMessage("invalid value"), session); // test is an invalid value

}
 
Example 9
private MessagingMessageListenerAdapter createInstance(
		DefaultMessageHandlerMethodFactory factory, Method method, MessageListenerContainer container) {

	MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
	endpoint.setBean(this.sample);
	endpoint.setMethod(method);
	endpoint.setMessageHandlerMethodFactory(factory);
	return endpoint.createMessageListener(container);
}
 
Example 10
private MethodJmsListenerEndpoint createMethodJmsEndpoint(DefaultMessageHandlerMethodFactory factory, Method method) {
	MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
	endpoint.setBean(listener);
	endpoint.setMethod(method);
	endpoint.setMessageHandlerMethodFactory(factory);
	return endpoint;
}
 
Example 11
Source Project: heimdall   Source File: RabbitConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public DefaultMessageHandlerMethodFactory messageHandlerMethodFactory() {

     DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
     factory.setMessageConverter(consumerJackson2MessageConverter());
     return factory;
}
 
Example 12
Source Project: heimdall   Source File: RabbitConfiguration.java    License: Apache License 2.0 5 votes vote down vote up
@Bean
public DefaultMessageHandlerMethodFactory messageHandlerMethodFactory() {

     DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
     factory.setMessageConverter(consumerJackson2MessageConverter());
     return factory;
}
 
Example 13
@Test
public void validatePayloadValid() throws JMSException {
	String methodName = "validatePayload";

	DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
	customFactory.setValidator(testValidator("invalid value"));
	initializeFactory(customFactory);

	Method method = getListenerMethod(methodName, String.class);
	MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
	Session session = mock(Session.class);
	listener.onMessage(createSimpleJmsTextMessage("test"), session); // test is a valid value
	assertListenerMethodInvocation(sample, methodName);
}
 
Example 14
@Test
public void validatePayloadInvalid() throws JMSException {
	DefaultMessageHandlerMethodFactory customFactory = new DefaultMessageHandlerMethodFactory();
	customFactory.setValidator(testValidator("invalid value"));

	Method method = getListenerMethod("validatePayload", String.class);
	MessagingMessageListenerAdapter listener = createInstance(customFactory, method);
	Session session = mock(Session.class);

	thrown.expect(ListenerExecutionFailedException.class);
	listener.onMessage(createSimpleJmsTextMessage("invalid value"), session); // test is an invalid value

}
 
Example 15
private MessagingMessageListenerAdapter createInstance(
		DefaultMessageHandlerMethodFactory factory, Method method, MessageListenerContainer container) {

	MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
	endpoint.setBean(sample);
	endpoint.setMethod(method);
	endpoint.setMessageHandlerMethodFactory(factory);
	return endpoint.createMessageListener(container);
}
 
Example 16
private MethodJmsListenerEndpoint createMethodJmsEndpoint(DefaultMessageHandlerMethodFactory factory, Method method) {
	MethodJmsListenerEndpoint endpoint = new MethodJmsListenerEndpoint();
	endpoint.setBean(listener);
	endpoint.setMethod(method);
	endpoint.setMessageHandlerMethodFactory(factory);
	return endpoint;
}
 
Example 17
Source Project: spring-analysis-note   Source File: EnableJmsTests.java    License: MIT License 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example 18
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
	factory.setBeanFactory(new StaticListableBeanFactory());
	factory.afterPropertiesSet();
}
 
Example 19
private MessagingMessageListenerAdapter createInstance(DefaultMessageHandlerMethodFactory factory, Method method) {
	return createInstance(factory, method, new SimpleMessageListenerContainer());
}
 
Example 20
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
	factory.setBeanFactory(new StaticListableBeanFactory());
	factory.afterPropertiesSet();
}
 
Example 21
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
	factory.setBeanFactory(new StaticListableBeanFactory());
	factory.afterPropertiesSet();
}
 
Example 22
Source Project: java-technology-stack   Source File: EnableJmsTests.java    License: MIT License 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example 23
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
	factory.setBeanFactory(new StaticListableBeanFactory());
	factory.afterPropertiesSet();
}
 
Example 24
private MessagingMessageListenerAdapter createInstance(DefaultMessageHandlerMethodFactory factory, Method method) {
	return createInstance(factory, method, new SimpleMessageListenerContainer());
}
 
Example 25
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
	factory.setBeanFactory(new StaticListableBeanFactory());
	factory.afterPropertiesSet();
}
 
Example 26
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
	factory.setBeanFactory(new StaticListableBeanFactory());
	factory.afterPropertiesSet();
}
 
Example 27
private MessageHandlerMethodFactory createDefaultJmsHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory defaultFactory = new DefaultMessageHandlerMethodFactory();
	defaultFactory.setBeanFactory(beanFactory);
	defaultFactory.afterPropertiesSet();
	return defaultFactory;
}
 
Example 28
Source Project: spring4-understanding   Source File: EnableJmsTests.java    License: Apache License 2.0 4 votes vote down vote up
@Bean
public MessageHandlerMethodFactory customMessageHandlerMethodFactory() {
	DefaultMessageHandlerMethodFactory factory = new DefaultMessageHandlerMethodFactory();
	factory.setValidator(new TestValidator());
	return factory;
}
 
Example 29
private void initializeFactory(DefaultMessageHandlerMethodFactory factory) {
	factory.setBeanFactory(new StaticListableBeanFactory());
	factory.afterPropertiesSet();
}
 
Example 30
private MessagingMessageListenerAdapter createInstance(DefaultMessageHandlerMethodFactory factory, Method method) {
	return createInstance(factory, method, new SimpleMessageListenerContainer());
}