当前位置: 首页>>代码示例>>Java>>正文


Java DefaultMessageListenerContainer.setMaxMessagesPerTask方法代码示例

本文整理汇总了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;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:22,代码来源:AdminJmsConfig.java

示例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;
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:19,代码来源:JmsExternalCommandListenerConfig.java

示例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;
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:18,代码来源:JmsExternalTaskReceiverConfig.java

示例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;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:22,代码来源:ClientJmsConfig.java

示例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;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:29,代码来源:JmsContainerManagerImpl.java

示例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);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:37,代码来源:DefaultJmsListenerContainerFactory.java

示例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;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:13,代码来源:JmsConfig.java

示例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;
}
 
开发者ID:c2mon,项目名称:c2mon,代码行数:13,代码来源:JmsConfig.java

示例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);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:53,代码来源:JmsConfiguration.java

示例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;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:75,代码来源:TemporaryQueueReplyManager.java


注:本文中的org.springframework.jms.listener.DefaultMessageListenerContainer.setMaxMessagesPerTask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。