Java Code Examples for org.springframework.jms.config.DefaultJmsListenerContainerFactory#setConcurrency()

The following examples show how to use org.springframework.jms.config.DefaultJmsListenerContainerFactory#setConcurrency() . 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: JMSConfig.java    From ElementVueSpringbootCodeTemplate with Apache License 2.0 6 votes vote down vote up
@Bean
public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory,
		DefaultJmsListenerContainerFactoryConfigurer configurer) {
	DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
	// This provides all boot's default to this factory, including the message
	// converter
	configurer.configure(factory, connectionFactory);

	// You could still override some of Boot's default if necessary.

	// 设置连接数
	factory.setConcurrency("3-10");
	// 重连间隔时间
	factory.setRecoveryInterval(1000L);

	return factory;
}
 
Example 2
Source File: ServiceSpringModuleConfig.java    From herd with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a JMS listener container factory that can return a JMS listener container.
 *
 * @param jmsConnectionFactory the JMS connection factory
 *
 * @return the JMS listener container factory
 */
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(ConnectionFactory jmsConnectionFactory)
{
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(jmsConnectionFactory);
    factory.setDestinationResolver(herdDestinationResolver);
    factory.setConcurrency(configurationHelper.getProperty(ConfigurationValue.JMS_LISTENER_POOL_CONCURRENCY_LIMITS));

    return factory;
}
 
Example 3
Source File: ServiceSpringModuleConfig.java    From herd with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a JMS listener container factory that returns a JMS listener container for the storage policy processor JMS message listener service.
 *
 * @param jmsConnectionFactory the JMS connection factory
 *
 * @return the JMS listener container factory
 */
@Bean
public DefaultJmsListenerContainerFactory storagePolicyProcessorJmsListenerContainerFactory(ConnectionFactory jmsConnectionFactory)
{
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory(jmsConnectionFactory);
    factory.setDestinationResolver(herdDestinationResolver);
    factory.setConcurrency(configurationHelper.getProperty(ConfigurationValue.STORAGE_POLICY_PROCESSOR_JMS_LISTENER_POOL_CONCURRENCY_LIMITS));

    return factory;
}
 
Example 4
Source File: JndiConsumerConfiguration.java    From solace-jms-spring-boot with Apache License 2.0 5 votes vote down vote up
@Bean
public DefaultJmsListenerContainerFactory cFactory(DemoErrorHandler errorHandler) {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory((ConnectionFactory) consumerConnectionFactory().getObject());
    factory.setDestinationResolver(consumerJndiDestinationResolver());
    factory.setErrorHandler(errorHandler);
    factory.setConcurrency("3-10");
   return factory;
}
 
Example 5
Source File: ActivemqConfiguration.java    From jim-framework with Apache License 2.0 5 votes vote down vote up
public JmsListenerContainerFactory<?> jmsListenerAContainerQueue() {
    DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory();

    bean.setConnectionFactory(this.pooledConnectionFactory);
    bean.setConcurrency("3-10");

    return bean;
}
 
Example 6
Source File: ActivemqConfiguration.java    From jim-framework with Apache License 2.0 5 votes vote down vote up
public JmsListenerContainerFactory<?> jmsListenerBContainerQueue() {
    DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory();
    ActiveMQConnectionFactory connectionFactory=new ActiveMQConnectionFactory(Constans.CONSUMER_B_BROKER_URL);
    //connectionFactory
    bean.setConnectionFactory(connectionFactory);
    bean.setConcurrency("3-10");

    return bean;
}
 
Example 7
Source File: ReceiverConfig.java    From spring-jms with MIT License 5 votes vote down vote up
@Bean
public DefaultJmsListenerContainerFactory orderDefaultJmsListenerContainerFactory() {
  DefaultJmsListenerContainerFactory factory =
      new DefaultJmsListenerContainerFactory();
  factory
      .setConnectionFactory(receiverActiveMQConnectionFactory());
  factory.setConcurrency("3-10");

  return factory;
}
 
Example 8
Source File: ReceiverConfig.java    From spring-jms with MIT License 5 votes vote down vote up
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
  DefaultJmsListenerContainerFactory factory =
      new DefaultJmsListenerContainerFactory();
  factory
      .setConnectionFactory(receiverActiveMQConnectionFactory());
  factory.setConcurrency("3-10");

  return factory;
}
 
Example 9
Source File: ReceiverConfig.java    From spring-jms with MIT License 5 votes vote down vote up
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
  DefaultJmsListenerContainerFactory factory =
      new DefaultJmsListenerContainerFactory();
  factory
      .setConnectionFactory(receiverActiveMQConnectionFactory());
  factory.setConcurrency("3-10");

  return factory;
}
 
Example 10
Source File: JmsMessageBrokerConfiguration.java    From piper with Apache License 2.0 5 votes vote down vote up
private DefaultJmsListenerContainerFactory createContainerFactory (int aConcurrency) {
  DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
  factory.setConcurrency(String.valueOf(aConcurrency));
  factory.setConnectionFactory(connectionFactory);
  return factory;
}
 
Example 11
Source File: ArtemisConfig.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Bean // configured for topics
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory( ConnectionFactory connectionFactory, NameDestinationResolver nameDestinationResolver )
{
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory( connectionFactory );
    factory.setDestinationResolver( nameDestinationResolver );
    // set to true, since we only use topics and we want to resolve names to topic destination
    factory.setPubSubDomain( true );
    // 1 forces the listener to use only one consumer, to avoid duplicated messages
    factory.setConcurrency( "1" );

    return factory;
}
 
Example 12
Source File: ArtemisConfig.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Bean // configured for queues
public DefaultJmsListenerContainerFactory jmsQueueListenerContainerFactory( ConnectionFactory connectionFactory, NameDestinationResolver nameDestinationResolver )
{
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    factory.setConnectionFactory( connectionFactory );
    factory.setDestinationResolver( nameDestinationResolver );
    factory.setPubSubDomain( false );
    factory.setConcurrency( "5-10" );

    return factory;
}