Java · Track 8 · Tutorial 2 of 4
Get told when a load finishes
Let BrizoConsol tell your system when each write has finished, instead of your system asking.
You will needThe monthly script from Put the steps in order, and a public address your system listens on.
By the endA run that tells your system as each write finishes.
1When a webhook helps
Instead of reading each request back, your system can be told when a write has finished. Add webhook_url to the declarations, and BrizoConsol posts the request's status there once - when it's written, or if it fails.
2Add it to the run
Monthly.java already adds it when BRIZO_WEBHOOK_URL is set:
Monthly.java
static Map<String, Object> declarations(String source, String period, String currency, String webhook) {
Map<String, Object> declarations = new LinkedHashMap<>();
declarations.put("source_reference", source);
declarations.put("period", period);
declarations.put("value_basis", "company_base");
declarations.put("rate_direction", "document_to_base");
declarations.put("base_currency", currency);
if (webhook != null) {
declarations.put("webhook_url", webhook);
}
return declarations;
}3What arrives
A POST with the same body GET …/requests/{id} answers: the counts, any refusals, and recalculation. For a trial balance that reads pending, because the call comes when the write finishes - the consolidation is still to run.
4The rules
- The address must be public: an internal or private address isn't called.
- Redirects aren't followed.
- A call that fails is recorded on the request and never fails it - read the request back to see what happened.
Want more detail? See the documentation