Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package id.co.sofcograha.gajiidapi.base.process;
- import java.util.List;
- import javax.jms.ConnectionFactory;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.ApplicationContext;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.jms.annotation.EnableJms;
- import org.springframework.jms.annotation.JmsListenerConfigurer;
- import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
- import org.springframework.jms.config.JmsListenerEndpointRegistrar;
- import org.springframework.jms.config.SimpleJmsListenerEndpoint;
- import org.springframework.util.ErrorHandler;
- @EnableJms
- @Configuration
- public class JMSConfiguration implements JmsListenerConfigurer {
- private final Logger logger = LoggerFactory.getLogger(this.getClass());
- @Autowired
- private ConnectionFactory connectionFactory;
- @Autowired
- private QueueUtilService queueUtilService;
- @Autowired
- private ApplicationContext applicationContext;
- @Bean
- public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
- DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
- // factory.setConnectionFactory(connectionFactory);
- // factory.setErrorHandler(new JMSErrorHandler());
- // factory.setDestinationResolver(destinationResolver());
- // factory.setSessionTransacted(true);
- // factory.setConcurrency("1");
- return factory;
- }
- @Override
- public void configureJmsListeners(JmsListenerEndpointRegistrar registrar) {
- // List<String> listActiveQueueDestination = queueUtilService.getListActiveQueueDestination();
- // for (String queueDestination : listActiveQueueDestination) {
- // SimpleJmsListenerEndpoint endpoint = new SimpleJmsListenerEndpoint();
- // endpoint.setId(queueDestination + "_ID");
- // endpoint.setDestination(queueDestination);
- // endpoint.setMessageListener(new QueueDefaultConsumer(queueUtilService, applicationContext));
- //
- // registrar.registerEndpoint(endpoint);
- // }
- }
- public class JMSErrorHandler implements ErrorHandler {
- @Override
- public void handleError(Throwable t) {
- logger.error("Queue ERROR", t);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment