use of org.apache.rya.periodic.notification.api.BindingSetRecordExportException in project incubator-rya by apache.
the class KafkaPeriodicBindingSetExporter method exportNotification.
/**
* Exports BindingSets to Kafka. The BindingSet and topic are extracted from
* the indicated BindingSetRecord and the BindingSet is then exported to the topic.
*/
@Override
public void exportNotification(final BindingSetRecord record) throws BindingSetRecordExportException {
try {
log.info("Exporting {} records to Kafka to topic: {}", record.getBindingSet().size(), record.getTopic());
final String bindingName = IncrementalUpdateConstants.PERIODIC_BIN_ID;
final BindingSet bindingSet = record.getBindingSet();
final String topic = record.getTopic();
final long binId = ((Literal) bindingSet.getValue(bindingName)).longValue();
final Future<RecordMetadata> future = producer.send(new ProducerRecord<String, BindingSet>(topic, Long.toString(binId), bindingSet));
// wait for confirmation that results have been received
future.get(5, TimeUnit.SECONDS);
} catch (final Exception e) {
// catch all possible exceptional behavior and throw as our checked exception.
throw new BindingSetRecordExportException(e.getMessage(), e);
}
}
Aggregations