11/*
2- * Copyright 2014-2016 the original author or authors.
2+ * Copyright 2014-2018 the original author or authors.
33 *
44 * Licensed under the Apache License, Version 2.0 (the "License");
55 * you may not use this file except in compliance with the License.
2222import org .springframework .amqp .rabbit .connection .ConnectionFactory ;
2323import org .springframework .amqp .rabbit .listener .DirectMessageListenerContainer ;
2424import org .springframework .amqp .rabbit .listener .SimpleMessageListenerContainer ;
25+ import org .springframework .integration .amqp .inbound .AmqpMessageSource .AmqpAckCallbackFactory ;
2526
2627/**
2728 * Factory class for AMQP components.
2829 *
2930 * @author Artem Bilan
3031 * @author Gary Russell
32+ *
3133 * @since 5.0
3234 */
3335public final class Amqp {
@@ -53,6 +55,7 @@ public static AmqpInboundGatewaySMLCSpec inboundGateway(ConnectionFactory connec
5355 */
5456 public static AmqpInboundGatewaySMLCSpec inboundGateway (ConnectionFactory connectionFactory , AmqpTemplate amqpTemplate ,
5557 String ... queueNames ) {
58+
5659 SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer (connectionFactory );
5760 listenerContainer .setQueueNames (queueNames );
5861 return inboundGateway (listenerContainer , amqpTemplate );
@@ -80,6 +83,7 @@ public static AmqpInboundGatewaySMLCSpec inboundGateway(ConnectionFactory connec
8083 */
8184 public static AmqpInboundGatewaySMLCSpec inboundGateway (ConnectionFactory connectionFactory , AmqpTemplate amqpTemplate ,
8285 Queue ... queues ) {
86+
8387 SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer (connectionFactory );
8488 listenerContainer .setQueues (queues );
8589 return inboundGateway (listenerContainer , amqpTemplate );
@@ -112,6 +116,7 @@ public static AmqpInboundGatewaySMLCSpec inboundGateway(SimpleMessageListenerCon
112116 */
113117 public static AmqpInboundGatewaySMLCSpec inboundGateway (SimpleMessageListenerContainer listenerContainer ,
114118 AmqpTemplate amqpTemplate ) {
119+
115120 return new AmqpInboundGatewaySMLCSpec (listenerContainer , amqpTemplate );
116121 }
117122
@@ -142,9 +147,37 @@ public static AmqpInboundGatewayDMLCSpec inboundGateway(DirectMessageListenerCon
142147 */
143148 public static AmqpInboundGatewayDMLCSpec inboundGateway (DirectMessageListenerContainer listenerContainer ,
144149 AmqpTemplate amqpTemplate ) {
150+
145151 return new AmqpInboundGatewayDMLCSpec (listenerContainer , amqpTemplate );
146152 }
147153
154+ /**
155+ * Create an initial AmqpInboundPolledChannelAdapterSpec
156+ * @param connectionFactory the connectionFactory.
157+ * @param queue the queue.
158+ * @return the AmqpInboundPolledChannelAdapterSpec.
159+ * @since 5.0.1
160+ */
161+ public static AmqpInboundPolledChannelAdapterSpec inboundPolledAdapter (ConnectionFactory connectionFactory ,
162+ String queue ) {
163+
164+ return new AmqpInboundPolledChannelAdapterSpec (connectionFactory , queue );
165+ }
166+
167+ /**
168+ * Create an initial AmqpInboundPolledChannelAdapterSpec
169+ * @param connectionFactory the connectionFactory.
170+ * @param ackCallbackFactory the ackCallbackFactory
171+ * @param queue the queue.
172+ * @return the AmqpInboundPolledChannelAdapterSpec.
173+ * @since 5.0.1
174+ */
175+ public static AmqpInboundPolledChannelAdapterSpec inboundPolledAdapter (ConnectionFactory connectionFactory ,
176+ AmqpAckCallbackFactory ackCallbackFactory , String queue ) {
177+
178+ return new AmqpInboundPolledChannelAdapterSpec (connectionFactory , ackCallbackFactory , queue );
179+ }
180+
148181 /**
149182 * Create an initial AmqpInboundChannelAdapterSpec using a
150183 * {@link SimpleMessageListenerContainer}.
@@ -154,6 +187,7 @@ public static AmqpInboundGatewayDMLCSpec inboundGateway(DirectMessageListenerCon
154187 */
155188 public static AmqpInboundChannelAdapterSMLCSpec inboundAdapter (ConnectionFactory connectionFactory ,
156189 String ... queueNames ) {
190+
157191 SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer (connectionFactory );
158192 listenerContainer .setQueueNames (queueNames );
159193 return new AmqpInboundChannelAdapterSMLCSpec (listenerContainer );
@@ -166,7 +200,9 @@ public static AmqpInboundChannelAdapterSMLCSpec inboundAdapter(ConnectionFactory
166200 * @param queues the queues.
167201 * @return the AmqpInboundChannelAdapterSpec.
168202 */
169- public static AmqpInboundChannelAdapterSMLCSpec inboundAdapter (ConnectionFactory connectionFactory , Queue ... queues ) {
203+ public static AmqpInboundChannelAdapterSMLCSpec inboundAdapter (ConnectionFactory connectionFactory ,
204+ Queue ... queues ) {
205+
170206 SimpleMessageListenerContainer listenerContainer = new SimpleMessageListenerContainer (connectionFactory );
171207 listenerContainer .setQueues (queues );
172208 return new AmqpInboundChannelAdapterSMLCSpec (listenerContainer );
@@ -235,6 +271,7 @@ public static AmqpAsyncOutboundGatewaySpec asyncOutboundGateway(AsyncRabbitTempl
235271 */
236272 public static <S extends AmqpPollableMessageChannelSpec <S >> AmqpPollableMessageChannelSpec <S > pollableChannel (
237273 ConnectionFactory connectionFactory ) {
274+
238275 return pollableChannel (null , connectionFactory );
239276 }
240277
@@ -247,6 +284,7 @@ public static <S extends AmqpPollableMessageChannelSpec<S>> AmqpPollableMessageC
247284 */
248285 public static <S extends AmqpPollableMessageChannelSpec <S >> AmqpPollableMessageChannelSpec <S > pollableChannel (
249286 String id , ConnectionFactory connectionFactory ) {
287+
250288 return new AmqpPollableMessageChannelSpec <S >(connectionFactory ).id (id );
251289 }
252290
@@ -258,6 +296,7 @@ public static <S extends AmqpPollableMessageChannelSpec<S>> AmqpPollableMessageC
258296 */
259297 public static <S extends AmqpMessageChannelSpec <S >> AmqpMessageChannelSpec <S > channel (
260298 ConnectionFactory connectionFactory ) {
299+
261300 return channel (null , connectionFactory );
262301 }
263302
@@ -270,6 +309,7 @@ public static <S extends AmqpMessageChannelSpec<S>> AmqpMessageChannelSpec<S> ch
270309 */
271310 public static <S extends AmqpMessageChannelSpec <S >> AmqpMessageChannelSpec <S > channel (String id ,
272311 ConnectionFactory connectionFactory ) {
312+
273313 return new AmqpMessageChannelSpec <S >(connectionFactory ).id (id );
274314 }
275315
@@ -290,6 +330,7 @@ public static AmqpPublishSubscribeMessageChannelSpec publishSubscribeChannel(Con
290330 */
291331 public static AmqpPublishSubscribeMessageChannelSpec publishSubscribeChannel (String id ,
292332 ConnectionFactory connectionFactory ) {
333+
293334 return new AmqpPublishSubscribeMessageChannelSpec (connectionFactory ).id (id );
294335 }
295336
0 commit comments