List of usage examples for org.springframework.jms.listener.adapter MessageListenerAdapter MessageListenerAdapter
public MessageListenerAdapter()
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}./*w w w.j ava 2 s. c om*/ * <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:org.springframework.flex.messaging.jms.JmsAdapter.java
/** * /*from w ww .j a v a 2 s.co m*/ * {@inheritDoc} */ public void afterPropertiesSet() { Assert.notNull(this.connectionFactory, "connectionFactory is required"); Assert.notNull(this.destination, "destination or destination name is required"); this.jmsTemplate.setConnectionFactory(this.connectionFactory); MessageConverter converterToSet = this.messageConverter; if (converterToSet == null || !(converterToSet instanceof FlexMessageConverter)) { converterToSet = new FlexMessageConverter(converterToSet); } this.jmsTemplate.setMessageConverter(converterToSet); MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter(); messageListenerAdapter.setMessageConverter(converterToSet); messageListenerAdapter.setDelegate(this); this.messageListenerContainer.setConnectionFactory(this.connectionFactory); this.messageListenerContainer.setMessageListener(messageListenerAdapter); this.messageListenerContainer.setAutoStartup(false); if (this.destination instanceof Destination) { this.jmsTemplate.setDefaultDestination((Destination) this.destination); this.messageListenerContainer.setDestination((Destination) this.destination); } else { this.jmsTemplate.setPubSubDomain(this.pubSubDomain); this.jmsTemplate.setDefaultDestinationName((String) this.destination); this.messageListenerContainer.setPubSubDomain(this.pubSubDomain); this.messageListenerContainer.setDestinationName((String) this.destination); } this.jmsTemplate.afterPropertiesSet(); this.messageListenerContainer.afterPropertiesSet(); }