|
19 | 19 | import java.util.Collection; |
20 | 20 | import java.util.Map; |
21 | 21 | import java.util.concurrent.locks.ReentrantLock; |
| 22 | +import java.util.function.Function; |
22 | 23 |
|
23 | 24 | import org.apache.commons.logging.LogFactory; |
24 | 25 | import org.apache.kafka.common.Metric; |
25 | 26 | import org.apache.kafka.common.MetricName; |
26 | 27 | import org.apache.kafka.common.TopicPartition; |
27 | 28 |
|
| 29 | +import org.springframework.context.ApplicationContext; |
| 30 | +import org.springframework.context.ApplicationEventPublisher; |
28 | 31 | import org.springframework.core.log.LogAccessor; |
| 32 | +import org.springframework.kafka.core.KafkaAdmin; |
29 | 33 | import org.springframework.kafka.event.ConsumerStoppedEvent; |
| 34 | +import org.springframework.lang.Nullable; |
30 | 35 |
|
31 | 36 | /** |
32 | 37 | * Reference of {@link ConcurrentMessageListenerContainer} to be passed to the {@link KafkaMessageListenerContainer}. |
@@ -268,18 +273,141 @@ else if (this.concurrentMessageListenerContainer.isFenced() && |
268 | 273 | } |
269 | 274 | } |
270 | 275 |
|
271 | | - AbstractMessageListenerContainer<?, ?> getConcurrentContainer() { |
272 | | - return this.concurrentMessageListenerContainer; |
| 276 | + @Nullable |
| 277 | + protected ApplicationContext getApplicationContext() { |
| 278 | + return this.concurrentMessageListenerContainer.getApplicationContext(); |
273 | 279 | } |
274 | 280 |
|
275 | | - @Override |
276 | | - public int hashCode() { |
277 | | - return this.concurrentMessageListenerContainer.hashCode(); |
| 281 | + /** |
| 282 | + * Get the event publisher. |
| 283 | + * @return the publisher |
| 284 | + */ |
| 285 | + @Nullable |
| 286 | + public ApplicationEventPublisher getApplicationEventPublisher() { |
| 287 | + return this.concurrentMessageListenerContainer.getApplicationEventPublisher(); |
278 | 288 | } |
279 | 289 |
|
280 | | - @Override |
281 | | - public boolean equals(Object obj) { |
282 | | - return this.concurrentMessageListenerContainer.equals(obj); |
| 290 | + /** |
| 291 | + * Get the {@link CommonErrorHandler}. |
| 292 | + * @return the handler. |
| 293 | + * @since 2.8 |
| 294 | + */ |
| 295 | + @Nullable |
| 296 | + public CommonErrorHandler getCommonErrorHandler() { |
| 297 | + return this.concurrentMessageListenerContainer.getCommonErrorHandler(); |
| 298 | + } |
| 299 | + |
| 300 | + protected boolean isStoppedNormally() { |
| 301 | + return this.concurrentMessageListenerContainer.isStoppedNormally(); |
| 302 | + } |
| 303 | + |
| 304 | + protected void setStoppedNormally(boolean stoppedNormally) { |
| 305 | + this.concurrentMessageListenerContainer.setStoppedNormally(stoppedNormally); |
| 306 | + } |
| 307 | + |
| 308 | + protected void setRunning(boolean running) { |
| 309 | + this.concurrentMessageListenerContainer.setRunning(running); |
| 310 | + } |
| 311 | + |
| 312 | + protected boolean isEnforceRebalanceRequested() { |
| 313 | + return this.concurrentMessageListenerContainer.isEnforceRebalanceRequested(); |
| 314 | + } |
| 315 | + |
| 316 | + protected void setEnforceRebalanceRequested(boolean enforceRebalance) { |
| 317 | + this.concurrentMessageListenerContainer.setEnforceRebalanceRequested(enforceRebalance); |
| 318 | + } |
| 319 | + |
| 320 | + /** |
| 321 | + * Return the currently configured {@link AfterRollbackProcessor}. |
| 322 | + * @return the after rollback processor. |
| 323 | + * @since 2.2.14 |
| 324 | + */ |
| 325 | + public AfterRollbackProcessor<? super K, ? super V> getAfterRollbackProcessor() { |
| 326 | + return this.concurrentMessageListenerContainer.getAfterRollbackProcessor(); |
| 327 | + } |
| 328 | + |
| 329 | + public boolean isChangeConsumerThreadName() { |
| 330 | + return this.concurrentMessageListenerContainer.isChangeConsumerThreadName(); |
| 331 | + } |
| 332 | + |
| 333 | + /** |
| 334 | + * Set to true to instruct the container to change the consumer thread name during |
| 335 | + * initialization. |
| 336 | + * @param changeConsumerThreadName true to change. |
| 337 | + * @since 3.0.1 |
| 338 | + * @see #setThreadNameSupplier(Function) |
| 339 | + */ |
| 340 | + public void setChangeConsumerThreadName(boolean changeConsumerThreadName) { |
| 341 | + this.concurrentMessageListenerContainer.setChangeConsumerThreadName(changeConsumerThreadName); |
| 342 | + } |
| 343 | + |
| 344 | + /** |
| 345 | + * Return the {@link KafkaAdmin}, used to find the cluster id for observation, if |
| 346 | + * present. |
| 347 | + * @return the kafkaAdmin |
| 348 | + * @since 3.0.5 |
| 349 | + */ |
| 350 | + @Nullable |
| 351 | + public KafkaAdmin getKafkaAdmin() { |
| 352 | + return this.concurrentMessageListenerContainer.getKafkaAdmin(); |
| 353 | + } |
| 354 | + |
| 355 | + public void setKafkaAdmin(KafkaAdmin kafkaAdmin) { |
| 356 | + this.concurrentMessageListenerContainer.setKafkaAdmin(kafkaAdmin); |
| 357 | + } |
| 358 | + |
| 359 | + protected RecordInterceptor<K, V> getRecordInterceptor() { |
| 360 | + return this.concurrentMessageListenerContainer.getRecordInterceptor(); |
| 361 | + } |
| 362 | + |
| 363 | + /** |
| 364 | + * Set an interceptor to be called before calling the record listener. |
| 365 | + * Does not apply to batch listeners. |
| 366 | + * @param recordInterceptor the interceptor. |
| 367 | + * @since 2.2.7 |
| 368 | + * @see #setInterceptBeforeTx(boolean) |
| 369 | + */ |
| 370 | + public void setRecordInterceptor(RecordInterceptor recordInterceptor) { |
| 371 | + this.concurrentMessageListenerContainer.setRecordInterceptor(recordInterceptor); |
| 372 | + } |
| 373 | + |
| 374 | + protected BatchInterceptor<K, V> getBatchInterceptor() { |
| 375 | + return this.concurrentMessageListenerContainer.getBatchInterceptor(); |
| 376 | + } |
| 377 | + |
| 378 | + /** |
| 379 | + * Set an interceptor to be called before calling the record listener. |
| 380 | + * @param batchInterceptor the interceptor. |
| 381 | + * @since 2.6.6 |
| 382 | + * @see #setInterceptBeforeTx(boolean) |
| 383 | + */ |
| 384 | + public void setBatchInterceptor(BatchInterceptor batchInterceptor) { |
| 385 | + this.concurrentMessageListenerContainer.setBatchInterceptor(batchInterceptor); |
| 386 | + } |
| 387 | + |
| 388 | + protected boolean isInterceptBeforeTx() { |
| 389 | + return this.concurrentMessageListenerContainer.isInterceptBeforeTx(); |
| 390 | + } |
| 391 | + |
| 392 | + /** |
| 393 | + * When false, invoke the interceptor after the transaction starts. |
| 394 | + * @param interceptBeforeTx false to intercept within the transaction. |
| 395 | + * Default true since 2.8. |
| 396 | + * @since 2.3.4 |
| 397 | + * @see #setRecordInterceptor(RecordInterceptor) |
| 398 | + * @see #setBatchInterceptor(BatchInterceptor) |
| 399 | + */ |
| 400 | + public void setInterceptBeforeTx(boolean interceptBeforeTx) { |
| 401 | + this.concurrentMessageListenerContainer.setInterceptBeforeTx(interceptBeforeTx); |
| 402 | + } |
| 403 | + |
| 404 | + /** |
| 405 | + * Return this or a parent container if this has a parent. |
| 406 | + * @return the parent or this. |
| 407 | + * @since 2.2.1 |
| 408 | + */ |
| 409 | + protected AbstractMessageListenerContainer<?, ?> parentOrThis() { |
| 410 | + return this; |
283 | 411 | } |
284 | 412 |
|
285 | 413 | } |
0 commit comments