Search in sources :

Example 1 with PublishSubscribeAmqpChannel

use of org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel in project spring-integration by spring-projects.

the class AmqpChannelFactoryBean method createInstance.

@Override
protected AbstractAmqpChannel createInstance() throws Exception {
    if (this.messageDriven) {
        AbstractMessageListenerContainer container = this.createContainer();
        if (this.amqpTemplate instanceof InitializingBean) {
            ((InitializingBean) this.amqpTemplate).afterPropertiesSet();
        }
        if (this.isPubSub) {
            PublishSubscribeAmqpChannel pubsub = new PublishSubscribeAmqpChannel(this.beanName, container, this.amqpTemplate, this.outboundHeaderMapper, this.inboundHeaderMapper);
            if (this.exchange != null) {
                pubsub.setExchange(this.exchange);
            }
            if (this.maxSubscribers != null) {
                pubsub.setMaxSubscribers(this.maxSubscribers);
            }
            this.channel = pubsub;
        } else {
            PointToPointSubscribableAmqpChannel p2p = new PointToPointSubscribableAmqpChannel(this.beanName, container, this.amqpTemplate, this.outboundHeaderMapper, this.inboundHeaderMapper);
            if (StringUtils.hasText(this.queueName)) {
                p2p.setQueueName(this.queueName);
            }
            if (this.maxSubscribers != null) {
                p2p.setMaxSubscribers(this.maxSubscribers);
            }
            this.channel = p2p;
        }
    } else {
        Assert.isTrue(!this.isPubSub, "An AMQP 'publish-subscribe-channel' must be message-driven.");
        PollableAmqpChannel pollable = new PollableAmqpChannel(this.beanName, this.amqpTemplate, this.outboundHeaderMapper, this.inboundHeaderMapper);
        if (this.amqpAdmin != null) {
            pollable.setAmqpAdmin(this.amqpAdmin);
        }
        if (StringUtils.hasText(this.queueName)) {
            pollable.setQueueName(this.queueName);
        }
        this.channel = pollable;
    }
    if (!CollectionUtils.isEmpty(this.interceptors)) {
        this.channel.setInterceptors(this.interceptors);
    }
    this.channel.setBeanName(this.beanName);
    if (this.getBeanFactory() != null) {
        this.channel.setBeanFactory(this.getBeanFactory());
    }
    if (this.defaultDeliveryMode != null) {
        this.channel.setDefaultDeliveryMode(this.defaultDeliveryMode);
    }
    if (this.extractPayload != null) {
        this.channel.setExtractPayload(this.extractPayload);
    }
    this.channel.setHeadersMappedLast(this.headersLast);
    this.channel.afterPropertiesSet();
    return this.channel;
}
Also used : PointToPointSubscribableAmqpChannel(org.springframework.integration.amqp.channel.PointToPointSubscribableAmqpChannel) PollableAmqpChannel(org.springframework.integration.amqp.channel.PollableAmqpChannel) InitializingBean(org.springframework.beans.factory.InitializingBean) AbstractMessageListenerContainer(org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer) PublishSubscribeAmqpChannel(org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel)

Aggregations

AbstractMessageListenerContainer (org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer)1 InitializingBean (org.springframework.beans.factory.InitializingBean)1 PointToPointSubscribableAmqpChannel (org.springframework.integration.amqp.channel.PointToPointSubscribableAmqpChannel)1 PollableAmqpChannel (org.springframework.integration.amqp.channel.PollableAmqpChannel)1 PublishSubscribeAmqpChannel (org.springframework.integration.amqp.channel.PublishSubscribeAmqpChannel)1