Search in sources :

Example 1 with SimpleMessageConverter

use of org.springframework.integration.support.converter.SimpleMessageConverter in project spring-integration by spring-projects.

the class SubscribableRedisChannel method onInit.

@Override
public void onInit() throws Exception {
    if (this.initialized) {
        return;
    }
    super.onInit();
    if (this.maxSubscribers == null) {
        Integer maxSubscribers = getIntegrationProperty(IntegrationProperties.CHANNELS_MAX_BROADCAST_SUBSCRIBERS, Integer.class);
        this.setMaxSubscribers(maxSubscribers);
    }
    if (this.messageConverter == null) {
        this.messageConverter = new SimpleMessageConverter();
    }
    if (this.messageConverter instanceof BeanFactoryAware) {
        ((BeanFactoryAware) this.messageConverter).setBeanFactory(this.getBeanFactory());
    }
    this.container.setConnectionFactory(this.connectionFactory);
    if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor)) {
        ErrorHandler errorHandler = new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(this.getBeanFactory()));
        this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, errorHandler);
    }
    this.container.setTaskExecutor(this.taskExecutor);
    MessageListenerAdapter adapter = new MessageListenerAdapter(new MessageListenerDelegate());
    adapter.setSerializer(this.serializer);
    adapter.afterPropertiesSet();
    this.container.addMessageListener(adapter, new ChannelTopic(this.topicName));
    this.container.afterPropertiesSet();
    this.dispatcher.setBeanFactory(this.getBeanFactory());
    this.initialized = true;
}
Also used : MessageListenerAdapter(org.springframework.data.redis.listener.adapter.MessageListenerAdapter) BeanFactoryAware(org.springframework.beans.factory.BeanFactoryAware) MessagePublishingErrorHandler(org.springframework.integration.channel.MessagePublishingErrorHandler) ErrorHandler(org.springframework.util.ErrorHandler) MessagePublishingErrorHandler(org.springframework.integration.channel.MessagePublishingErrorHandler) ChannelTopic(org.springframework.data.redis.listener.ChannelTopic) BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver) SimpleMessageConverter(org.springframework.integration.support.converter.SimpleMessageConverter) ErrorHandlingTaskExecutor(org.springframework.integration.util.ErrorHandlingTaskExecutor)

Aggregations

BeanFactoryAware (org.springframework.beans.factory.BeanFactoryAware)1 ChannelTopic (org.springframework.data.redis.listener.ChannelTopic)1 MessageListenerAdapter (org.springframework.data.redis.listener.adapter.MessageListenerAdapter)1 MessagePublishingErrorHandler (org.springframework.integration.channel.MessagePublishingErrorHandler)1 BeanFactoryChannelResolver (org.springframework.integration.support.channel.BeanFactoryChannelResolver)1 SimpleMessageConverter (org.springframework.integration.support.converter.SimpleMessageConverter)1 ErrorHandlingTaskExecutor (org.springframework.integration.util.ErrorHandlingTaskExecutor)1 ErrorHandler (org.springframework.util.ErrorHandler)1