Page 1 of 1

Webhooks Bug??

PostPosted: Mon May 17, 2021 11:31 am
by SBarnes
The below code inserts into SY_WebhookMessage when an attempted post doesn't work, however it is not taking into account whether or not the subscriber itself is enabled.

Code: Select all
string sql = @"INSERT INTO SY_WebhookMessage(RecID, SY_WebhookSubscription_RecID, Body, ItemNo, Status, LastSavedDateTime, AddedDateTime, Retries)
                  SELECT NewID(), SY_WebhookSubscription.RecID, @Body,
                  COALESCE(QueueTable.MaximumItemNo, 0) + ROW_NUMBER() OVER (ORDER BY (SELECT NULL)),
                  0, SYSUTCDATETIME(), SYSUTCDATETIME(), 0
                  FROM SY_WebhookSubscription
                  CROSS JOIN (SELECT MAX(ItemNo) AS MaximumItemNo FROM SY_WebhookMessage) QueueTable
                  WHERE EventName = @EventName
                  ORDER BY SY_WebhookSubscription.ItemNo";

Re: Webhooks Bug??  Topic is solved

PostPosted: Mon May 17, 2021 11:34 am
by Scott.Pearce

Re: Webhooks Bug??

PostPosted: Mon May 17, 2021 12:23 pm
by SBarnes
Thanks Scott,

It can be an even bigger issue because if you then re-enable the subscriber the api can run out of memory when there are too many items in SY_WebhookMessage that haven't be closed off with a response and the api loads them for processing, Mike is aware of this.