|
27 | 27 | import org.springframework.kafka.core.KafkaTemplate;
|
28 | 28 | import org.springframework.kafka.core.ProducerFactory;
|
29 | 29 | import org.springframework.kafka.listener.AbstractMessageListenerContainer;
|
| 30 | +import org.springframework.kafka.listener.ConsumerProperties; |
30 | 31 | import org.springframework.kafka.listener.ContainerProperties;
|
31 | 32 | import org.springframework.kafka.listener.GenericMessageListenerContainer;
|
32 | 33 | import org.springframework.kafka.requestreply.ReplyingKafkaTemplate;
|
|
38 | 39 | * @author Artem Bilan
|
39 | 40 | * @author Nasko Vasilev
|
40 | 41 | * @author Gary Russell
|
| 42 | + * @author Anshul Mehra |
41 | 43 | *
|
42 | 44 | * @since 3.0
|
43 | 45 | */
|
@@ -79,67 +81,133 @@ public static <K, V> KafkaProducerMessageHandlerSpec.KafkaProducerMessageHandler
|
79 | 81 | * @param <V> the Kafka message value type.
|
80 | 82 | * @return the spec.
|
81 | 83 | * @since 3.0.1
|
| 84 | + * @deprecated in favor of {@link #inboundChannelAdapter(ConsumerFactory, ConsumerProperties)} |
82 | 85 | */
|
| 86 | + @Deprecated |
83 | 87 | public static <K, V> KafkaInboundChannelAdapterSpec<K, V> inboundChannelAdapter(
|
84 | 88 | ConsumerFactory<K, V> consumerFactory, String... topics) {
|
85 | 89 |
|
86 |
| - return inboundChannelAdapter(consumerFactory, false, topics); |
| 90 | + return inboundChannelAdapter(consumerFactory, new ConsumerProperties(topics), false); |
87 | 91 | }
|
88 | 92 |
|
89 | 93 | /**
|
90 | 94 | * Create an initial {@link KafkaInboundChannelAdapterSpec} with the consumer factory and
|
91 |
| - * topics. |
| 95 | + * topics with a custom ack callback factory. |
92 | 96 | * @param consumerFactory the consumer factory.
|
93 |
| - * @param allowMultiFetch true to fetch multiple records on each poll. |
| 97 | + * @param ackCallbackFactory the callback factory. |
94 | 98 | * @param topics the topic(s).
|
95 | 99 | * @param <K> the Kafka message key type.
|
96 | 100 | * @param <V> the Kafka message value type.
|
97 | 101 | * @return the spec.
|
98 |
| - * @since 3.2 |
| 102 | + * @since 3.0.1 |
| 103 | + * @deprecated in favor of |
| 104 | + * {@link #inboundChannelAdapter(ConsumerFactory, ConsumerProperties, KafkaAckCallbackFactory)} |
99 | 105 | */
|
| 106 | + @Deprecated |
100 | 107 | public static <K, V> KafkaInboundChannelAdapterSpec<K, V> inboundChannelAdapter(
|
101 |
| - ConsumerFactory<K, V> consumerFactory, boolean allowMultiFetch, String... topics) { |
| 108 | + ConsumerFactory<K, V> consumerFactory, |
| 109 | + KafkaAckCallbackFactory<K, V> ackCallbackFactory, String... topics) { |
102 | 110 |
|
103 |
| - return new KafkaInboundChannelAdapterSpec<>(consumerFactory, allowMultiFetch, topics); |
| 111 | + return inboundChannelAdapter(consumerFactory, ackCallbackFactory, false, topics); |
104 | 112 | }
|
105 | 113 |
|
106 | 114 | /**
|
107 | 115 | * Create an initial {@link KafkaInboundChannelAdapterSpec} with the consumer factory and
|
108 | 116 | * topics with a custom ack callback factory.
|
109 | 117 | * @param consumerFactory the consumer factory.
|
110 | 118 | * @param ackCallbackFactory the callback factory.
|
| 119 | + * @param allowMultiFetch true to fetch multiple records on each poll. |
111 | 120 | * @param topics the topic(s).
|
112 | 121 | * @param <K> the Kafka message key type.
|
113 | 122 | * @param <V> the Kafka message value type.
|
114 | 123 | * @return the spec.
|
115 | 124 | * @since 3.0.1
|
| 125 | + * @deprecated in favor of |
| 126 | + * {@link #inboundChannelAdapter(ConsumerFactory, ConsumerProperties, KafkaAckCallbackFactory, boolean)} |
116 | 127 | */
|
| 128 | + @Deprecated |
117 | 129 | public static <K, V> KafkaInboundChannelAdapterSpec<K, V> inboundChannelAdapter(
|
118 | 130 | ConsumerFactory<K, V> consumerFactory,
|
119 |
| - KafkaAckCallbackFactory<K, V> ackCallbackFactory, String... topics) { |
| 131 | + KafkaAckCallbackFactory<K, V> ackCallbackFactory, |
| 132 | + boolean allowMultiFetch, |
| 133 | + String... topics) { |
120 | 134 |
|
121 |
| - return inboundChannelAdapter(consumerFactory, ackCallbackFactory, false, topics); |
| 135 | + return new KafkaInboundChannelAdapterSpec<>(consumerFactory, new ConsumerProperties(topics), ackCallbackFactory, allowMultiFetch); |
| 136 | + } |
| 137 | + |
| 138 | + /** |
| 139 | + * Create an initial {@link KafkaInboundChannelAdapterSpec} with the consumer factory and |
| 140 | + * topics. |
| 141 | + * @param consumerFactory the consumer factory. |
| 142 | + * @param consumerProperties the consumerProperties. |
| 143 | + * @param <K> the Kafka message key type. |
| 144 | + * @param <V> the Kafka message value type. |
| 145 | + * @return the spec. |
| 146 | + * @since 3.2 |
| 147 | + */ |
| 148 | + public static <K, V> KafkaInboundChannelAdapterSpec<K, V> inboundChannelAdapter( |
| 149 | + ConsumerFactory<K, V> consumerFactory, ConsumerProperties consumerProperties) { |
| 150 | + |
| 151 | + return inboundChannelAdapter(consumerFactory, consumerProperties, false); |
| 152 | + } |
| 153 | + |
| 154 | + /** |
| 155 | + * Create an initial {@link KafkaInboundChannelAdapterSpec} with the consumer factory and |
| 156 | + * topics. |
| 157 | + * @param consumerFactory the consumer factory. |
| 158 | + * @param consumerProperties the consumerProperties. |
| 159 | + * @param allowMultiFetch true to fetch multiple records on each poll. |
| 160 | + * @param <K> the Kafka message key type. |
| 161 | + * @param <V> the Kafka message value type. |
| 162 | + * @return the spec. |
| 163 | + * @since 3.2 |
| 164 | + */ |
| 165 | + public static <K, V> KafkaInboundChannelAdapterSpec<K, V> inboundChannelAdapter( |
| 166 | + ConsumerFactory<K, V> consumerFactory, |
| 167 | + ConsumerProperties consumerProperties, |
| 168 | + boolean allowMultiFetch) { |
| 169 | + |
| 170 | + return new KafkaInboundChannelAdapterSpec<>(consumerFactory, consumerProperties, allowMultiFetch); |
| 171 | + } |
| 172 | + |
| 173 | + /** |
| 174 | + * Create an initial {@link KafkaInboundChannelAdapterSpec} with the consumer factory and |
| 175 | + * topics with a custom ack callback factory. |
| 176 | + * @param consumerFactory the consumer factory. |
| 177 | + * @param consumerProperties the consumerProperties. |
| 178 | + * @param ackCallbackFactory the callback factory. |
| 179 | + * @param <K> the Kafka message key type. |
| 180 | + * @param <V> the Kafka message value type. |
| 181 | + * @return the spec. |
| 182 | + * @since 3.2 |
| 183 | + */ |
| 184 | + public static <K, V> KafkaInboundChannelAdapterSpec<K, V> inboundChannelAdapter( |
| 185 | + ConsumerFactory<K, V> consumerFactory, |
| 186 | + ConsumerProperties consumerProperties, |
| 187 | + KafkaAckCallbackFactory<K, V> ackCallbackFactory) { |
| 188 | + |
| 189 | + return inboundChannelAdapter(consumerFactory, consumerProperties, ackCallbackFactory, false); |
122 | 190 | }
|
123 | 191 |
|
124 | 192 | /**
|
125 | 193 | * Create an initial {@link KafkaInboundChannelAdapterSpec} with the consumer factory and
|
126 | 194 | * topics with a custom ack callback factory.
|
127 | 195 | * @param consumerFactory the consumer factory.
|
| 196 | + * @param consumerProperties the consumerProperties. |
128 | 197 | * @param ackCallbackFactory the callback factory.
|
129 | 198 | * @param allowMultiFetch true to fetch multiple records on each poll.
|
130 |
| - * @param topics the topic(s). |
131 | 199 | * @param <K> the Kafka message key type.
|
132 | 200 | * @param <V> the Kafka message value type.
|
133 | 201 | * @return the spec.
|
134 |
| - * @since 3.0.1 |
| 202 | + * @since 3.2 |
135 | 203 | */
|
136 | 204 | public static <K, V> KafkaInboundChannelAdapterSpec<K, V> inboundChannelAdapter(
|
137 | 205 | ConsumerFactory<K, V> consumerFactory,
|
| 206 | + ConsumerProperties consumerProperties, |
138 | 207 | KafkaAckCallbackFactory<K, V> ackCallbackFactory,
|
139 |
| - boolean allowMultiFetch, |
140 |
| - String... topics) { |
| 208 | + boolean allowMultiFetch) { |
141 | 209 |
|
142 |
| - return new KafkaInboundChannelAdapterSpec<>(consumerFactory, ackCallbackFactory, allowMultiFetch, topics); |
| 210 | + return new KafkaInboundChannelAdapterSpec<>(consumerFactory, consumerProperties, ackCallbackFactory, allowMultiFetch); |
143 | 211 | }
|
144 | 212 |
|
145 | 213 | /**
|
|
0 commit comments