Skip to content

Commit

Permalink
fixed webhook logic to disable unresponsive hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
albogdano committed Mar 12, 2021
1 parent 49fb076 commit 2237f1c
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions para-server/src/main/java/com/erudika/para/queue/River.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,16 @@ protected int processWebhookPayload(String appid, String id, Map<String, Object>
ok = true;
}
} catch (Exception e) {
logger.info("Webhook not delivered! {} isn't responding. {}", targetUrl, status);
logger.info("Webhook {} not delivered! {} isn't responding. {}", id, targetUrl, status);
} finally {
if (!ok) {
// count failed delivieries and disable that webhook object after X failed attempts
String countId = "failed_webhook_count" + Config.SEPARATOR + id;
Integer count = Para.getCache().get(appid, countId);
if (count == null) {
Para.getCache().put(appid, countId, 1);
} else if (count >= (MAX_FAILED_WEBHOOK_ATTEMPTS - 1)) {
count = 0;
}
if (count >= (MAX_FAILED_WEBHOOK_ATTEMPTS - 1)) {
Webhook hook = Para.getDAO().read(appid, id);
if (hook != null) {
hook.setActive(false);
Expand Down

0 comments on commit 2237f1c

Please sign in to comment.