hapifhir / hapi-fhir

🔥 HAPI FHIR - Java API for HL7 FHIR Clients and Servers
http://hapifhir.io
Apache License 2.0
2.04k stars 1.33k forks source link

Most Subscription Pointcuts aren't triggered #4940

Closed LJNIC closed 1 month ago

LJNIC commented 1 year ago

Describe the bug Most Subscription POINTCUTs don't seem to function.

To Reproduce Steps to reproduce the behavior:

  1. Clone the hapi-fhir-jpaserver-starter (which has the SubscriptionDebugLogInterceptor enabled)
  2. Enable REST Subscriptions
  3. POST a REST Subscription with a dead URL
  4. POST a matching resource for the Subscription
  5. Note how only a single log is output from the SubscriptionDebugLogInterceptor (that it was submitted to the pipeline) and that none of SUBSCRIPTION_AFTER_DELIVERY, SUBSCRIPTION_BEFORE_DELIVERY, etc. are triggered

Expected behavior For all SUBSCRIPTION* Pointcuts to be triggered.

Logs

2023-05-25 14:48:57.742 [qtp1141354562-31] INFO  c.u.f.j.s.u.S.SUBS1 [SubscriptionDebugLogInterceptor.java:167] Resource Patient/3 was submitted to the processing pipeline (op=CREATE)
2023-05-25 14:48:58.327 [qtp1141354562-31] INFO  fhirtest.access [LoggingInterceptor.java:175] Path[/fhir] Source[] Operation[create  Patient] UA[PostmanRuntime/7.32.2] Params[] ResponseEncoding[JSON] Operation[create  Patient] UA[PostmanRuntime/7.32.2] Params[] ResponseEncoding[JSON]
2023-05-25 14:48:58.343 [subscription-delivery-rest-hook-2-1] INFO  c.u.f.j.s.m.d.r.SubscriptionDeliveringRestHookSubscriber [SubscriptionDeliveringRestHookSubscriber.java:110] Delivering CREATE rest-hook payload Patient/3/_history/1 for Subscription/2
2023-05-25 14:48:58.416 [empi-1] INFO  ca.uhn.fhir.log.mdm_troubleshooting [MdmCandidateSearchSvc.java:106] Candidate search found 0 matching resources for Patient/3
2023-05-25 14:48:58.549 [subscription-delivery-rest-hook-2-2] INFO  c.u.f.j.s.m.d.r.SubscriptionDeliveringRestHookSubscriber [SubscriptionDeliveringRestHookSubscriber.java:110] Delivering CREATE rest-hook payload Patient/4/_history/1 for Subscription/2
2023-05-25 14:48:58.565 [subscription-delivery-rest-hook-2-1] ERROR c.u.f.j.s.m.d.BaseSubscriptionDeliverySubscriber [BaseSubscriptionDeliverySubscriber.java:106] Failure handling subscription payload for subscription: Subscription/2
ca.uhn.fhir.rest.server.exceptions.InvalidRequestException: HTTP 400 Bad Request: HAPI-0960: Can not create resource with ID[3], no resource with this ID exists and clients may only assign IDs which contain at least one non-numeric character

The first trigger, shown in the first line, is hit, but there should be another one before the message is sent: https://github.com/hapifhir/hapi-fhir/blob/e3a7390d6a88d09a1793f8ff937b8d596178cc71/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/util/SubscriptionDebugLogInterceptor.java#LL121C2-L121C2 https://github.com/hapifhir/hapi-fhir/blob/e3a7390d6a88d09a1793f8ff937b8d596178cc71/hapi-fhir-jpaserver-subscription/src/main/java/ca/uhn/fhir/jpa/subscription/match/deliver/BaseSubscriptionDeliverySubscriber.java#L94

Environment (please complete the following information):

LJNIC commented 9 months ago

Found this was just because the interceptor service used in the JPA Starter isn't the main interceptor service.

Jake-Gillberg commented 9 months ago

@LJNIC Did you find a way to register interceptors with the main interceptor service? I just ran into this with the MDM hooks being set up in JPA starter not being called

LJNIC commented 9 months ago

@LJNIC Did you find a way to register interceptors with the main interceptor service? I just ran into this with the MDM hooks being set up in JPA starter not being called

You can grab the service from Spring.