[MGNLHOOK-353] Add more tracing / investigate Webhooks 1.0.1 not sending events Created: 21/Sep/23  Updated: 29/Sep/23  Resolved: 29/Sep/23

Status: Closed
Project: Magnolia Webhooks
Component/s: None
Affects Version/s: 1.0.1
Fix Version/s: 1.0.2

Type: Bug Priority: Neutral
Reporter: Javier Benito Assignee: Javier Benito
Resolution: Fixed Votes: 0
Labels: None
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: 1h Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Sub-Tasks:
Key
Summary
Type
Status
Assignee
MGNLHOOK-358 Implement fix Technical task Completed Javier Benito  
MGNLHOOK-359 Review Technical task Completed Rishab Dhar  
MGNLHOOK-360 Pre-Integration QA Technical task Completed Dai Ha  
MGNLHOOK-361 QA Technical task Completed Oanh Thai Hoang  
Team: DeveloperX
Epic Link: Webhooks Maintenance (Phase 2)
Sprint: DevX 47
Story Points: 3
Approved:
Yes

 Description   

Description

There is a problem using webhooks on a PaaS customer (The Hartford).

It turns out that there's a use case which provokes webhooks to fail, removing all subscribers and making them unusable until Magnolia is restarted.

Use case

  • Create a webhook definition, using Resource Files app, inside any module.
  • Add a webhook definition, for example:
name: webhook1
url: https://webhook.site/506b6a1e-b782-4d32-9745-088854f70b0c
method: get
enabled: true

events:
  - name: p1
    eventType: Published 
  • Triggering the webhook publishing a page, should work, event should be received.
  • Add a new event for a different event type, for example Unpublished:
name: webhook1
url: https://webhook.site/506b6a1e-b782-4d32-9745-088854f70b0c
method: get
enabled: true

events:
  - name: p1
    eventType: Published 
  - name: p2
    eventType: Unpublished
  • There is this exception in the log file:
2023-09-21 11:32:37,201 ERROR info.magnolia.event.SimpleEventBus                : Exception caught when dispatching info.magnolia.webhooks.core.WebhookDefinitionChangedEvent with info.magnolia.webhooks.registry.WebhookDefinitionEventHandler eventHandler.
java.lang.NullPointerException: null
	at info.magnolia.webhooks.events.core.SimpleEventSubscribers.unregister(SimpleEventSubscribers.java:51) ~[magnolia-webhooks-events-1.0.1.jar:?]
	at info.magnolia.webhooks.registry.WebhookDefinitionEventHandler.removeSubscriberFor(WebhookDefinitionEventHandler.java:86) ~[magnolia-webhooks-core-1.0.1.jar:?]
	at info.magnolia.webhooks.registry.WebhookDefinitionEventHandler.lambda$onChange$2(WebhookDefinitionEventHandler.java:68) ~[magnolia-webhooks-core-1.0.1.jar:?]
	at java.util.ArrayList.forEach(ArrayList.java:1257) ~[?:1.8.0_231]
	at info.magnolia.webhooks.registry.WebhookDefinitionEventHandler.onChange(WebhookDefinitionEventHandler.java:68) ~[magnolia-webhooks-core-1.0.1.jar:?]
	at info.magnolia.webhooks.core.WebhookDefinitionChangedEvent.dispatch(WebhookDefinitionChangedEvent.java:57) ~[magnolia-webhooks-core-1.0.1.jar:?]
	at info.magnolia.webhooks.core.WebhookDefinitionChangedEvent.dispatch(WebhookDefinitionChangedEvent.java:28) ~[magnolia-webhooks-core-1.0.1.jar:?]
	at info.magnolia.event.SimpleEventBus.fireEvent(SimpleEventBus.java:75) ~[magnolia-core-6.2.35.jar:?]
	at info.magnolia.webhooks.registry.WebhookDefinitionRegistry.register(WebhookDefinitionRegistry.java:92) ~[magnolia-webhooks-core-1.0.1.jar:?]
	at info.magnolia.config.source.yaml.YamlConfigurationSource.loadAndRegister(YamlConfigurationSource.java:143) ~[magnolia-configuration-6.2.35.jar:?]
	at info.magnolia.config.source.yaml.AbstractFileResourceConfigurationSource.lambda$start$2(AbstractFileResourceConfigurationSource.java:162) ~[magnolia-configuration-6.2.35.jar:?]
	at info.magnolia.resourceloader.layered.LayeredResourceOrigin$RelayingChangeHandler.onResourceChanged(LayeredResourceOrigin.java:284) [magnolia-resource-loader-6.2.35.jar:?]
	at info.magnolia.resourceloader.AbstractResourceOrigin.dispatchResourceChange(AbstractResourceOrigin.java:132) [magnolia-resource-loader-6.2.35.jar:?]
	at info.magnolia.resourceloader.jcr.JcrResourceOrigin$ResourcesObservationListener.onEvent(JcrResourceOrigin.java:360) [magnolia-resource-loader-6.2.35.jar:?]
	at info.magnolia.cms.util.FilteredEventListener.onEvent(FilteredEventListener.java:86) [magnolia-core-6.2.35.jar:?]
	at info.magnolia.observation.DeferringEventListener$ObservationBasedDelayedExecutor$1.run(DeferringEventListener.java:102) [magnolia-core-6.2.35.jar:?]
	at info.magnolia.cms.util.DelayedExecutor$RunnableWrapper.run(DelayedExecutor.java:103) [magnolia-core-6.2.35.jar:?]
	at EDU.oswego.cs.dl.util.concurrent.ClockDaemon$RunLoop.run(Unknown Source) [concurrent-1.3.4.jar:?]
	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_231]
2023-09-21 11:32:37,227 INFO  agnolia.config.source.yaml.YamlConfigurationSource: Registered definition from YAML file [/admincentral/webhooks/Webhooks_test.yaml]: [webhook] definition [webhook1] with reference id: [admincentral:Webhooks_test] from module [admincentral] at [Webhooks_test]
2023-09-21 11:33:22,808 INFO  info.magnolia.module.scheduler.CommandJob         : Starting job [asyncCommand1695288802806]... 
2023-09-21 11:33:23,975 INFO  info.magnolia.module.scheduler.CommandJob         : Job executed successfully [asyncCommand1695288802806]
2023-09-21 11:33:23,975 INFO  fo.magnolia.webhooks.events.core.EventsQueueWorker: Passing event to subscribers [{ "id": "4d8d8007-ebbc-480e-a9a3-110cf3b7f165", "contentUnpublished": "/travel"}]
2023-09-21 11:33:23,976 INFO  fo.magnolia.webhooks.events.core.EventsQueueWorker: Subscribers number [0]
21-Sep-2023 11:34:04.396 INFO [main] org.apache.catalina.core.StandardServer.await A valid shutdown command was received via the shutdown port. Stopping the Server instance.
21-Sep-2023 11:34:04.396 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
21-Sep-2023 11:34:04.400 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
21-Sep-2023 11:34:06.653 INFO [main] org.atmosphere.util.ForkJoinPool.<init> Using ForkJoinPool  java.util.concurrent.ForkJoinPool. Set the org.atmosphere.cpr.broadcaster.maxAsyncWriteThreads to -1 to fully use its power.
21-Sep-2023 11:34:06.654 WARNING [main] org.atmosphere.cpr.DefaultBroadcaster.addAtmosphereResource AtmosphereResource 4654ad83-5e31-48d9-b77a-2fcd7e4162eb is not suspended. If cached messages exists, this may cause unexpected situation. Suspend first 
  • This provokes that there aren't subscribers at all, so webhooks are triggered, but no event is sent.

Workaround

Restarting Magnolia instance, make them work. And after further research, if you make changes to those webhooks files, this don't happen any more and webhooks still work.

Developer notes

Ensure that null lists are not returned when getting subscribers by type, to be added/removed.

 


Generated at Mon Feb 12 10:03:24 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.