org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory Java Examples

The following examples show how to use org.springframework.amqp.rabbit.listener.RabbitListenerContainerFactory. 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: RabbitChannelDefinitionProcessor.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
protected RabbitListenerContainerFactory<?> resolveContainerFactory(RabbitListenerEndpoint endpoint, RabbitListenerContainerFactory<?> containerFactory) {
    if (containerFactory != null) {
        return containerFactory;
    } else if (this.containerFactory != null) {
        return this.containerFactory;
    } else if (containerFactoryBeanName != null) {
        Assert.state(beanFactory != null, "BeanFactory must be set to obtain container factory by bean name");
        // Consider changing this if live change of the factory is required...
        this.containerFactory = beanFactory.getBean(containerFactoryBeanName, RabbitListenerContainerFactory.class);
        return this.containerFactory;
    } else {
        throw new IllegalStateException("Could not resolve the " +
            RabbitListenerContainerFactory.class.getSimpleName() + " to use for [" +
            endpoint + "] no factory was given and no default is set.");
    }
}
 
Example #2
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 #3
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 #4
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 #5
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 #6
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 #7
Source File: RabbitChannelDefinitionProcessor.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
/**
 * Register a new {@link RabbitListenerEndpoint} alongside the
 * {@link RabbitListenerContainerFactory} to use to create the underlying container.
 * <p>The {@code factory} may be {@code null} if the default factory has to be
 * used for that endpoint.
 */
protected void registerEndpoint(RabbitListenerEndpoint endpoint, RabbitListenerContainerFactory<?> factory) {
    Assert.notNull(endpoint, "Endpoint must not be null");
    Assert.hasText(endpoint.getId(), "Endpoint id must be set");

    Assert.state(this.endpointRegistry != null, "No RabbitListenerEndpointRegistry set");
    endpointRegistry.registerListenerContainer(endpoint, resolveContainerFactory(endpoint, factory), true);
}
 
Example #8
Source File: AmqpConfiguration.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Create RabbitListenerContainerFactory bean if no listenerContainerFactory
 * bean found
 *
 * @return RabbitListenerContainerFactory bean
 */
@Bean
@ConditionalOnMissingBean(name = "listenerContainerFactory")
public RabbitListenerContainerFactory<SimpleMessageListenerContainer> listenerContainerFactory(
        final SimpleRabbitListenerContainerFactoryConfigurer configurer, final ErrorHandler errorHandler) {
    final ConfigurableRabbitListenerContainerFactory factory = new ConfigurableRabbitListenerContainerFactory(
            amqpProperties.isMissingQueuesFatal(), amqpProperties.getDeclarationRetries(), errorHandler);
    configurer.configure(factory, rabbitConnectionFactory);
    return factory;
}
 
Example #9
Source File: RabbitChannelDefinitionProcessor.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public RabbitListenerContainerFactory<?> getContainerFactory() {
    return containerFactory;
}
 
Example #10
Source File: RabbitChannelDefinitionProcessor.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
public void setContainerFactory(RabbitListenerContainerFactory<?> containerFactory) {
    this.containerFactory = containerFactory;
}
 
Example #11
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;
}