private SimpleConsumer(Connection connection, Channel channel, String queue) { super(channel); this.connection = connection; this.queue = queue; this.ackRequired = !getAcknowledgeMode().isAutoAck() && !getAcknowledgeMode().isManual(); }
private SimpleConsumer(Connection connection, Channel channel, String queue) { super(channel); this.connection = connection; this.queue = queue; this.ackRequired = !getAcknowledgeMode().isAutoAck() && !getAcknowledgeMode().isManual(); }
@Nullable private SimpleConsumer consume(String queue, Connection connection) { Channel channel = null; SimpleConsumer consumer = null; try { channel = connection.createChannel(isChannelTransacted()); channel.basicQos(getPrefetchCount()); consumer = new SimpleConsumer(connection, channel, queue); channel.queueDeclarePassive(queue); consumer.consumerTag = channel.basicConsume(queue, getAcknowledgeMode().isAutoAck(), (getConsumerTagStrategy() != null ? getConsumerTagStrategy().createConsumerTag(queue) : ""), // NOSONAR never null isNoLocal(), isExclusive(), getConsumerArguments(), consumer); } catch (AmqpApplicationContextClosedException e) { throw new AmqpConnectException(e); } catch (Exception e) { RabbitUtils.closeChannel(channel); RabbitUtils.closeConnection(connection); consumer = handleConsumeException(queue, consumer, e); } return consumer; }
@Nullable private SimpleConsumer consume(String queue, Connection connection) { Channel channel = null; SimpleConsumer consumer = null; try { channel = connection.createChannel(isChannelTransacted()); channel.basicQos(getPrefetchCount()); consumer = new SimpleConsumer(connection, channel, queue); channel.queueDeclarePassive(queue); consumer.consumerTag = channel.basicConsume(queue, getAcknowledgeMode().isAutoAck(), (getConsumerTagStrategy() != null ? getConsumerTagStrategy().createConsumerTag(queue) : ""), // NOSONAR never null isNoLocal(), isExclusive(), getConsumerArguments(), consumer); } catch (AmqpApplicationContextClosedException e) { throw new AmqpConnectException(e); } catch (Exception e) { RabbitUtils.closeChannel(channel); RabbitUtils.closeConnection(connection); consumer = handleConsumeException(queue, consumer, e); } return consumer; }
@Test public void testParseWithDirect() { DirectMessageListenerContainer container = beanFactory.getBean("direct1", DirectMessageListenerContainer.class); assertEquals(AcknowledgeMode.MANUAL, container.getAcknowledgeMode()); assertEquals(beanFactory.getBean(ConnectionFactory.class), container.getConnectionFactory()); assertEquals(MessageListenerAdapter.class, container.getMessageListener().getClass());