クラス DeadLetterPublishingRecovererFactory

java.lang.ObjectSE
org.springframework.kafka.retrytopic.DeadLetterPublishingRecovererFactory

public class DeadLetterPublishingRecovererFactory extends ObjectSE
DestinationTopicResolver を使用してメッセージを転送するために使用される DeadLetterPublishingRecoverer を作成および構成します。
導入:
2.7
作成者:
Tomaz Fernandes, Gary Russell, Soby Chacko, Artem Bilan
  • コンストラクターの詳細

    • DeadLetterPublishingRecovererFactory

      public DeadLetterPublishingRecovererFactory(DestinationTopicResolver destinationTopicResolver)
  • メソッドの詳細

    • setHeadersFunction

      public void setHeadersFunction(BiFunctionSE<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>, ExceptionSE, @Nullable org.apache.kafka.common.header.Headers> headersFunction)
      このファクトリによって追加された標準の再試行ヘッダーに加えて、出力レコードに追加のヘッダーを作成する関数を設定します。
      パラメーター:
      headersFunction - 関数。
      導入:
      2.8.4
    • setPartitionResolver

      public void setPartitionResolver(BiFunctionSE<org.apache.kafka.clients.consumer.ConsumerRecord<?,?>, @Nullable StringSE, @Nullable IntegerSE> resolver)
      パブリッシュ先のパーティション番号のリゾルバーを設定します。デフォルトでは、コンシューマーレコードと同じパーティションが使用されます。リゾルバーが null または負の数を返した場合、プロデューサーレコードのパーティションは null に設定され、KafkaProducer がパブリッシュ先のパーティションを決定します。
      パラメーター:
      resolver - リゾルバー。
      導入:
      2.9.2
    • setRetainAllRetryHeaderValues

      public void setRetainAllRetryHeaderValues(boolean retainAllRetryHeaderValues)
      RetryTopicHeaders の最後の値のみを保持するには、false に設定します。デフォルトでは true で、レコードがトピック間を遷移するときにすべての値が保持されます。
      パラメーター:
      retainAllRetryHeaderValues - 最後の値のみを保存する場合は false。
      導入:
      2.9.6
    • setDeadLetterPublisherCreator

      public void setDeadLetterPublisherCreator(DeadLetterPublishingRecovererFactory.DeadLetterPublisherCreator creator)
      DeadLetterPublishingRecovererFactory.DeadLetterPublisherCreator を指定します。たとえば、パブリッシュされたレコードを変更する場合など、デフォルトの代わりに DeadLetterPublishingRecoverer のサブクラスを作成するために使用されます。
      パラメーター:
      creator - クリエイター
      導入:
      3.0.9.
    • setDeadLetterPublishingRecovererCustomizer

      public void setDeadLetterPublishingRecovererCustomizer(ConsumerSE<DeadLetterPublishingRecoverer> customizer)
      カスタマイザを設定してデフォルトの DeadLetterPublishingRecoverer をカスタマイズします。
      パラメーター:
      customizer - カスタマイザー。
      関連事項:
    • addNotRetryableException

      public final void addNotRetryableException(ClassSE<? extends ExceptionSE> exceptionType)
      デフォルトリストに例外型を追加します。デフォルトでは、次の例外は再試行されません。 その他はすべて再試行されます。
      パラメーター:
      exceptionType - 例外型。
      導入:
      2.8
      関連事項:
    • removeNotRetryableException

      public boolean removeNotRetryableException(ClassSE<? extends ExceptionSE> exceptionType)
      構成済みリストから例外型を削除します。デフォルトでは、次の例外は再試行されません。 その他はすべて再試行されます。
      パラメーター:
      exceptionType - 例外型。
      戻り値:
      削除が成功した場合は true。
      関連事項:
    • neverLogListenerException

      public void neverLogListenerException()
      リスナー例外をログに記録しないでください。デフォルトでは、再試行が終了した後にのみログに記録されます。
      導入:
      2.7.13
    • alwaysLogListenerException

      public void alwaysLogListenerException()
      試行ごとにリスナー例外をログに記録します。デフォルトでは、再試行が終了した後にのみログに記録されます。
      導入:
      2.7.13
    • create

      public DeadLetterPublishingRecoverer create(StringSE mainListenerId)
    • maybeLogListenerException

      protected void maybeLogListenerException(ExceptionSE exception, org.apache.kafka.clients.consumer.ConsumerRecord<?,?> consumerRecord, DestinationTopic nextDestination)
      エラーのあるレコードを再試行トピックに送信する前に、例外をログに記録します。このメソッドは、下流のアプリケーションによってオーバーライドされ、エラーのログ記録方法をカスタマイズできます。
      パラメーター:
      exception - エラーの原因となった例外
      consumerRecord - 元のコンシューマー記録
      nextDestination - 記録が進む次のトピック
      導入:
      3.3.0
    • resolveTopicPartition

      protected org.apache.kafka.common.TopicPartition resolveTopicPartition(org.apache.kafka.clients.consumer.ConsumerRecord<?,?> cr, DestinationTopic nextDestination)
      Creates and returns the TopicPartition, where the original record should be forwarded. By default, it will use the same partition as the original record's partition, in the next destination topic.

      DeadLetterPublishingRecoverer#checkPartition has logic to check whether that partition exists, and if it doesn't, it sets -1, to allow the Producer itself to assign a partition to the record.

      サブクラスは、必要に応じて、このメソッドから継承して実装をオーバーライドできます。

      setPartitionResolver(BiFunction) を使用して宛先パーティションをカスタマイズすることもできます。
      パラメーター:
      cr - DLT に転送される元の ConsumerRecord
      nextDestination - consumerRecord が転送される次の DestinationTopic
      戻り値:
      cr が送信されるトピックとパーティションを指定する TopicPartition のインスタンス。
      関連事項: