Java Code Examples for org.springframework.jms.listener.DefaultMessageListenerContainer#setConnectionFactory()
The following examples show how to use
org.springframework.jms.listener.DefaultMessageListenerContainer#setConnectionFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdminJmsConfig.java From c2mon with GNU Lesser General Public License v3.0 | 7 votes |
@Bean public DefaultMessageListenerContainer adminRequestJmsContainer(ClientRequestDelegator delegator, ClientRequestErrorHandler errorHandler) { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); String adminRequestQueue = properties.getJms().getAdminRequestQueue(); container.setDestination(new ActiveMQQueue(adminRequestQueue)); container.setConnectionFactory(adminSingleConnectionFactory()); container.setMessageListener(delegator); container.setConcurrentConsumers(1); container.setMaxConcurrentConsumers(2); container.setMaxMessagesPerTask(1); container.setReceiveTimeout(1000); container.setIdleTaskExecutionLimit(600); container.setSessionTransacted(false); container.setTaskExecutor(clientExecutor); container.setErrorHandler(errorHandler); container.setAutoStartup(false); container.setPhase(ServerConstants.PHASE_INTERMEDIATE); return container; }
Example 2
Source File: JmsContainerManagerImpl.java From c2mon with GNU Lesser General Public License v3.0 | 6 votes |
/** * Returns the container so that it can be started manually when added during * server runtime. * @param process the Process to create a container for * @param consumersMax the max number of consumers (at start-up subscribe with less) * @return the JMS container that was created */ private DefaultMessageListenerContainer subscribe(final Process process, final int consumersMax) { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(updateConnectionFactory); container.setDestination(new ActiveMQQueue(properties.getJms().getQueuePrefix() + ".update." + process.getName())); container.setMessageListener(listener); container.setConcurrentConsumers(properties.getJms().getUpdate().getInitialConsumers()); container.setMaxConcurrentConsumers(consumersMax); container.setSessionTransacted(properties.getJms().getUpdate().isTransacted()); container.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER); container.setAutoStartup(false); container.setPhase(ServerConstants.PHASE_START_LAST); container.setMaxMessagesPerTask(properties.getJms().getUpdate().getMaxMessagesPerTask()); container.setReceiveTimeout(properties.getJms().getUpdate().getReceiveTimeout()); container.setIdleTaskExecutionLimit(properties.getJms().getUpdate().getIdleTaskExecutionLimit()); container.setBeanName(process.getName() + " update JMS container"); container.setTaskExecutor(daqThreadPoolTaskExecutor); container.setAcceptMessagesWhileStopping(false); jmsContainers.put(process.getId(), container); container.initialize(); return container; }
Example 3
Source File: ConfigRequestJmsConfig.java From c2mon with GNU Lesser General Public License v3.0 | 6 votes |
@Bean public DefaultMessageListenerContainer configRequestJmsContainer(ConfigurationRequestHandler requestHandler) { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); String configRequestQueue = properties.getJms().getConfigRequestQueue(); container.setDestination(new ActiveMQQueue(configRequestQueue)); container.setConnectionFactory(clientSingleConnectionFactory); container.setMessageListener(requestHandler); container.setConcurrentConsumers(1); container.setMaxConcurrentConsumers(1); container.setSessionTransacted(false); container.setTaskExecutor(clientExecutor); container.setPhase(ServerConstants.PHASE_START_LAST); return container; }
Example 4
Source File: ClientJmsConfig.java From c2mon with GNU Lesser General Public License v3.0 | 6 votes |
@Bean public DefaultMessageListenerContainer clientRequestJmsContainer(ClientRequestDelegator delegator, ClientRequestErrorHandler errorHandler) { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); String clientRequestQueue = properties.getJms().getRequestQueue(); container.setDestination(new ActiveMQQueue(clientRequestQueue)); container.setConnectionFactory(clientSingleConnectionFactory()); container.setMessageListener(delegator); container.setConcurrentConsumers(properties.getJms().getInitialConsumers()); container.setMaxConcurrentConsumers(properties.getJms().getMaxConsumers()); container.setMaxMessagesPerTask(1); container.setReceiveTimeout(1000); container.setIdleTaskExecutionLimit(600); container.setSessionTransacted(false); container.setTaskExecutor(clientExecutor()); container.setErrorHandler(errorHandler); container.setAutoStartup(false); container.setPhase(ServerConstants.PHASE_INTERMEDIATE); return container; }
Example 5
Source File: MessagingConfig.java From pro-spring-boot with Apache License 2.0 | 5 votes |
@Bean public DefaultMessageListenerContainer messageListener() { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(this.connectionFactory); container.setDestinationName(queue); container.setMessageListener(new Consumer()); return container; }
Example 6
Source File: JmsConsumerConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public DefaultMessageListenerContainer containerListener() { DefaultMessageListenerContainer listener = new DefaultMessageListenerContainer(); listener.setConnectionFactory(jmsCommonConfig.connectionFactory()); listener.setDestination(jmsCommonConfig.userQueue()); listener.setMessageListener(userReceiver()); return listener; }
Example 7
Source File: MQHierachy.java From Thunder with Apache License 2.0 | 5 votes |
public void listen(Destination destination, SessionAwareMessageListener<BytesMessage> messageListener, String requestSelector, boolean topic) throws Exception { int concurrentConsumers = mqPropertyEntity.getInteger(ThunderConstant.MQ_CONCURRENT_CONSUMERS_ATTRIBUTE_NAME); int maxConcurrentConsumers = mqPropertyEntity.getInteger(ThunderConstant.MQ_MAX_CONCURRENT_CONSUMERS_ATTRIBUTE_NAME); long receiveTimeout = mqPropertyEntity.getLong(ThunderConstant.MQ_RECEIVE_TIMEOUT_ATTRIBUTE_NAME); long recoveryInterval = mqPropertyEntity.getLong(ThunderConstant.MQ_RECOVERY_INTERVAL_ATTRIBUTE_NAME); int idleConsumerLimit = mqPropertyEntity.getInteger(ThunderConstant.MQ_IDLE_CONSUMER_LIMIT_ATTRIBUTE_NAME); int idleTaskExecutionLimit = mqPropertyEntity.getInteger(ThunderConstant.MQ_IDLE_TASK_EXECUTION_LIMIT_ATTRIBUTE_NAME); int cacheLevel = mqPropertyEntity.getInteger(ThunderConstant.MQ_CACHE_LEVEL_ATTRIBUTE_NAME); boolean acceptMessagesWhileStopping = mqPropertyEntity.getBoolean(ThunderConstant.MQ_ACCEPT_MESSAGES_WHILE_STOPPING_ATTRIBUTE_NAME); MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter(); messageListenerAdapter.setDelegate(messageListener); DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer(); messageListenerContainer.setDestination(destination); messageListenerContainer.setConnectionFactory(connectionFactory); messageListenerContainer.setMessageListener(messageListenerAdapter); if (StringUtils.isNotEmpty(requestSelector)) { messageListenerContainer.setMessageSelector(SelectorType.REQUEST_SELECTOR + " = '" + requestSelector + "'"); } messageListenerContainer.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE); messageListenerContainer.setPubSubDomain(topic); messageListenerContainer.setConcurrentConsumers(topic ? 1 : concurrentConsumers); messageListenerContainer.setMaxConcurrentConsumers(topic ? 1 : maxConcurrentConsumers); messageListenerContainer.setReceiveTimeout(receiveTimeout); messageListenerContainer.setRecoveryInterval(recoveryInterval); messageListenerContainer.setIdleConsumerLimit(idleConsumerLimit); messageListenerContainer.setIdleTaskExecutionLimit(idleTaskExecutionLimit); messageListenerContainer.setCacheLevel(cacheLevel); messageListenerContainer.setAcceptMessagesWhileStopping(acceptMessagesWhileStopping); messageListenerContainer.afterPropertiesSet(); messageListenerContainer.start(); }
Example 8
Source File: StubRunnerJmsConfiguration.java From spring-cloud-contract with Apache License 2.0 | 5 votes |
private MessageListenerContainer listenerContainer(String queueName, ConnectionFactory connectionFactory, MessageListener listener) { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setDestinationName(queueName); container.setMessageListener(listener); return container; }
Example 9
Source File: JmsConfig.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public DefaultMessageListenerContainer secondServerRequestListenerContainer() { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(secondSingleConnectionFactory()); container.setDestinationName("replaced-at-runtime"); container.setSessionTransacted(false); container.setMaxMessagesPerTask(1); container.setReceiveTimeout(1000); container.setIdleTaskExecutionLimit(10); container.setAutoStartup(false); return container; }
Example 10
Source File: JmsConfig.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public DefaultMessageListenerContainer serverRequestListenerContainer() { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(singleConnectionFactory()); container.setDestinationName("replaced-at-runtime"); container.setSessionTransacted(false); container.setMaxMessagesPerTask(1); container.setReceiveTimeout(1000); container.setIdleTaskExecutionLimit(10); container.setAutoStartup(false); return container; }
Example 11
Source File: DaqJmsConfig.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public DefaultMessageListenerContainer requestJmsContainer(ProcessRequestHandlerImpl processRequestHandler) { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(daqInConnectionFactory()); container.setDestination(new ActiveMQQueue(properties.getJms().getQueuePrefix() + ".request")); container.setMessageListener(processRequestHandler); container.setConcurrentConsumers(properties.getJms().getRequest().getInitialConsumers()); container.setMaxConcurrentConsumers(properties.getJms().getRequest().getMaxConsumers()); container.setSessionTransacted(properties.getJms().getRequest().isTransacted()); container.setPhase(ServerConstants.PHASE_START_LAST); container.setBeanName("Process request JMS container"); return container; }
Example 12
Source File: MockServerConfig.java From c2mon with GNU Lesser General Public License v3.0 | 5 votes |
@Bean public MessageListenerContainer mockServerListener(ActiveMQConnectionFactory connectionFactory) { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(connectionFactory); container.setDestination(new ActiveMQQueue("c2mon.client.request")); container.setMessageListener((SessionAwareMessageListener) (message, session) -> { session.createProducer(message.getJMSReplyTo()).send(session.createTextMessage("[]")); }); return container; }
Example 13
Source File: MessagingConfig.java From pro-spring-boot with Apache License 2.0 | 5 votes |
@Bean public DefaultMessageListenerContainer messageListener() { DefaultMessageListenerContainer container = new DefaultMessageListenerContainer(); container.setConnectionFactory(this.connectionFactory); container.setDestinationName(queue); container.setMessageListener(new Consumer()); return container; }
Example 14
Source File: ActiveMqListenerConfig.java From roncoo-pay with Apache License 2.0 | 5 votes |
/** * 消息监听容器 * * @param singleConnectionFactory 连接工厂 * @param orderQueryQueueDestination 消息目的地 * @param pollingMessageListener 监听器实现 * @return 消息监听容器 */ @Bean(name = "orderQueryQueueMessageListenerContainer") public DefaultMessageListenerContainer orderQueryQueueMessageListenerContainer(@Qualifier("connectionFactory") SingleConnectionFactory singleConnectionFactory, @Qualifier("orderQueryQueueDestination") ActiveMQQueue orderQueryQueueDestination, @Qualifier("pollingMessageListener") PollingMessageListener pollingMessageListener) { DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer(); messageListenerContainer.setConnectionFactory(singleConnectionFactory); messageListenerContainer.setDestination(orderQueryQueueDestination); messageListenerContainer.setMessageListener(pollingMessageListener); return messageListenerContainer; }
Example 15
Source File: ActiveMqListenerConfig.java From roncoo-pay with Apache License 2.0 | 5 votes |
/** * 消息监听容器 * * @param singleConnectionFactory 连接工厂 * @param tradeQueueDestination 消息目的地 * @param consumerSessionAwareMessageListener 监听器实现 * @return 消息监听容器 */ @Bean(name = "tradeQueueMessageListenerContainer") public DefaultMessageListenerContainer tradeQueueMessageListenerContainer(@Qualifier("connectionFactory") SingleConnectionFactory singleConnectionFactory, @Qualifier("tradeQueueDestination") ActiveMQQueue tradeQueueDestination, @Qualifier("consumerSessionAwareMessageListener") ConsumerSessionAwareMessageListener consumerSessionAwareMessageListener) { DefaultMessageListenerContainer messageListenerContainer = new DefaultMessageListenerContainer(); messageListenerContainer.setConnectionFactory(singleConnectionFactory); messageListenerContainer.setMessageListener(consumerSessionAwareMessageListener); messageListenerContainer.setDestination(tradeQueueDestination); return messageListenerContainer; }
Example 16
Source File: SolaceController.java From solace-samples-cloudfoundry-java with Apache License 2.0 | 5 votes |
public DefaultMessageListenerContainer createListener(String destination) { // do something here to create a message listener container DefaultMessageListenerContainer lc = new DefaultMessageListenerContainer(); lc.setConnectionFactory((ConnectionFactory) connectionFactory.getObject()); lc.setDestinationResolver(jndiDestinationResolver); lc.setDestinationName(destination); lc.setMessageListener(new SimpleMessageListener()); lc.setPubSubDomain(true); lc.initialize(); return lc; }
Example 17
Source File: SolaceController.java From solace-samples-cloudfoundry-java with Apache License 2.0 | 5 votes |
public DefaultMessageListenerContainer createListener(String destination) { // do something here to create a message listener container DefaultMessageListenerContainer lc = new DefaultMessageListenerContainer(); lc.setConnectionFactory(connectionFactory); lc.setDestinationName(destination); lc.setMessageListener(new SimpleMessageListener()); lc.setPubSubDomain(true); lc.initialize(); return lc; }
Example 18
Source File: AbstractConsumer.java From jim-framework with Apache License 2.0 | 5 votes |
public void afterPropertiesSet() { if(this.consumerConfig.getBrokerUrlList() != null && !this.consumerConfig.getBrokerUrlList().isEmpty() && !Strings.isNullOrEmpty(this.consumerConfig.getQueueName())) { for(String brokerUrl : this.consumerConfig.getBrokerUrlList()) { //ConnectionFactory connectionFactory = ConnectionFactoryContainer.getSingleConsumerConnectionFactory(brokerUrl); ConnectionFactory connectionFactory = ConnectionFactoryContainer.getConsumerConnectionFactory(brokerUrl); if (this.listenerContainerMap.containsKey(connectionFactory)) { continue; } DefaultMessageListenerContainer defaultMessageListenerContainer = new DefaultMessageListenerContainer(); defaultMessageListenerContainer.setCacheLevel(this.consumerConfig.getCacheLevel()); defaultMessageListenerContainer.setConcurrentConsumers(this.consumerConfig.getConcurrentConsumers()); ActiveMQQueue activeMQQueue = new ActiveMQQueue(); activeMQQueue.setPhysicalName(this.consumerConfig.getQueueName()); if(this.consumerConfig.getAcknowledgemode() < 0 || this.consumerConfig.getAcknowledgemode() > 4) { this.consumerConfig.setAcknowledgemode( Session.AUTO_ACKNOWLEDGE); } if(this.consumerConfig.getAcknowledgemode() == Session.SESSION_TRANSACTED) { defaultMessageListenerContainer.setSessionTransacted(true); } defaultMessageListenerContainer.setSessionAcknowledgeMode(this.consumerConfig.getAcknowledgemode()); defaultMessageListenerContainer.setConnectionFactory(connectionFactory); defaultMessageListenerContainer.setDestination(activeMQQueue); defaultMessageListenerContainer.setMessageListener(this); defaultMessageListenerContainer.initialize(); defaultMessageListenerContainer.start(); this.listenerContainerMap.put(connectionFactory, defaultMessageListenerContainer); } } }
Example 19
Source File: JmsProducerConfig.java From Spring with Apache License 2.0 | 5 votes |
@Bean public DefaultMessageListenerContainer containerListener() { final DefaultMessageListenerContainer listener = new DefaultMessageListenerContainer(); listener.setConnectionFactory(jmsCommonConfig.connectionFactory()); listener.setDestination(jmsCommonConfig.confirmationQueue()); listener.setMessageListener(confirmationReceiver()); return listener; }