@Test public void testAmqpChannelFactoryBean() throws Exception { AmqpChannelFactoryBean channelFactoryBean = new AmqpChannelFactoryBean(); channelFactoryBean.setBeanFactory(mock(BeanFactory.class)); channelFactoryBean.setConnectionFactory(this.connectionFactory); channelFactoryBean.setBeanName("testChannel"); channelFactoryBean.afterPropertiesSet(); AbstractAmqpChannel channel = channelFactoryBean.getObject(); assertThat(channel, instanceOf(PointToPointSubscribableAmqpChannel.class)); channelFactoryBean = new AmqpChannelFactoryBean(); channelFactoryBean.setBeanFactory(mock(BeanFactory.class)); channelFactoryBean.setConnectionFactory(this.connectionFactory); channelFactoryBean.setBeanName("testChannel"); channelFactoryBean.setPubSub(true); channelFactoryBean.afterPropertiesSet(); channel = channelFactoryBean.getObject(); assertThat(channel, instanceOf(PublishSubscribeAmqpChannel.class)); RabbitAdmin rabbitAdmin = new RabbitAdmin(this.connectionFactory); rabbitAdmin.deleteQueue("testChannel"); rabbitAdmin.deleteExchange("si.fanout.testChannel"); }
/** * @param acknowledgeMode the acknowledgeMode. * @return the spec. * @see org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer#setAcknowledgeMode(AcknowledgeMode) */ public S acknowledgeMode(AcknowledgeMode acknowledgeMode) { this.amqpChannelFactoryBean.setAcknowledgeMode(acknowledgeMode); return _this(); }
@Override protected AbstractAmqpChannel doGet() { this.amqpChannelFactoryBean.setAdviceChain(this.adviceChain.toArray(new Advice[this.adviceChain.size()])); return super.doGet(); }
AmqpPollableMessageChannelSpec(AmqpChannelFactoryBean amqpChannelFactoryBean, ConnectionFactory connectionFactory) { this.amqpChannelFactoryBean = amqpChannelFactoryBean; this.amqpChannelFactoryBean.setConnectionFactory(connectionFactory); this.amqpChannelFactoryBean.setSingleton(false); this.amqpChannelFactoryBean.setPubSub(false); /* We need this artificial BeanFactory to overcome AmqpChannelFactoryBean initialization. The real BeanFactory will be applied later for the target AbstractAmqpChannel instance. */ this.amqpChannelFactoryBean.setBeanFactory(new DefaultListableBeanFactory()); }
AmqpPollableMessageChannelSpec(ConnectionFactory connectionFactory) { this(new AmqpChannelFactoryBean(false), connectionFactory); }
@Override protected AbstractAmqpChannel doGet() { Assert.notNull(getId(), "The 'id' or 'queueName' must be specified"); try { this.channel = this.amqpChannelFactoryBean.getObject(); } catch (Exception e) { throw new BeanCreationException("Cannot create the AMQP MessageChannel", e); } return super.doGet(); }
@Override protected S id(@Nullable String id) { this.amqpChannelFactoryBean.setBeanName(id); return super.id(id); }
AmqpPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) { super(connectionFactory); this.amqpChannelFactoryBean.setPubSub(true); }
/** * @param autoStartup the autoStartup. * @return the spec. * @see org.springframework.context.SmartLifecycle */ public S autoStartup(boolean autoStartup) { this.amqpChannelFactoryBean.setAutoStartup(autoStartup); return _this(); }
/** * Configure {@code channelTransacted} on both the * {@link org.springframework.amqp.rabbit.core.RabbitTemplate} (for sends) and * {@link org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer} * (for receives) when using Spring Integration 4.0. When using Spring Integration * 4.1, only the container is configured. See {@link #templateChannelTransacted(boolean)}. * @param channelTransacted the channelTransacted. * @return the spec. * @see org.springframework.amqp.rabbit.core.RabbitTemplate#setChannelTransacted(boolean) * @see org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer#setChannelTransacted(boolean) */ public S channelTransacted(boolean channelTransacted) { this.amqpChannelFactoryBean.setChannelTransacted(channelTransacted); return _this(); }
AmqpPollableMessageChannelSpec(AmqpChannelFactoryBean amqpChannelFactoryBean, ConnectionFactory connectionFactory) { this.amqpChannelFactoryBean = amqpChannelFactoryBean; this.amqpChannelFactoryBean.setConnectionFactory(connectionFactory); this.amqpChannelFactoryBean.setSingleton(false); this.amqpChannelFactoryBean.setPubSub(false); /* We need this artificial BeanFactory to overcome AmqpChannelFactoryBean initialization. The real BeanFactory will be applied later for the target AbstractAmqpChannel instance. */ this.amqpChannelFactoryBean.setBeanFactory(new DefaultListableBeanFactory()); }
AmqpMessageChannelSpec(ConnectionFactory connectionFactory) { super(new AmqpChannelFactoryBean(true), connectionFactory); }
@Override protected AbstractAmqpChannel doGet() { Assert.notNull(getId(), "The 'id' or 'queueName' must be specified"); try { this.channel = this.amqpChannelFactoryBean.getObject(); } catch (Exception e) { throw new BeanCreationException("Cannot create the AMQP MessageChannel", e); } return super.doGet(); }
@Override protected S id(@Nullable String id) { this.amqpChannelFactoryBean.setBeanName(id); return super.id(id); }
AmqpPublishSubscribeMessageChannelSpec(ConnectionFactory connectionFactory) { super(connectionFactory); this.amqpChannelFactoryBean.setPubSub(true); }
/** * @param autoStartup the autoStartup. * @return the spec. * @see org.springframework.context.SmartLifecycle */ public S autoStartup(boolean autoStartup) { this.amqpChannelFactoryBean.setAutoStartup(autoStartup); return _this(); }
/** * Configure {@code channelTransacted} on both the * {@link org.springframework.amqp.rabbit.core.RabbitTemplate} (for sends) and * {@link org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer} * (for receives) when using Spring Integration 4.0. When using Spring Integration * 4.1, only the container is configured. See {@link #templateChannelTransacted(boolean)}. * @param channelTransacted the channelTransacted. * @return the spec. * @see org.springframework.amqp.rabbit.core.RabbitTemplate#setChannelTransacted(boolean) * @see org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer#setChannelTransacted(boolean) */ public S channelTransacted(boolean channelTransacted) { this.amqpChannelFactoryBean.setChannelTransacted(channelTransacted); return _this(); }
AmqpPollableMessageChannelSpec(AmqpChannelFactoryBean amqpChannelFactoryBean, ConnectionFactory connectionFactory) { this.amqpChannelFactoryBean = amqpChannelFactoryBean; this.amqpChannelFactoryBean.setConnectionFactory(connectionFactory); this.amqpChannelFactoryBean.setSingleton(false); this.amqpChannelFactoryBean.setPubSub(false); /* We need this artificial BeanFactory to overcome AmqpChannelFactoryBean initialization. The real BeanFactory will be applied later for the target AbstractAmqpChannel instance. */ this.amqpChannelFactoryBean.setBeanFactory(new DefaultListableBeanFactory()); }
AmqpPollableMessageChannelSpec(ConnectionFactory connectionFactory) { this(new AmqpChannelFactoryBean(false), connectionFactory); }
@Override protected AbstractAmqpChannel doGet() { Assert.notNull(getId(), "The 'id' or 'queueName' must be specified"); try { this.channel = this.amqpChannelFactoryBean.getObject(); } catch (Exception e) { throw new BeanCreationException("Cannot create the AMQP MessageChannel", e); } return super.doGet(); }