Search in sources :

Example 1 with KafkaProducerClient

use of com.ibm.streamsx.kafka.clients.producer.KafkaProducerClient in project streamsx.kafka by IBMStreams.

the class AbstractKafkaProducerOperator method initProducer.

private void initProducer() throws Exception {
    // configure producer
    KafkaOperatorProperties props = getKafkaProperties();
    if (crContext == null) {
        logger.info("Creating KafkaProducerClient...");
        producer = new KafkaProducerClient(getOperatorContext(), keyType, messageType, props);
    } else {
        switch(consistentRegionPolicy) {
            case AtLeastOnce:
                logger.info("Creating AtLeastOnceKafkaProducerClient...");
                producer = new AtLeastOnceKafkaProducerClient(getOperatorContext(), keyType, messageType, props);
                break;
            case Transactional:
                logger.info("Creating TransactionalKafkaProducerClient...");
                producer = new TransactionalKafkaProducerClient(getOperatorContext(), keyType, messageType, props, /*lazyTransactionBegin*/
                true);
                break;
            default:
                throw new RuntimeException("Unrecognized ConsistentRegionPolicy: " + consistentRegionPolicy);
        }
    }
}
Also used : TransactionalKafkaProducerClient(com.ibm.streamsx.kafka.clients.producer.TransactionalKafkaProducerClient) AtLeastOnceKafkaProducerClient(com.ibm.streamsx.kafka.clients.producer.AtLeastOnceKafkaProducerClient) TransactionalKafkaProducerClient(com.ibm.streamsx.kafka.clients.producer.TransactionalKafkaProducerClient) KafkaProducerClient(com.ibm.streamsx.kafka.clients.producer.KafkaProducerClient) AtLeastOnceKafkaProducerClient(com.ibm.streamsx.kafka.clients.producer.AtLeastOnceKafkaProducerClient) KafkaOperatorProperties(com.ibm.streamsx.kafka.properties.KafkaOperatorProperties)

Aggregations

AtLeastOnceKafkaProducerClient (com.ibm.streamsx.kafka.clients.producer.AtLeastOnceKafkaProducerClient)1 KafkaProducerClient (com.ibm.streamsx.kafka.clients.producer.KafkaProducerClient)1 TransactionalKafkaProducerClient (com.ibm.streamsx.kafka.clients.producer.TransactionalKafkaProducerClient)1 KafkaOperatorProperties (com.ibm.streamsx.kafka.properties.KafkaOperatorProperties)1