クラス KafkaTestUtils
java.lang.ObjectSE
org.springframework.kafka.test.utils.KafkaTestUtils
Kafka テストユーティリティ。
- 作成者:
- Gary Russell, Hugo Wood, Artem Bilan, Sanghyeok An
メソッドのサマリー
修飾子と型メソッド説明consumerProps
(StringSE brokers, StringSE group) <Integer, String>
コンシューマーのテストプロパティを設定します。consumerProps
(StringSE brokers, StringSE group, StringSE autoCommit) <Integer, String>
コンシューマーのテストプロパティを設定します。consumerProps
(StringSE group, StringSE autoCommit, EmbeddedKafkaBroker embeddedKafka) <Integer, String>
コンシューマーのテストプロパティを設定します。static PropertiesSE
デフォルトのコンシューマープロパティのオーバーライドに等しいProperties
SE オブジェクトを返します。static org.apache.kafka.clients.consumer.OffsetAndMetadata
getCurrentOffset
(StringSE brokerAddresses, StringSE group, StringSE topic, int partition) 提供されたグループ / トピック / パーティションの現在のオフセットとメタデータを取得します。static org.apache.kafka.clients.consumer.OffsetAndMetadata
getCurrentOffset
(org.apache.kafka.clients.admin.AdminClient adminClient, StringSE group, StringSE topic, int partition) 提供されたグループ / トピック / パーティションの現在のオフセットとメタデータを取得します。getEndOffsets
(org.apache.kafka.clients.consumer.Consumer<?, ?> consumer, StringSE topic, IntegerSE... partitions) リクエストされたトピック / パーティションの終了オフセットを返しますstatic org.apache.kafka.clients.consumer.ConsumerRecord
<?, ?> getOneRecord
(StringSE brokerAddresses, StringSE group, StringSE topic, int partition, boolean seekToLast, boolean commit, DurationSE timeout) トピック / パーティションからグループの単一のレコードを取得します。static ObjectSE
getPropertyValue
(ObjectSE root, StringSE propertyPath) ネストされたDirectFieldAccessor
を使用して、ドット表記を使用してプロパティを取得し、フィールドをトラバースします。たとえばstatic <T> T
getPropertyValue
(ObjectSE root, StringSE propertyPath, ClassSE<T> type) getPropertyValue(Object, String)
の型付きバージョン。static <K,
V> org.apache.kafka.clients.consumer.ConsumerRecords <K, V> getRecords
(org.apache.kafka.clients.consumer.Consumer<K, V> consumer) 記録のためにコンシューマーをポーリングします。static <K,
V> org.apache.kafka.clients.consumer.ConsumerRecords <K, V> getRecords
(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, DurationSE timeout) 記録のためにコンシューマーをポーリングします。static <K,
V> org.apache.kafka.clients.consumer.ConsumerRecords <K, V> getRecords
(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, DurationSE timeout, int minRecords) 記録のためにコンシューマーをポーリングします。static <K,
V> org.apache.kafka.clients.consumer.ConsumerRecord <K, V> getSingleRecord
(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, StringSE topic) 指定されたトピックの単一のレコードを期待して、コンシューマーをポーリングします。static <K,
V> org.apache.kafka.clients.consumer.ConsumerRecord <K, V> getSingleRecord
(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, StringSE topic, DurationSE timeout) 指定されたトピックの単一のレコードを期待して、コンシューマーをポーリングします。producerProps
(StringSE brokers) <Integer, String>
プロデューサーのテストプロパティを設定します。producerProps
(EmbeddedKafkaBroker embeddedKafka) <Integer, String>
プロデューサーのテストプロパティを設定します。streamsProps
(StringSE applicationId, StringSE brokers) Kafka ストリームのテストプロパティを設定します。
メソッドの詳細
consumerProps
public static MapSE<StringSE,ObjectSE> consumerProps(StringSE group, StringSE autoCommit, EmbeddedKafkaBroker embeddedKafka) <Integer, String>
コンシューマーのテストプロパティを設定します。- パラメーター:
group
- グループ ID。autoCommit
- 自動コミット。embeddedKafka
-EmbeddedKafkaBroker
インスタンス。- 戻り値:
- プロパティ。
consumerProps
producerProps
<Integer, String>
プロデューサーのテストプロパティを設定します。- パラメーター:
embeddedKafka
-EmbeddedKafkaBroker
インスタンス。- 戻り値:
- プロパティ。
consumerProps
producerProps
streamsProps
getSingleRecord
public static <K,V> org.apache.kafka.clients.consumer.ConsumerRecord<K,V> getSingleRecord(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, StringSE topic) 指定されたトピックの単一のレコードを期待して、コンシューマーをポーリングします。- 型パラメーター:
K
- 鍵の型。V
- 値の型。- パラメーター:
consumer
- コンシューマー。topic
- トピック。- 戻り値:
- レコード。
- 例外:
IllegalStateExceptionSE
- 正確に 1 つのレコードが受信されない場合。- 関連事項:
getSingleRecord
public static <K,V> org.apache.kafka.clients.consumer.ConsumerRecord<K,V> getSingleRecord(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, StringSE topic, DurationSE timeout) 指定されたトピックの単一のレコードを期待して、コンシューマーをポーリングします。- 型パラメーター:
K
- 鍵の型。V
- 値の型。- パラメーター:
consumer
- コンシューマー。topic
- トピック。timeout
- レコードを待機する最大期間。Consumer.poll(Duration)
に転送されます。- 戻り値:
- レコード。
- 例外:
IllegalStateExceptionSE
- 正確に 1 つのレコードが受信されない場合。- 導入:
- 2.9.3
getOneRecord
@Nullable public static org.apache.kafka.clients.consumer.ConsumerRecord<?,?> getOneRecord(StringSE brokerAddresses, StringSE group, StringSE topic, int partition, boolean seekToLast, boolean commit, DurationSE timeout) トピック / パーティションからグループの単一のレコードを取得します。オプションで、現在の最後のレコードを探します。- パラメーター:
brokerAddresses
- ブローカーの住所。group
- グループ。topic
- トピック。partition
- パーティション。seekToLast
- 存在する場合、既存の最後のレコードをフェッチする場合は true。commit
- ポーリング後にオフセットをコミットするかどうか。timeout
- タイムアウト。- 戻り値:
- レコード。レコードを受信しなかった場合は null。
- 導入:
- 2.9.3
getCurrentOffset
public static org.apache.kafka.clients.consumer.OffsetAndMetadata getCurrentOffset(StringSE brokerAddresses, StringSE group, StringSE topic, int partition) throws ExceptionSE 提供されたグループ / トピック / パーティションの現在のオフセットとメタデータを取得します。- パラメーター:
brokerAddresses
- ブローカーの住所。group
- グループ。topic
- トピック。partition
- パーティション。- 戻り値:
- オフセットとメタデータ。
- 例外:
ExceptionSE
- 例外が発生した場合。- 導入:
- 2.3
getCurrentOffset
public static org.apache.kafka.clients.consumer.OffsetAndMetadata getCurrentOffset(org.apache.kafka.clients.admin.AdminClient adminClient, StringSE group, StringSE topic, int partition) throws ExceptionSE 提供されたグループ / トピック / パーティションの現在のオフセットとメタデータを取得します。- パラメーター:
adminClient
- AdminClient インスタンス。group
- グループ。topic
- トピック。partition
- パーティション。- 戻り値:
- オフセットとメタデータ。
- 例外:
ExceptionSE
- 例外が発生した場合。- 導入:
- 3.0
getEndOffsets
public static MapSE<org.apache.kafka.common.TopicPartition, LongSE> getEndOffsets(org.apache.kafka.clients.consumer.Consumer<?, ?> consumer, StringSE topic, IntegerSE... partitions) リクエストされたトピック / パーティションの終了オフセットを返します- パラメーター:
consumer
- コンシューマー。topic
- トピック。partitions
- パーティション、またはすべてのパーティションの場合は null。- 戻り値:
- エンドオフセットのマップ。
- 導入:
- 2.6.5
- 関連事項:
getRecords
public static <K,V> org.apache.kafka.clients.consumer.ConsumerRecords<K,V> getRecords(org.apache.kafka.clients.consumer.Consumer<K, V> consumer) 記録のためにコンシューマーをポーリングします。- 型パラメーター:
K
- 鍵の型。V
- 値の型。- パラメーター:
consumer
- コンシューマー。- 戻り値:
- 記録。
- 関連事項:
getRecords
public static <K,V> org.apache.kafka.clients.consumer.ConsumerRecords<K,V> getRecords(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, DurationSE timeout) 記録のためにコンシューマーをポーリングします。- 型パラメーター:
K
- 鍵の型。V
- 値の型。- パラメーター:
consumer
- コンシューマー。timeout
- レコードを待機する最大時間(ミリ秒単位)。Consumer.poll(Duration)
に転送されます。- 戻り値:
- 記録。
- 例外:
IllegalStateExceptionSE
- ポーリングが null を返した場合(2.3.4 以降)。- 導入:
- 2.9.3
getRecords
public static <K,V> org.apache.kafka.clients.consumer.ConsumerRecords<K,V> getRecords(org.apache.kafka.clients.consumer.Consumer<K, V> consumer, DurationSE timeout, int minRecords) 記録のためにコンシューマーをポーリングします。- 型パラメーター:
K
- 鍵の型。V
- 値の型。- パラメーター:
consumer
- コンシューマー。timeout
- レコードを待機する最大時間(ミリ秒単位)。Consumer.poll(Duration)
に転送されます。minRecords
- タイムアウトになるまで、または少なくともこの数のレコードが受信されるまで待ちます。- 戻り値:
- 記録。
- 例外:
IllegalStateExceptionSE
- ポーリングが null を返した場合。- 導入:
- 2.9.3
getPropertyValue
ネストされたDirectFieldAccessor
を使用して、ドット表記を使用してプロパティを取得し、フィールドをトラバースします。たとえば "foo.bar.baz" は、foo の bar フィールドの baz フィールドへの参照を取得します。Spring Integration から採用。- パラメーター:
root
- オブジェクト。propertyPath
- パス。- 戻り値:
- フィールド。
getPropertyValue
getPropertyValue(Object, String)
の型付きバージョン。- 型パラメーター:
T
- 型。- パラメーター:
root
- オブジェクト。propertyPath
- パス。type
- オブジェクトをキャストする型。- 戻り値:
- フィールド値。
- 関連事項:
defaultPropertyOverrides
デフォルトのコンシューマープロパティのオーバーライドに等しいProperties
SE オブジェクトを返します。Mockito テストで引数を照合するときに役立ちます。- 戻り値:
- デフォルトのプロパティ。
- 導入:
- 2.2.5