|
33 | 33 | import org.springframework.scheduling.TaskScheduler; |
34 | 34 | import org.springframework.transaction.PlatformTransactionManager; |
35 | 35 | import org.springframework.util.Assert; |
| 36 | +import org.springframework.util.StringUtils; |
36 | 37 |
|
37 | 38 | /** |
38 | 39 | * Contains runtime properties for a listener container. |
@@ -159,6 +160,8 @@ public class ContainerProperties { |
159 | 160 |
|
160 | 161 | private String clientId = ""; |
161 | 162 |
|
| 163 | + private boolean logContainerConfig; |
| 164 | + |
162 | 165 | public ContainerProperties(String... topics) { |
163 | 166 | Assert.notEmpty(topics, "An array of topicPartitions must be provided"); |
164 | 167 | this.topics = Arrays.asList(topics).toArray(new String[topics.length]); |
@@ -204,6 +207,7 @@ public void setMessageListener(Object messageListener) { |
204 | 207 | * @param ackMode the {@link AckMode}; default BATCH. |
205 | 208 | */ |
206 | 209 | public void setAckMode(AbstractMessageListenerContainer.AckMode ackMode) { |
| 210 | + Assert.notNull(ackMode, "'ackMode' cannot be null"); |
207 | 211 | this.ackMode = ackMode; |
208 | 212 | } |
209 | 213 |
|
@@ -483,4 +487,55 @@ public void setClientId(String clientId) { |
483 | 487 | this.clientId = clientId; |
484 | 488 | } |
485 | 489 |
|
| 490 | + /** |
| 491 | + * Log the container configuration if true (INFO). |
| 492 | + * @return true to log. |
| 493 | + * @since 2.0.1 |
| 494 | + */ |
| 495 | + public boolean isLogContainerConfig() { |
| 496 | + return this.logContainerConfig; |
| 497 | + } |
| 498 | + |
| 499 | + /** |
| 500 | + * Set to true to instruct each container to log this configuration. |
| 501 | + * @param logContainerConfig true to log. |
| 502 | + * @since 2.1.1 |
| 503 | + */ |
| 504 | + public void setLogContainerConfig(boolean logContainerConfig) { |
| 505 | + this.logContainerConfig = logContainerConfig; |
| 506 | + } |
| 507 | + |
| 508 | + @Override |
| 509 | + public String toString() { |
| 510 | + return "ContainerProperties [" |
| 511 | + + (this.topics != null ? "topics=" + Arrays.toString(this.topics) : "") |
| 512 | + + (this.topicPattern != null ? ", topicPattern=" + this.topicPattern : "") |
| 513 | + + (this.topicPartitions != null |
| 514 | + ? ", topicPartitions=" + Arrays.toString(this.topicPartitions) : "") |
| 515 | + + ", ackMode=" + this.ackMode |
| 516 | + + ", ackCount=" + this.ackCount |
| 517 | + + ", ackTime=" + this.ackTime |
| 518 | + + ", messageListener=" + this.messageListener |
| 519 | + + ", pollTimeout=" + this.pollTimeout |
| 520 | + + (this.consumerTaskExecutor != null |
| 521 | + ? ", consumerTaskExecutor=" + this.consumerTaskExecutor : "") |
| 522 | + + (this.errorHandler != null ? ", errorHandler=" + this.errorHandler : "") |
| 523 | + + ", shutdownTimeout=" + this.shutdownTimeout |
| 524 | + + (this.consumerRebalanceListener != null |
| 525 | + ? ", consumerRebalanceListener=" + this.consumerRebalanceListener : "") |
| 526 | + + (this.commitCallback != null ? ", commitCallback=" + this.commitCallback : "") |
| 527 | + + ", syncCommits=" + this.syncCommits |
| 528 | + + ", ackOnError=" + this.ackOnError |
| 529 | + + ", idleEventInterval=" |
| 530 | + + (this.idleEventInterval == null ? "not enabled" : this.idleEventInterval) |
| 531 | + + (this.groupId != null ? ", groupId=" + this.groupId : "") |
| 532 | + + (this.transactionManager != null |
| 533 | + ? ", transactionManager=" + this.transactionManager : "") |
| 534 | + + ", monitorInterval=" + this.monitorInterval |
| 535 | + + (this.scheduler != null ? ", scheduler=" + this.scheduler : "") |
| 536 | + + ", noPollThreshold=" + this.noPollThreshold |
| 537 | + + (StringUtils.hasText(this.clientId) ? ", clientId=" + this.clientId : "") |
| 538 | + + "]"; |
| 539 | + } |
| 540 | + |
486 | 541 | } |
0 commit comments