Search in sources :

Example 1 with KinesisProducer

use of com.amazonaws.services.kinesis.producer.KinesisProducer in project beam by apache.

the class BasicKinesisProvider method createKinesisProducer.

@Override
public IKinesisProducer createKinesisProducer(KinesisProducerConfiguration config) {
    config.setRegion(region.getName());
    config.setCredentialsProvider(getCredentialsProvider());
    if (serviceEndpoint != null) {
        URI uri = URI.create(serviceEndpoint);
        config.setKinesisEndpoint(uri.getHost());
        config.setKinesisPort(uri.getPort());
    }
    config.setVerifyCertificate(verifyCertificate);
    return new KinesisProducer(config);
}
Also used : KinesisProducer(com.amazonaws.services.kinesis.producer.KinesisProducer) IKinesisProducer(com.amazonaws.services.kinesis.producer.IKinesisProducer) URI(java.net.URI)

Example 2 with KinesisProducer

use of com.amazonaws.services.kinesis.producer.KinesisProducer in project flink by apache.

the class FlinkKinesisProducer method close.

@Override
public void close() throws Exception {
    LOG.info("Closing producer");
    super.close();
    KinesisProducer kp = this.producer;
    this.producer = null;
    if (kp != null) {
        LOG.info("Flushing outstanding {} records", kp.getOutstandingRecordsCount());
        // try to flush all outstanding records
        while (kp.getOutstandingRecordsCount() > 0) {
            kp.flush();
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                LOG.warn("Flushing was interrupted.");
                // stop the blocking flushing and destroy producer immediately
                break;
            }
        }
        LOG.info("Flushing done. Destroying producer instance.");
        kp.destroy();
    }
}
Also used : KinesisProducer(com.amazonaws.services.kinesis.producer.KinesisProducer)

Aggregations

KinesisProducer (com.amazonaws.services.kinesis.producer.KinesisProducer)2 IKinesisProducer (com.amazonaws.services.kinesis.producer.IKinesisProducer)1 URI (java.net.URI)1