use of org.talend.components.common.runtime.GenericIndexedRecordConverter in project components by Talend.
the class AzureStorageQueueWriter method write.
@Override
public void write(Object object) throws IOException {
String content;
if (object == null)
return;
cleanWrites();
result.totalCount++;
if (writeSchema == null) {
writeSchema = ((IndexedRecord) object).getSchema();
}
GenericIndexedRecordConverter factory = new GenericIndexedRecordConverter();
factory.setSchema(writeSchema);
IndexedRecord inputRecord = factory.convertToAvro((IndexedRecord) object);
Field msgContent = writeSchema.getField(AzureStorageQueueProperties.FIELD_MESSAGE_CONTENT);
int ttl = props.timeToLiveInSeconds.getValue();
int visibility = props.initialVisibilityDelayInSeconds.getValue();
if (msgContent == null) {
LOGGER.error(i18nMessages.getMessage("error.VacantMessage"));
if (props.dieOnError.getValue()) {
throw new ComponentException(new Exception(i18nMessages.getMessage("error.VacantMessage")));
}
} else {
content = (String) inputRecord.get(msgContent.pos());
messagesBuffer.add(new QueueMessage(new CloudQueueMessage(content), ttl, visibility));
}
if (messagesBuffer.size() >= MAX_MSG_TO_ENQUEUE) {
sendParallelMessages();
}
}
Aggregations