本文整理汇总了Java中org.springframework.jms.listener.DefaultMessageListenerContainer.setMaxMessagesPerTask方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessageListenerContainer.setMaxMessagesPerTask方法的具体用法?Java DefaultMessageListenerContainer.setMaxMessagesPerTask怎么用?Java DefaultMessageListenerContainer.setMaxMessagesPerTask使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jms.listener.DefaultMessageListenerContainer
的用法示例。
在下文中一共展示了DefaultMessageListenerContainer.setMaxMessagesPerTask方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: initializeContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
protected void initializeContainer(DefaultMessageListenerContainer container) {
if (this.taskExecutor != null) {
container.setTaskExecutor(this.taskExecutor);
}
if (this.transactionManager != null) {
container.setTransactionManager(this.transactionManager);
}
if (this.cacheLevel != null) {
container.setCacheLevel(this.cacheLevel);
}
else if (this.cacheLevelName != null) {
container.setCacheLevelName(this.cacheLevelName);
}
if (this.concurrency != null) {
container.setConcurrency(this.concurrency);
}
if (this.maxMessagesPerTask != null) {
container.setMaxMessagesPerTask(this.maxMessagesPerTask);
}
if (this.receiveTimeout != null) {
container.setReceiveTimeout(this.receiveTimeout);
}
if (this.backOff != null) {
container.setBackOff(this.backOff);
if (this.recoveryInterval != null) {
logger.warn("Ignoring recovery interval in DefaultJmsListenerContainerFactory in favor of BackOff");
}
}
else if (this.recoveryInterval != null) {
container.setRecoveryInterval(this.recoveryInterval);
}
}
示例7: serverRequestListenerContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@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;
}
示例8: secondServerRequestListenerContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@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;
}
示例9: configureDefaultMessageListenerContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
private void configureDefaultMessageListenerContainer(JmsEndpoint endpoint, DefaultMessageListenerContainer container) {
if (concurrentConsumers >= 0) {
container.setConcurrentConsumers(concurrentConsumers);
}
if (cacheLevel >= 0) {
container.setCacheLevel(cacheLevel);
} else if (cacheLevelName != null) {
container.setCacheLevelName(cacheLevelName);
} else {
container.setCacheLevel(defaultCacheLevel(endpoint));
}
if (idleTaskExecutionLimit >= 0) {
container.setIdleTaskExecutionLimit(idleTaskExecutionLimit);
}
if (idleConsumerLimit >= 0) {
container.setIdleConsumerLimit(idleConsumerLimit);
}
if (maxConcurrentConsumers > 0) {
if (maxConcurrentConsumers < concurrentConsumers) {
throw new IllegalArgumentException("Property maxConcurrentConsumers: " + maxConcurrentConsumers
+ " must be higher than concurrentConsumers: " + concurrentConsumers);
}
container.setMaxConcurrentConsumers(maxConcurrentConsumers);
}
if (maxMessagesPerTask >= 0) {
container.setMaxMessagesPerTask(maxMessagesPerTask);
}
container.setPubSubNoLocal(pubSubNoLocal);
if (receiveTimeout >= 0) {
container.setReceiveTimeout(receiveTimeout);
}
if (recoveryInterval >= 0) {
container.setRecoveryInterval(recoveryInterval);
}
if (taskExecutor != null) {
container.setTaskExecutor(taskExecutor);
}
PlatformTransactionManager tm = getTransactionManager();
if (tm != null) {
container.setTransactionManager(tm);
} else if (transactionManager == null && transacted && !lazyCreateTransactionManager) {
container.setSessionTransacted(true);
}
if (transactionName != null) {
container.setTransactionName(transactionName);
}
if (transactionTimeout >= 0) {
container.setTransactionTimeout(transactionTimeout);
}
}
示例10: createListenerContainer
import org.springframework.jms.listener.DefaultMessageListenerContainer; //导入方法依赖的package包/类
@Override
protected AbstractMessageListenerContainer createListenerContainer() throws Exception {
// Use DefaultMessageListenerContainer as it supports reconnects (see CAMEL-3193)
DefaultMessageListenerContainer answer = new DefaultJmsMessageListenerContainer(endpoint, endpoint.isAllowReplyManagerQuickStop());
answer.setDestinationName("temporary");
answer.setDestinationResolver(destResolver);
answer.setAutoStartup(true);
if (endpoint.getMaxMessagesPerTask() >= 0) {
answer.setMaxMessagesPerTask(endpoint.getMaxMessagesPerTask());
}
answer.setIdleConsumerLimit(endpoint.getIdleConsumerLimit());
answer.setIdleTaskExecutionLimit(endpoint.getIdleTaskExecutionLimit());
answer.setMessageListener(this);
answer.setPubSubDomain(false);
answer.setSubscriptionDurable(false);
answer.setConcurrentConsumers(endpoint.getReplyToConcurrentConsumers());
if (endpoint.getReplyToMaxConcurrentConsumers() > 0) {
answer.setMaxConcurrentConsumers(endpoint.getReplyToMaxConcurrentConsumers());
}
answer.setConnectionFactory(endpoint.getConnectionFactory());
// we use CACHE_CONSUMER by default to cling to the consumer as long as we can, since we can only consume
// msgs from the JMS Connection that created the temp destination in the first place
if (endpoint.getReplyToCacheLevelName() != null) {
if ("CACHE_NONE".equals(endpoint.getReplyToCacheLevelName())) {
throw new IllegalArgumentException("ReplyToCacheLevelName cannot be CACHE_NONE when using temporary reply queues. The value must be either CACHE_CONSUMER, or CACHE_SESSION");
}
answer.setCacheLevelName(endpoint.getReplyToCacheLevelName());
} else {
answer.setCacheLevel(DefaultMessageListenerContainer.CACHE_CONSUMER);
}
String clientId = endpoint.getClientId();
if (clientId != null) {
clientId += ".CamelReplyManager";
answer.setClientId(clientId);
}
// we cannot do request-reply over JMS with transaction
answer.setSessionTransacted(false);
// other optional properties
answer.setExceptionListener(new TemporaryReplyQueueExceptionListener(destResolver, endpoint.getExceptionListener()));
if (endpoint.getErrorHandler() != null) {
answer.setErrorHandler(endpoint.getErrorHandler());
} else {
answer.setErrorHandler(new DefaultSpringErrorHandler(endpoint.getCamelContext(), TemporaryQueueReplyManager.class,
endpoint.getErrorHandlerLoggingLevel(), endpoint.isErrorHandlerLogStackTrace()));
}
if (endpoint.getReceiveTimeout() >= 0) {
answer.setReceiveTimeout(endpoint.getReceiveTimeout());
}
if (endpoint.getRecoveryInterval() >= 0) {
answer.setRecoveryInterval(endpoint.getRecoveryInterval());
}
if (endpoint.getTaskExecutor() != null) {
if (log.isDebugEnabled()) {
log.debug("Using custom TaskExecutor: {} on listener container: {}", endpoint.getTaskExecutor(), answer);
}
answer.setTaskExecutor(endpoint.getTaskExecutor());
}
// setup a bean name which is used by Spring JMS as the thread name
// use the name of the request destination
String name = "TemporaryQueueReplyManager[" + endpoint.getDestinationName() + "]";
answer.setBeanName(name);
if (answer.getConcurrentConsumers() > 1) {
// log that we are using concurrent consumers
log.info("Using {}-{} concurrent consumers on {}",
new Object[]{answer.getConcurrentConsumers(), answer.getMaxConcurrentConsumers(), name});
}
return answer;
}