All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.dell.cpsd.common.rabbitmq.context.builder.ContainerFactory Maven / Gradle / Ivy

The newest version!
/**
 * Copyright © 2017 Dell Inc. or its subsidiaries.  All Rights Reserved.
 * Dell EMC Confidential/Proprietary Information
 */

package com.dell.cpsd.common.rabbitmq.context.builder;

import com.dell.cpsd.common.logging.ILogger;
import com.dell.cpsd.common.rabbitmq.log.RabbitMQLoggingManager;
import com.dell.cpsd.common.rabbitmq.retrypolicy.DefaultRetryPolicyFactory;
import org.aopalliance.aop.Advice;
import org.springframework.amqp.core.AcknowledgeMode;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
import org.springframework.amqp.rabbit.listener.adapter.MessageListenerAdapter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.util.ErrorHandler;

/**
 * 

* Copyright © 2017 Dell Inc. or its subsidiaries. All Rights Reserved. * Dell EMC Confidential/Proprietary Information *

* * @since SINCE-TBD */ public class ContainerFactory { private static final ILogger LOGGER = RabbitMQLoggingManager.getLogger(ContainerFactory.class); public SimpleMessageListenerContainer createDefaultContainer(String containerName, ConnectionFactory connectionFactory, MessageConverter messageConverter, Object messageHandler) { final SimpleMessageListenerContainer container = new SimpleMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setAcknowledgeMode(AcknowledgeMode.AUTO); container.setAdviceChain(new Advice[] {DefaultRetryPolicyFactory.makeContainerListenerRetryPolicy()}); container.setErrorHandler(errorHandler(containerName)); container.setMessageConverter(messageConverter); container.setMessageListener(new MessageListenerAdapter(messageHandler, messageConverter)); return container; } /** * The error handler for the listener container. * * @param listenerName The name of the listener. * @return The error handler for the listener container. * @since 1.0 */ private ErrorHandler errorHandler(final String listenerName) { return new DefaultContainerErrorHandler(listenerName); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy