Java Code Examples for org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory#setConnectionFactory()

The following examples show how to use org.springframework.amqp.rabbit.config.SimpleRabbitListenerContainerFactory#setConnectionFactory() . 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: AmqpMessageBrokerConfiguration.java    From piper with Apache License 2.0 5 votes vote down vote up
private SimpleRabbitListenerContainerFactory createContainerFactory (int aConcurrency) {
  SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
  factory.setConcurrentConsumers(aConcurrency);
  factory.setConnectionFactory(connectionFactory);
  factory.setDefaultRequeueRejected(false);
  factory.setMessageConverter(jacksonAmqpMessageConverter(objectMapper));
  factory.setPrefetchCount(rabbit.getListener().getDirect().getPrefetch());
  return factory;
}
 
Example 2
Source File: SpringRabbitTracing.java    From brave with Apache License 2.0 5 votes vote down vote up
/** Creates an instrumented {@linkplain SimpleRabbitListenerContainerFactory} */
public SimpleRabbitListenerContainerFactory newSimpleRabbitListenerContainerFactory(
  ConnectionFactory connectionFactory
) {
  SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
  factory.setConnectionFactory(connectionFactory);
  factory.setAdviceChain(new TracingRabbitListenerAdvice(this));
  return factory;
}
 
Example 3
Source File: RabbitConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory retryContainerFactory(ConnectionFactory connectionFactory, RetryOperationsInterceptor retryInterceptor) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);

    Advice[] adviceChain = { retryInterceptor };
    factory.setAdviceChain(adviceChain);

    return factory;
}
 
Example 4
Source File: RabbitConfiguration.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory defaultContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);

    return factory;
}
 
Example 5
Source File: RabbitMQConfiguration.java    From cukes with Apache License 2.0 5 votes vote down vote up
@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;
}
 
Example 6
Source File: EventRegistryRabbitConfiguration.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Bean(name = "rabbitListenerContainerFactory")
public SimpleRabbitListenerContainerFactory simpleRabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();

    factory.setConnectionFactory(connectionFactory);
    return factory;
}
 
Example 7
Source File: AmqpMessagingApplication.java    From spring-cloud-contract with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(
		ConnectionFactory connectionFactory, MessageConverter messageConverter) {
	SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
	factory.setConnectionFactory(connectionFactory);
	factory.setConcurrentConsumers(3);
	factory.setMaxConcurrentConsumers(10);
	factory.setMessageConverter(messageConverter);
	return factory;
}
 
Example 8
Source File: RabbitTemplateConfig.java    From spring-boot-tutorials with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(new Jackson2JsonMessageConverter());
    return factory;
}
 
Example 9
Source File: RabbitTemplateConfig.java    From spring-boot-tutorials with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(new Jackson2JsonMessageConverter());
    return factory;
}
 
Example 10
Source File: RabbitmqConfig.java    From ChengFeng1.5 with MIT License 5 votes vote down vote up
@Bean
    public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(){
        SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory());
//        factory.setMessageConverter(new Jackson2JsonMessageConverter());
        factory.setAcknowledgeMode(AcknowledgeMode.MANUAL);
        return factory;
    }
 
Example 11
Source File: RabbitMQRouterConfig.java    From konker-platform with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setAcknowledgeMode(AcknowledgeMode.AUTO);
    factory.setConcurrentConsumers(1);
    factory.setMaxConcurrentConsumers(20);

    Advice[] adviceChain = new Advice[] { interceptor() };
    factory.setAdviceChain(adviceChain);
    return factory;
}
 
Example 12
Source File: RabbitConfiguration.java    From JuniperBot with GNU General Public License v3.0 5 votes vote down vote up
@Bean
public RabbitListenerContainerFactory<SimpleMessageListenerContainer> rabbitListenerContainerFactory() {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory());
    factory.setDefaultRequeueRejected(false);
    factory.setMessageConverter(messageConverter());
    return factory;
}
 
Example 13
Source File: RabbitMQConfiguration.java    From seed with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory jadyerRabbitListenerContainerFactory(ConnectionFactory connectionFactory){
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(new Jackson2JsonMessageConverter());
    return factory;
}
 
Example 14
Source File: TopicRabbitConfig.java    From iot-dc3 with Apache License 2.0 5 votes vote down vote up
@Bean
public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(new Jackson2JsonMessageConverter());
    return factory;
}
 
Example 15
Source File: RabbitConfig.java    From iot-dc3 with Apache License 2.0 5 votes vote down vote up
@Bean
public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(new Jackson2JsonMessageConverter());
    return factory;
}
 
Example 16
Source File: TopicRabbitConfig.java    From iot-dc3 with Apache License 2.0 5 votes vote down vote up
@Bean
public RabbitListenerContainerFactory<?> rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setMessageConverter(new Jackson2JsonMessageConverter());
    return factory;
}
 
Example 17
Source File: RabbitMqConfiguration.java    From Hands-On-High-Performance-with-Spring-5 with MIT License 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory listenerContainer() {
	SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
	factory.setConnectionFactory(connectionFactory());
	factory.setMaxConcurrentConsumers(5);
	return factory;
}
 
Example 18
Source File: SpringRabbitMQTest.java    From java-specialagent with Apache License 2.0 5 votes vote down vote up
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory() {
  final SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
  factory.setConnectionFactory(connectionFactory());
  factory.setConcurrentConsumers(3);
  factory.setMaxConcurrentConsumers(10);
  return factory;
}
 
Example 19
Source File: BaseConfiguration.java    From common-project with Apache License 2.0 5 votes vote down vote up
/**
 * 配置接收消息的MessageConverter
 *
 * @param connectionFactory 连接工厂
 * @return
 */
@Bean
public SimpleRabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory factory = new SimpleRabbitListenerContainerFactory();
    factory.setConnectionFactory(connectionFactory);
    factory.setPrefetchCount(50);
    factory.setConcurrentConsumers(5);
    factory.setMessageConverter(new ProtobufMessageConverter());
    factory.setAcknowledgeMode(AcknowledgeMode.AUTO);
    return factory;
}
 
Example 20
Source File: MessageListenerConfig_Post_1_4_0.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
@Bean(name = "rabbitListenerContainerFactory")
public RabbitListenerContainerFactory rabbitListenerContainerFactory(ConnectionFactory connectionFactory) {
    SimpleRabbitListenerContainerFactory containerFactory = new SimpleRabbitListenerContainerFactory();
    containerFactory.setConnectionFactory(connectionFactory);
    return containerFactory;
}