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);
}
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();
}
}
Aggregations