本文整理汇总了Java中org.springframework.jms.listener.DefaultMessageListenerContainer.setMessageListener方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessageListenerContainer.setMessageListener方法的具体用法?Java DefaultMessageListenerContainer.setMessageListener怎么用?Java DefaultMessageListenerContainer.setMessageListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jms.listener.DefaultMessageListenerContainer
的用法示例。
在下文中一共展示了DefaultMessageListenerContainer.setMessageListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUpClass
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@BeforeClass
public void setUpClass() {
JmsConnector jmsConnector = ActiveMQTestUtils.createTestJmsConnector();
_factory = new JmsSenderFactory(jmsConnector);
_mdd = MarketDataDistributorTest.getTestDistributor(_factory);
_collectingReceiver = new CollectingByteArrayMessageReceiver();
JmsByteArrayMessageDispatcher messageDispatcher = new JmsByteArrayMessageDispatcher(_collectingReceiver);
_container = new DefaultMessageListenerContainer();
_container.setConnectionFactory(jmsConnector.getConnectionFactory());
_container.setMessageListener(messageDispatcher);
_container.setDestinationName(_mdd.getDistributionSpec().getJmsTopic());
_container.setPubSubDomain(true);
_container.afterPropertiesSet();
_container.start();
}
示例2: adminRequestJmsContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@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;
}
示例3: responder
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer responder() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory());
container.setDestinationName("test.out");
MessageListenerAdapter adapter = new MessageListenerAdapter(new Object() {
@SuppressWarnings("unused")
public String handleMessage(String in) {
return in.toUpperCase();
}
});
container.setMessageListener(adapter);
return container;
}
示例4: taskMessageListenerContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
@Autowired
public DefaultMessageListenerContainer taskMessageListenerContainer(JmsExternalCommandListener externalTaskListener
, ConnectionFactory connectionFactory
, ActiveMQQueue taskQueue) {
DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
listenerContainer.setMessageListener(externalTaskListener);
listenerContainer.setDestination(taskQueue);
listenerContainer.setConnectionFactory(connectionFactory);
listenerContainer.setAcceptMessagesWhileStopping(false);
listenerContainer.setSessionTransacted(true);
listenerContainer.setConcurrentConsumers(concurrentConsumers);
listenerContainer.setMaxMessagesPerTask(maxMessagesPerTask);
listenerContainer.setReceiveTimeout(receiveTimeout);
LOG.debug("DefaultMessageListenerContainer for queue [{}] with message selector [{}] was started", listenerContainer.getDestination(), listenerContainer.getMessageSelector());
return listenerContainer;
}
示例5: taskMessageListenerContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
@Autowired
public DefaultMessageListenerContainer taskMessageListenerContainer(JmsExternalTaskListener externalTaskListener
, ConnectionFactory receiverConnectionFactory
, ActiveMQQueue taskQueue) {
DefaultMessageListenerContainer listenerContainer = new DefaultMessageListenerContainer();
listenerContainer.setMessageListener(externalTaskListener);
listenerContainer.setDestination(taskQueue);
listenerContainer.setConnectionFactory(receiverConnectionFactory);
listenerContainer.setAcceptMessagesWhileStopping(false);
listenerContainer.setSessionTransacted(true);
listenerContainer.setConcurrentConsumers(concurrentConsumers);
listenerContainer.setMaxMessagesPerTask(maxMessagesPerTask);
listenerContainer.setReceiveTimeout(receiveTimeout);
return listenerContainer;
}
示例6: clientRequestJmsContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@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;
}
示例7: configRequestJmsContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@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;
}
示例8: subscribe
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
/**
* 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;
}
示例9: messageListener
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer messageListener() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(this.connectionFactory);
container.setDestinationName("testQueue");
container.setMessageListener(new MessageListener() {
@Override
public void onMessage(Message message) {
try {
System.out.println(message.getBody(Object.class));
}
catch (JMSException ex) {
ex.printStackTrace();
}
}
});
return container;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:SampleHornetQApplication.java
示例10: hornetQMessageListenerContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public MessageListenerContainer hornetQMessageListenerContainer() {
Map<String, Object> map = new HashMap<String, Object>();
map.put(TransportConstants.HOST_PROP_NAME, hornetq_host);
map.put(TransportConstants.PORT_PROP_NAME, hornetq_port);
TransportConfiguration transportConfiguration =new TransportConfiguration(
NettyConnectorFactory.class.getName(), map);
HornetQConnectionFactory hornetQConnectionFactory = HornetQJMSClient.createConnectionFactoryWithoutHA(
JMSFactoryType.CF, transportConfiguration);
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory((ConnectionFactory) hornetQConnectionFactory);
container.setDestination(HornetQJMSClient.createTopic(IMConstant.GATEWAY_USERREGISTER_TOPIC));
container.setPubSubDomain(true);
container.setPubSubNoLocal(true);
container.setMessageListener(userRegisterListener);
container.setSessionAcknowledgeMode(Session.AUTO_ACKNOWLEDGE);
return container;
}
示例11: init
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
public void init(ComponentRepository repo, LinkedHashMap<String, String> configuration) throws Exception {
final AnalyticServiceServer server = new AnalyticServiceServer(getViewProcessor(), getPositionMaster(), getPortfolioMaster(), getConfigSource());
server.setUser(getUser());
server.setViewName(getViewName());
server.setProviderIdName(getProviderIdName());
AnalyticServiceTradeProducer tradeProducer = new AnalyticServiceTradeProducer();
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setMessageListener(
new JmsByteArrayMessageDispatcher(
new ByteArrayFudgeMessageReceiver(tradeProducer)));
container.setDestinationName(getListenTopicName());
container.setPubSubDomain(false);
container.setConnectionFactory(getListenJmsConnector().getConnectionFactory());
JmsAnalyticsDistributor analyticsDistributor = new JmsAnalyticsDistributor(new DefaultJmsTopicNameResolver(getPositionSource()), OpenGammaFudgeContext.getInstance(), _listenJmsConnector);
server.setAnalyticResultReceiver(analyticsDistributor);
server.setTradeProducer(tradeProducer);
repo.registerLifecycle(server);
repo.registerLifecycle(container);
}
示例12: startListener
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
public void startListener() {
MessageListenerAdapter messageListenerAdapter = new MessageListenerAdapter();
messageListenerAdapter.setDelegate(this);
messageListenerAdapter.setMessageConverter(mqMessageConverter);
DefaultMessageListenerContainer mqListener = new DefaultMessageListenerContainer();
mqListener.setConnectionFactory(mqConnectionFactory.getFactory());
mqListener.setDestinationName(appConfig.getMqQueueName());
mqListener.setMessageListener(messageListenerAdapter);
mqListener.setConcurrency("4-8");
mqListener.setSessionTransacted(true);
mqListener.initialize();
mqListener.start();
}
示例13: registerMessageListener
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
public void registerMessageListener(MessageListener listener,
String destinationName)
{
log.info("registerMessageListener(" + destinationName + ", " + listener + ")");
container = new DefaultMessageListenerContainer();
container.setConnectionFactory(connectionFactory);
container.setDestinationName(destinationName);
container.setMessageListener(listener);
container.setTaskExecutor(taskExecutor);
container.afterPropertiesSet();
container.start();
listenerContainerMap.put(listener, container);
}
示例14: messageListener
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Bean
public DefaultMessageListenerContainer messageListener() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setConnectionFactory(this.connectionFactory);
container.setDestinationName(queue);
container.setMessageListener(new Consumer());
return container;
}
示例15: mockServerListener
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@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;
}