Search in sources :

Example 1 with InitProducerIdResponseData

use of org.apache.kafka.common.message.InitProducerIdResponseData in project kafka by apache.

the class TransactionManagerTest method prepareInitPidResponse.

private void prepareInitPidResponse(Errors error, boolean shouldDisconnect, long producerId, short producerEpoch) {
    InitProducerIdResponseData responseData = new InitProducerIdResponseData().setErrorCode(error.code()).setProducerEpoch(producerEpoch).setProducerId(producerId).setThrottleTimeMs(0);
    client.prepareResponse(body -> {
        InitProducerIdRequest initProducerIdRequest = (InitProducerIdRequest) body;
        assertEquals(transactionalId, initProducerIdRequest.data().transactionalId());
        assertEquals(transactionTimeoutMs, initProducerIdRequest.data().transactionTimeoutMs());
        return true;
    }, new InitProducerIdResponse(responseData), shouldDisconnect);
}
Also used : InitProducerIdResponseData(org.apache.kafka.common.message.InitProducerIdResponseData) InitProducerIdRequest(org.apache.kafka.common.requests.InitProducerIdRequest) InitProducerIdResponse(org.apache.kafka.common.requests.InitProducerIdResponse)

Example 2 with InitProducerIdResponseData

use of org.apache.kafka.common.message.InitProducerIdResponseData in project kafka by apache.

the class TransactionManagerTest method initializeIdempotentProducerId.

private void initializeIdempotentProducerId(long producerId, short epoch) {
    InitProducerIdResponseData responseData = new InitProducerIdResponseData().setErrorCode(Errors.NONE.code()).setProducerEpoch(epoch).setProducerId(producerId).setThrottleTimeMs(0);
    client.prepareResponse(body -> {
        InitProducerIdRequest initProducerIdRequest = (InitProducerIdRequest) body;
        assertNull(initProducerIdRequest.data().transactionalId());
        return true;
    }, new InitProducerIdResponse(responseData), false);
    runUntil(transactionManager::hasProducerId);
}
Also used : InitProducerIdResponseData(org.apache.kafka.common.message.InitProducerIdResponseData) InitProducerIdRequest(org.apache.kafka.common.requests.InitProducerIdRequest) InitProducerIdResponse(org.apache.kafka.common.requests.InitProducerIdResponse)

Aggregations

InitProducerIdResponseData (org.apache.kafka.common.message.InitProducerIdResponseData)2 InitProducerIdRequest (org.apache.kafka.common.requests.InitProducerIdRequest)2 InitProducerIdResponse (org.apache.kafka.common.requests.InitProducerIdResponse)2