use of org.jumpmind.symmetric.transport.ITransportManager in project symmetric-ds by JumpMind.
the class PushService method updateBatchStatus.
protected Status updateBatchStatus(OutgoingBatch batch, Node targetNode, Node identityNode, NodeSecurity identitySecurity) {
OutgoingBatch.Status returnStatus = batch.getStatus();
ITransportManager transportManager = engine.getTransportManager();
IAcknowledgeService acknowledgeService = engine.getAcknowledgeService();
IIncomingTransport transport = null;
try {
transport = transportManager.getAckStatusTransport(batch, targetNode, identityNode, identitySecurity.getNodePassword(), parameterService.getRegistrationUrl());
BufferedReader reader = transport.openReader();
String line = null;
do {
line = reader.readLine();
if (line != null) {
log.info("Updating batch status: {}", line);
List<BatchAck> batchAcks = transportManager.readAcknowledgement(line, "");
for (BatchAck batchInfo : batchAcks) {
if (batchInfo.getBatchId() == batch.getBatchId()) {
acknowledgeService.ack(batchInfo);
returnStatus = batchInfo.getStatus();
}
}
}
} while (line != null);
} catch (FileNotFoundException ex) {
log.info("Failed to read batch status for {}. It is probably because the server is not online yet", batch.getNodeBatchId());
} catch (Exception ex) {
log.warn(String.format("Failed to read the batch status for %s", batch.getNodeBatchId()), ex);
} finally {
transport.close();
}
return returnStatus;
}
Aggregations