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


Java SimpleRabbitListenerContainerFactory类代码示例

本文整理汇总了Java中org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory的典型用法代码示例。如果您正苦于以下问题:Java SimpleRabbitListenerContainerFactory类的具体用法?Java SimpleRabbitListenerContainerFactory怎么用?Java SimpleRabbitListenerContainerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleRabbitListenerContainerFactory类属于org.springframework.amqp.rabbit.config包,在下文中一共展示了SimpleRabbitListenerContainerFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rabbitListenerContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
		ConnectionFactory connectionFactory, RabbitProperties config) {
	SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
	factory.setConnectionFactory(connectionFactory);
	Listener listenerConfig = config.getListener();
	factory.setAutoStartup(listenerConfig.isAutoStartup());
	if (listenerConfig.getAcknowledgeMode() != null) {
		factory.setAcknowledgeMode(listenerConfig.getAcknowledgeMode());
	}
	if (listenerConfig.getConcurrency() != null) {
		factory.setConcurrentConsumers(listenerConfig.getConcurrency());
	}
	if (listenerConfig.getMaxConcurrency() != null) {
		factory.setMaxConcurrentConsumers(listenerConfig.getMaxConcurrency());
	}
	if (listenerConfig.getPrefetch() != null) {
		factory.setPrefetchCount(listenerConfig.getPrefetch());
	}
	if (listenerConfig.getTransactionSize() != null) {
		factory.setTxSize(listenerConfig.getTransactionSize());
	}
	return factory;
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:26,代码来源:RabbitAnnotationDrivenConfiguration.java

示例2: rabbitListenerContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(messageConverter);
    factory.setDefaultRequeueRejected(rabbitProperties.getDefaultRequeueRejected());
    factory.setErrorHandler(new DefaultErrorHandler());

    return factory;
}
 
开发者ID:lodsve,项目名称:lodsve-framework,代码行数:12,代码来源:RabbitConfiguration.java

示例3: createContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
private SimpleRabbitListenerContainerFactory createContainerFactory (int aConcurrency) {
  SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
  factory.setConcurrentConsumers(aConcurrency);
  factory.setConnectionFactory(connectionFactory);
  factory.setDefaultRequeueRejected(false);
  factory.setMessageConverter(jacksonAmqpMessageConverter(objectMapper));
  return factory;
}
 
开发者ID:creactiviti,项目名称:piper,代码行数:9,代码来源:AmqpMessengerConfiguration.java

示例4: rabbitListenerContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Bean
@ConditionalOnMissingBean(name = "rabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
		SimpleRabbitListenerContainerFactoryConfigurer configurer,
		ConnectionFactory connectionFactory) {
	SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
	configurer.configure(factory, connectionFactory);
	return factory;
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:RabbitAnnotationDrivenConfiguration.java

示例5: testEnableRabbitCreateDefaultContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Test
public void testEnableRabbitCreateDefaultContainerFactory() {
	load(EnableRabbitConfiguration.class);
	RabbitListenerContainerFactory<?> rabbitListenerContainerFactory = this.context
			.getBean("rabbitListenerContainerFactory",
					RabbitListenerContainerFactory.class);
	assertThat(rabbitListenerContainerFactory.getClass())
			.isEqualTo(SimpleRabbitListenerContainerFactory.class);
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:10,代码来源:RabbitAutoConfigurationTests.java

示例6: testRabbitListenerContainerFactoryBackOff

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Test
public void testRabbitListenerContainerFactoryBackOff() {
	load(TestConfiguration5.class);
	SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context
			.getBean("rabbitListenerContainerFactory",
					SimpleRabbitListenerContainerFactory.class);
	rabbitListenerContainerFactory.setTxSize(10);
	verify(rabbitListenerContainerFactory).setTxSize(10);
	DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
	Advice[] adviceChain = (Advice[]) dfa.getPropertyValue("adviceChain");
	assertThat(adviceChain).isNull();
}
 
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:13,代码来源:RabbitAutoConfigurationTests.java

示例7: rabbitListenerContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setConcurrentConsumers(3);
    factory.setMaxConcurrentConsumers(10);
    return factory;
}
 
开发者ID:giovannicandido,项目名称:audit-mq-collector,代码行数:9,代码来源:RabbitConfiguration.java

示例8: testEnableRabbitCreateDefaultContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Test
public void testEnableRabbitCreateDefaultContainerFactory() {
	load(EnableRabbitConfiguration.class);
	RabbitListenerContainerFactory<?> rabbitListenerContainerFactory = this.context
			.getBean("rabbitListenerContainerFactory",
					RabbitListenerContainerFactory.class);
	assertEquals(SimpleRabbitListenerContainerFactory.class,
			rabbitListenerContainerFactory.getClass());
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:RabbitAutoConfigurationTests.java

示例9: testRabbitListenerContainerFactoryBackOff

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Test
public void testRabbitListenerContainerFactoryBackOff() {
	load(TestConfiguration5.class);
	SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context
			.getBean("rabbitListenerContainerFactory",
					SimpleRabbitListenerContainerFactory.class);
	rabbitListenerContainerFactory.setTxSize(10);
	verify(rabbitListenerContainerFactory).setTxSize(10);
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:10,代码来源:RabbitAutoConfigurationTests.java

示例10: testRabbitListenerContainerFactoryWithCustomSettings

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Test
public void testRabbitListenerContainerFactoryWithCustomSettings() {
	load(TestConfiguration.class, "spring.rabbitmq.listener.autoStartup:false",
			"spring.rabbitmq.listener.acknowledgeMode:manual",
			"spring.rabbitmq.listener.concurrency:5",
			"spring.rabbitmq.listener.maxConcurrency:10",
			"spring.rabbitmq.listener.prefetch=40",
			"spring.rabbitmq.listener.transactionSize:20");
	SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory = this.context
			.getBean("rabbitListenerContainerFactory",
					SimpleRabbitListenerContainerFactory.class);
	DirectFieldAccessor dfa = new DirectFieldAccessor(rabbitListenerContainerFactory);
	assertEquals(false, dfa.getPropertyValue("autoStartup"));
	assertEquals(AcknowledgeMode.MANUAL, dfa.getPropertyValue("acknowledgeMode"));
	assertEquals(5, dfa.getPropertyValue("concurrentConsumers"));
	assertEquals(10, dfa.getPropertyValue("maxConcurrentConsumers"));
	assertEquals(40, dfa.getPropertyValue("prefetchCount"));
	assertEquals(20, dfa.getPropertyValue("txSize"));
}
 
开发者ID:Nephilim84,项目名称:contestparser,代码行数:20,代码来源:RabbitAutoConfigurationTests.java

示例11: myFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
/**
 * enables support for @RabbitListener
 * @param configurer
 * @return
 */
@Bean
public SimpleRabbitListenerContainerFactory myFactory(
    SimpleRabbitListenerContainerFactoryConfigurer configurer) {
  SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
  configurer.configure(factory, connectionFactory);
  // factory.setMessageConverter(myMessageConverter());
  return factory;
}
 
开发者ID:the-james-burton,项目名称:the-turbine,代码行数:14,代码来源:AmqpSetup.java

示例12: rabbitListenerContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Bean
SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(org.springframework.amqp.rabbit.connection.ConnectionFactory  cf,
                                                                    ObjectMapper mapper) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(cf);
    factory.setMessageConverter(new Jackson2JsonMessageConverter(mapper));
    return factory;
}
 
开发者ID:ctco,项目名称:cukes,代码行数:9,代码来源:RabbitMQConfiguration.java

示例13: rabbitListenerContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    // factory.setPrefetchCount(5);

    factory.setAcknowledgeMode(AcknowledgeMode.AUTO);
    return factory;
}
 
开发者ID:capesonlee,项目名称:tangtang-spring-cloud,代码行数:10,代码来源:ConsumerConfig.java

示例14: myContainerFactory

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleRabbitListenerContainerFactory myContainerFactory(
        SimpleRabbitListenerContainerFactoryConfigurer configurer,
        ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setPrefetchCount(100);
    configurer.configure(factory, connectionFactory);
    return factory;
}
 
开发者ID:yu199195,项目名称:myth,代码行数:11,代码来源:AmqpConfig.java

示例15: initRabbitMQ

import org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory; //导入依赖的package包/类
private void initRabbitMQ() throws URISyntaxException {
    CachingConnectionFactory connectionFactory = new CachingConnectionFactory(new URI(host));

    Map<String, Object> cmdQueueArgs = new HashMap<>();
    cmdQueueArgs.put("x-max-length", maxSize);
    cmdQueueArgs.put("x-max-priority", maxPriority);
    Queue cmdQueue = new Queue(name, true, false, false, cmdQueueArgs);

    RabbitAdmin rabbitAdmin = new RabbitAdmin(connectionFactory);
    rabbitAdmin.declareQueue(cmdQueue);

    // setup listener container factory
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setConcurrentConsumers(DEFAULT_CONCURRENCY);
    factory.setMaxConcurrentConsumers(DEFAULT_CONCURRENCY);
    factory.setTaskExecutor(executor);
    factory.setAutoStartup(false);

    // setup rabbit template
    template = new RabbitTemplate(connectionFactory);
    template.setQueue(name);

    // setup container
    SimpleRabbitListenerEndpoint simpleEndpoint = new SimpleRabbitListenerEndpoint();
    simpleEndpoint.setMessageListener(new RabbitMessageListener());

    container = factory.createListenerContainer(simpleEndpoint);
    container.setQueueNames(name);
    LOGGER.trace("RabbitMQ initialized on '%s' with queue name '%s'", host, name);
}
 
开发者ID:FlowCI,项目名称:flow-platform,代码行数:32,代码来源:RabbitQueue.java


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