Example usage for org.springframework.integration.amqp.inbound AmqpInboundChannelAdapter start

List of usage examples for org.springframework.integration.amqp.inbound AmqpInboundChannelAdapter start

Introduction

In this page you can find the example usage for org.springframework.integration.amqp.inbound AmqpInboundChannelAdapter start.

Prototype

@Override
    public final void start() 

Source Link

Usage

From source file:org.springframework.integration.x.rabbit.RabbitChannelRegistry.java

@Override
public void createInbound(final String name, MessageChannel moduleInputChannel,
        final Collection<MediaType> acceptedMediaTypes, boolean aliasHint) {
    if (logger.isInfoEnabled()) {
        logger.info("declaring queue for inbound: " + name);
    }/*from w  w  w  . j  a  va2  s  .  c om*/
    this.rabbitAdmin.declareQueue(new Queue(name));
    SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(
            this.connectionFactory);
    if (this.concurrentConsumers != null) {
        listenerContainer.setConcurrentConsumers(this.concurrentConsumers);
    }
    listenerContainer.setQueueNames(name);
    listenerContainer.afterPropertiesSet();
    AmqpInboundChannelAdapter adapter = new AmqpInboundChannelAdapter(listenerContainer);
    DirectChannel bridgeToModuleChannel = new DirectChannel();
    bridgeToModuleChannel.setBeanName(name + ".bridge");
    adapter.setOutputChannel(bridgeToModuleChannel);
    adapter.setHeaderMapper(this.mapper);
    adapter.setBeanName("inbound." + name);
    adapter.afterPropertiesSet();
    this.lifecycleBeans.add(adapter);
    ReceivingHandler convertingBridge = new ReceivingHandler(acceptedMediaTypes);
    convertingBridge.setOutputChannel(moduleInputChannel);
    convertingBridge.setBeanName(name + ".convert.bridge");
    convertingBridge.afterPropertiesSet();
    bridgeToModuleChannel.subscribe(convertingBridge);
    adapter.start();
}

From source file:org.springframework.integration.x.rabbit.RabbitChannelRegistry.java

@Override
public void tap(String tapModule, final String name, MessageChannel tapModuleInputChannel) {
    SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(
            this.connectionFactory);
    if (this.concurrentConsumers != null) {
        listenerContainer.setConcurrentConsumers(this.concurrentConsumers);
    }//from ww  w . j  a  va 2  s  . c o  m
    Queue queue = this.rabbitAdmin.declareQueue();
    Binding binding = BindingBuilder.bind(queue).to(new FanoutExchange("tap." + name));
    this.rabbitAdmin.declareBinding(binding);
    listenerContainer.setQueues(queue);
    listenerContainer.afterPropertiesSet();
    AmqpInboundChannelAdapter adapter = new AmqpInboundChannelAdapter(listenerContainer);
    DirectChannel bridgeToTapChannel = new DirectChannel();
    bridgeToTapChannel.setBeanName(tapModule + ".bridge");
    adapter.setOutputChannel(bridgeToTapChannel);
    adapter.setHeaderMapper(this.mapper);
    adapter.setBeanName("tap." + name);
    adapter.setComponentName(tapModule + "." + "tapAdapter");
    adapter.afterPropertiesSet();
    this.lifecycleBeans.add(adapter);
    // TODO: media types need to be passed in by Tap.
    Collection<MediaType> acceptedMediaTypes = Collections.singletonList(MediaType.ALL);
    ReceivingHandler convertingBridge = new ReceivingHandler(acceptedMediaTypes);
    convertingBridge.setOutputChannel(tapModuleInputChannel);
    convertingBridge.setBeanName(name + ".convert.bridge");
    convertingBridge.afterPropertiesSet();
    bridgeToTapChannel.subscribe(convertingBridge);
    adapter.start();
}

From source file:org.springframework.integration.x.rabbit.RabbitMessageBus.java

private void doRegisterConsumer(String name, MessageChannel moduleInputChannel, Queue queue) {
    SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer(
            this.connectionFactory);
    if (this.concurrentConsumers != null) {
        listenerContainer.setConcurrentConsumers(this.concurrentConsumers);
    }/*  w w  w  . ja v a 2s  .  c  o m*/
    listenerContainer.setQueues(queue);
    Advice advice = new StatelessRetryOperationsInterceptorFactoryBean().getObject();
    listenerContainer.setAdviceChain(new Advice[] { advice });
    listenerContainer.afterPropertiesSet();
    AmqpInboundChannelAdapter adapter = new AmqpInboundChannelAdapter(listenerContainer);
    DirectChannel bridgeToModuleChannel = new DirectChannel();
    bridgeToModuleChannel.setBeanName(name + ".bridge");
    adapter.setOutputChannel(bridgeToModuleChannel);
    adapter.setHeaderMapper(this.mapper);
    adapter.setBeanName("inbound." + name);
    adapter.afterPropertiesSet();
    addBinding(Binding.forConsumer(adapter, moduleInputChannel));
    ReceivingHandler convertingBridge = new ReceivingHandler();
    convertingBridge.setOutputChannel(moduleInputChannel);
    convertingBridge.setBeanName(name + ".convert.bridge");
    convertingBridge.afterPropertiesSet();
    bridgeToModuleChannel.subscribe(convertingBridge);
    adapter.start();
}