Example usage for org.springframework.jms.listener DefaultMessageListenerContainer setDestinationName

List of usage examples for org.springframework.jms.listener DefaultMessageListenerContainer setDestinationName

Introduction

In this page you can find the example usage for org.springframework.jms.listener DefaultMessageListenerContainer setDestinationName.

Prototype

public void setDestinationName(@Nullable String destinationName) 

Source Link

Document

Set the name of the destination to receive messages from.

Usage

From source file:com.rabbitmq.jms.sample.StockConsumer.java

@Bean
public DefaultMessageListenerContainer jmsListener(ConnectionFactory connectionFactory) {

    log.info("connectionFactory => " + connectionFactory);

    DefaultMessageListenerContainer jmsListener = new DefaultMessageListenerContainer();
    jmsListener.setConnectionFactory(connectionFactory);
    jmsListener.setDestinationName("rabbit-trader-channel");
    jmsListener.setPubSubDomain(false);/*www. ja  v a  2s.c o  m*/

    MessageListenerAdapter adapter = new MessageListenerAdapter(new Receiver());
    adapter.setDefaultListenerMethod("receive");

    jmsListener.setMessageListener(adapter);
    return jmsListener;
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.batch.config.DeleteMsgConfiguration.java

@Bean
DefaultMessageListenerContainer deleteContainer(MessageListenerAdapter deleteListenerAdapter,
        ConnectionFactory connectionFactory) {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setMessageListener(deleteListenerAdapter);
    container.setConnectionFactory(connectionFactory);
    container.setDestinationName(deleteDocumentsQueueName);
    return container;
}

From source file:uk.gov.nationalarchives.discovery.taxonomy.batch.config.CategorisationMsgConfiguration.java

@Bean
DefaultMessageListenerContainer categorisationContainer(MessageListenerAdapter categorisationListenerAdapter,
        ConnectionFactory connectionFactory) {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setMessageListener(categorisationListenerAdapter);
    container.setConnectionFactory(connectionFactory);
    container.setDestinationName(categoriseDocumentsQueueName);
    return container;
}

From source file:com.jim.im.config.GenericMQConfig.java

/**
 * ???//from   w  ww  .j a va 2 s  . c om
 *
 * @param queueName ??
 * @param rpcServiceExport ??
 * @return
 */
protected MessageListenerContainer buildListenerContainer(JmsInvokerServiceExporter rpcServiceExport,
        String queueName) {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(jmsConnectionFactory());
    container.setDestinationName(queueName);
    container.setMessageConverter(messageConverter());
    container.setMessageListener(rpcServiceExport);
    container.setConcurrentConsumers(Runtime.getRuntime().availableProcessors());
    return container;
}

From source file:com.jim.im.config.GenericMQConfig.java

/**
 * ?????,MQ???//from w w w.ja v a2s . c  om
 *
 * @param topicName
 * @param messageListener
 * @return
 */
public MessageListenerContainer mqMessageReceiver(String topicName, MessageListener messageListener) {
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(jmsConnectionFactory());
    container.setDestinationName(topicName);
    container.setPubSubDomain(true);
    container.setPubSubNoLocal(true);
    container.setMessageListener(messageListener);
    container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
    return container;
}

From source file:org.apigw.monitoring.config.JmsConfig.java

@Bean
DefaultMessageListenerContainer container(MessageListener messageListener,
        ConnectionFactory connectionFactory) {
    log.debug(String.format("Setting up DefaultMessageListenerContainer for destination: %s",
            monitoringDestination));/*  ww w.  jav a2 s . c om*/
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setMessageListener(messageListener);
    container.setConnectionFactory(connectionFactory);
    container.setDestinationName(monitoringDestination);
    container.setSessionTransacted(true); //Setting this flag to "true" will use a short local JMS transaction when running outside of a managed transaction.
    return container;
}

From source file:com.athena.dolly.common.core.ActiveMQPlaygroundConfiguration.java

@Bean
public AbstractMessageListenerContainer listenerContainer() {
    final DefaultMessageListenerContainer defaultMessageListenerContainer = new DefaultMessageListenerContainer();
    defaultMessageListenerContainer.setConnectionFactory(connectionFactory());
    defaultMessageListenerContainer.setConcurrency(listenerContainerConcurrency);
    defaultMessageListenerContainer.setDestinationName(queueName);
    defaultMessageListenerContainer.setMessageListener(queueListener());
    return defaultMessageListenerContainer;
}

From source file:org.nebulaframework.grid.cluster.manager.services.jobs.splitaggregate.AggregatorServiceImpl.java

/**
 * Internal method which handles the aggregator start-up for 
 * a given {@code GridJobProfile}./*from  www  .  ja  v  a  2  s  .co  m*/
 * <p>
 * Creates and starts a {@code ResultCollector} instance for
 * the given {@code GridJob}, and also creates necessary JMS message
 * handling infrastructure.
 * 
 * @param profile {@code GridJobProfile} jobProfile
 */
protected void doStartAggregator(GridJobProfile profile, SplitAggregateJobManager manager) {

    // Create Message Listener Adapter and Result Collector for Job
    MessageListenerAdapter adapter = new MessageListenerAdapter();
    adapter.setDefaultListenerMethod("onResult");

    // Create JMS Message Listener Container
    DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
    container.setConnectionFactory(connectionFactory);
    container.setDestinationName(JMSNamingSupport.getResultQueueName(profile.getJobId()));
    container.setMessageListener(adapter);

    //Create results collector and set it as Execution Manager
    ResultCollector collector = new ResultCollector(profile, manager, container);
    profile.setExecutionManager(manager);
    manager.addResultCollector(profile.getJobId(), collector);

    // Initialize Adapter and Container
    adapter.setDelegate(collector);
    container.afterPropertiesSet();
}

From source file:terrastore.event.impl.ActiveMQEventBus.java

private void createConsumer(Event event) {
    String queueName = TERRASTORE_QUEUE_PREFIX + event.getBucket();
    if (!consumers.containsKey(queueName)) {
        stateLock.lock();// w ww.  ja v  a 2 s  . co m
        try {
            if (!shutdown && !consumers.containsKey(queueName)) {
                DefaultMessageListenerContainer consumer = new DefaultMessageListenerContainer();
                consumer.setConnectionFactory(jmsConnectionFactory);
                consumer.setSessionTransacted(true);
                consumer.setMessageListener(new EventProcessor(eventListeners, actionExecutor));
                consumer.setDestinationName(queueName);
                consumer.start();
                consumer.initialize();
                consumers.put(queueName, consumer);
            }
        } finally {
            stateLock.unlock();
        }
    }
}

From source file:terrastore.event.impl.ActiveMQEventBus.java

private void initConsumers(String broker) throws Exception {
    ActiveMQConnection connection = null;
    DestinationSource destinations = null;
    try {/*  www  .  j a  va 2 s  . co m*/
        connection = ActiveMQConnection.makeConnection(broker);
        connection.start();
        //
        destinations = connection.getDestinationSource();
        destinations.start();
        //
        Set<ActiveMQQueue> queues = destinations.getQueues();
        for (ActiveMQQueue queue : queues) {
            if (queue.getQueueName().startsWith(TERRASTORE_QUEUE_PREFIX)) {
                LOG.info("Listening to queue: {}", queue.getQueueName());
                DefaultMessageListenerContainer consumer = new DefaultMessageListenerContainer();
                consumer.setConnectionFactory(jmsConnectionFactory);
                consumer.setSessionTransacted(true);
                consumer.setMessageListener(new EventProcessor(eventListeners, actionExecutor));
                consumer.setDestinationName(queue.getQueueName());
                consumer.start();
                consumer.initialize();
                consumers.put(queue.getQueueName(), consumer);
            }
        }
    } finally {
        if (destinations != null) {
            destinations.stop();
        }
        if (connection != null) {
            connection.stop();
            connection.close();
        }
    }
}