Search in sources :

Example 1 with UnsupportedForMessageFormatException

use of org.apache.kafka.common.errors.UnsupportedForMessageFormatException in project kafka by apache.

the class TransactionManagerTest method testUnsupportedForMessageFormatInTxnOffsetCommit.

@Test
public void testUnsupportedForMessageFormatInTxnOffsetCommit() {
    final TopicPartition tp = new TopicPartition("foo", 0);
    doInitTransactions();
    transactionManager.beginTransaction();
    TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(tp, new OffsetAndMetadata(39L)), new ConsumerGroupMetadata(consumerGroupId));
    prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, producerId, epoch);
    prepareFindCoordinatorResponse(Errors.NONE, false, CoordinatorType.GROUP, consumerGroupId);
    prepareTxnOffsetCommitResponse(consumerGroupId, producerId, epoch, singletonMap(tp, Errors.UNSUPPORTED_FOR_MESSAGE_FORMAT));
    runUntil(transactionManager::hasError);
    assertTrue(transactionManager.lastError() instanceof UnsupportedForMessageFormatException);
    assertTrue(sendOffsetsResult.isCompleted());
    assertFalse(sendOffsetsResult.isSuccessful());
    assertTrue(sendOffsetsResult.error() instanceof UnsupportedForMessageFormatException);
    assertFatalError(UnsupportedForMessageFormatException.class);
}
Also used : UnsupportedForMessageFormatException(org.apache.kafka.common.errors.UnsupportedForMessageFormatException) ConsumerGroupMetadata(org.apache.kafka.clients.consumer.ConsumerGroupMetadata) TopicPartition(org.apache.kafka.common.TopicPartition) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) Test(org.junit.jupiter.api.Test)

Example 2 with UnsupportedForMessageFormatException

use of org.apache.kafka.common.errors.UnsupportedForMessageFormatException in project apache-kafka-on-k8s by banzaicloud.

the class TransactionManagerTest method testUnsupportedForMessageFormatInTxnOffsetCommit.

@Test
public void testUnsupportedForMessageFormatInTxnOffsetCommit() {
    final String consumerGroupId = "consumer";
    final long pid = 13131L;
    final short epoch = 1;
    final TopicPartition tp = new TopicPartition("foo", 0);
    doInitTransactions(pid, epoch);
    transactionManager.beginTransaction();
    TransactionalRequestResult sendOffsetsResult = transactionManager.sendOffsetsToTransaction(singletonMap(tp, new OffsetAndMetadata(39L)), consumerGroupId);
    prepareAddOffsetsToTxnResponse(Errors.NONE, consumerGroupId, pid, epoch);
    // AddOffsetsToTxn Handled, TxnOffsetCommit Enqueued
    sender.run(time.milliseconds());
    // FindCoordinator Enqueued
    sender.run(time.milliseconds());
    prepareFindCoordinatorResponse(Errors.NONE, false, CoordinatorType.GROUP, consumerGroupId);
    // FindCoordinator Returned
    sender.run(time.milliseconds());
    prepareTxnOffsetCommitResponse(consumerGroupId, pid, epoch, singletonMap(tp, Errors.UNSUPPORTED_FOR_MESSAGE_FORMAT));
    // TxnOffsetCommit Handled
    sender.run(time.milliseconds());
    assertTrue(transactionManager.hasError());
    assertTrue(transactionManager.lastError() instanceof UnsupportedForMessageFormatException);
    assertTrue(sendOffsetsResult.isCompleted());
    assertFalse(sendOffsetsResult.isSuccessful());
    assertTrue(sendOffsetsResult.error() instanceof UnsupportedForMessageFormatException);
    assertFatalError(UnsupportedForMessageFormatException.class);
}
Also used : UnsupportedForMessageFormatException(org.apache.kafka.common.errors.UnsupportedForMessageFormatException) TopicPartition(org.apache.kafka.common.TopicPartition) OffsetAndMetadata(org.apache.kafka.clients.consumer.OffsetAndMetadata) Test(org.junit.Test)

Aggregations

OffsetAndMetadata (org.apache.kafka.clients.consumer.OffsetAndMetadata)2 TopicPartition (org.apache.kafka.common.TopicPartition)2 UnsupportedForMessageFormatException (org.apache.kafka.common.errors.UnsupportedForMessageFormatException)2 ConsumerGroupMetadata (org.apache.kafka.clients.consumer.ConsumerGroupMetadata)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1