Search in sources :

Example 11 with MessagePublishingErrorHandler

use of org.springframework.integration.channel.MessagePublishingErrorHandler in project spring-integration by spring-projects.

the class RedisQueueMessageDrivenEndpoint method onInit.

@Override
protected void onInit() {
    super.onInit();
    if (this.expectMessage) {
        Assert.notNull(this.serializer, "'serializer' has to be provided where 'expectMessage == true'.");
    }
    if (this.taskExecutor == null) {
        String beanName = this.getComponentName();
        this.taskExecutor = new SimpleAsyncTaskExecutor((beanName == null ? "" : beanName + "-") + this.getComponentType());
    }
    if (!(this.taskExecutor instanceof ErrorHandlingTaskExecutor) && this.getBeanFactory() != null) {
        MessagePublishingErrorHandler errorHandler = new MessagePublishingErrorHandler(new BeanFactoryChannelResolver(this.getBeanFactory()));
        errorHandler.setDefaultErrorChannel(this.errorChannel);
        this.taskExecutor = new ErrorHandlingTaskExecutor(this.taskExecutor, errorHandler);
    }
}
Also used : MessagePublishingErrorHandler(org.springframework.integration.channel.MessagePublishingErrorHandler) SimpleAsyncTaskExecutor(org.springframework.core.task.SimpleAsyncTaskExecutor) BeanFactoryChannelResolver(org.springframework.integration.support.channel.BeanFactoryChannelResolver) ErrorHandlingTaskExecutor(org.springframework.integration.util.ErrorHandlingTaskExecutor)

Example 12 with MessagePublishingErrorHandler

use of org.springframework.integration.channel.MessagePublishingErrorHandler 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

MessagePublishingErrorHandler (org.springframework.integration.channel.MessagePublishingErrorHandler)12 BeanFactoryChannelResolver (org.springframework.integration.support.channel.BeanFactoryChannelResolver)5 Test (org.junit.Test)4 ErrorHandlingTaskExecutor (org.springframework.integration.util.ErrorHandlingTaskExecutor)4 DirectChannel (org.springframework.integration.channel.DirectChannel)3 MessageDeliveryException (org.springframework.messaging.MessageDeliveryException)3 StaticApplicationContext (org.springframework.context.support.StaticApplicationContext)2 SimpleAsyncTaskExecutor (org.springframework.core.task.SimpleAsyncTaskExecutor)2 SourcePollingChannelAdapter (org.springframework.integration.endpoint.SourcePollingChannelAdapter)2 MessagingException (org.springframework.messaging.MessagingException)2 CountDownLatch (java.util.concurrent.CountDownLatch)1 Log (org.apache.commons.logging.Log)1 DirectFieldAccessor (org.springframework.beans.DirectFieldAccessor)1 BeanFactory (org.springframework.beans.factory.BeanFactory)1 BeanFactoryAware (org.springframework.beans.factory.BeanFactoryAware)1 BeanInitializationException (org.springframework.beans.factory.BeanInitializationException)1 TaskExecutor (org.springframework.core.task.TaskExecutor)1 ChannelTopic (org.springframework.data.redis.listener.ChannelTopic)1 MessageListenerAdapter (org.springframework.data.redis.listener.adapter.MessageListenerAdapter)1 Poller (org.springframework.integration.annotation.Poller)1