9 Subscription Interceptor Proposal
Ken Stevens edited this page 2019-01-13 22:42:33 -05:00

HAPI FHIR JPA Server 3.7 currently provides a mechanism for registering interceptors with the FHIR Server endpoint.

Informed by unit test needs and end-user needs, this document proposes a similar interceptor mechanism for subscriptions. As with other interceptors, boolean = true means continue processing, boolean = false mean stop processing.

Here are the three HAPI-FHIR subscription methods that would call registered interceptors:

SubscriptionRegistry.registerSubscription(IIdType theId, IBaseResource theSubscription)

The active subscription about be added to the in-memory SubscriptionRegistry:

boolean incomingSubscriptionPreProcessed(IIdType theId, IBaseResource theSubscription)

The CanonicalSubscription after it has been added to the SubscriptionRegistry:

void registeredSubscriptionPostProcessed(CanonicalSubscription theSubscription)

SubscriptionMatchingSubscriber.matchActiveSubscriptionsAndDeliver(ResourceModifiedMessage theMsg)

The incoming resource along with the operation (CREATE, UPDATE, DELETE, or MANUALLY_TRIGGERED):

boolean incomingResourcePreProcessed(ResourceModifiedMessage theMsg)

After the resource has matched a subscription but before it has been delivered to the endpoint:

boolean subscriptionMatchBeforeDelivery(ResourceModifiedMessage theMsg, CanonicalSubscription theSubscription)

After the resource has been matched against all subscriptions:

void incomingResourcePostProcessed(ResourceModifiedMessage theMsg)

SubscriptionDeliveringRestHookSubscriber.doDelivery(ResourceDeliveryMessage theMsg, CanonicalSubscription theSubscription, EncodingEnum thePayloadType, IGenericClient theClient, IBaseResource thePayloadResource)

The incoming resource and other relevant details before any processing:

boolean incomingRequestPreProcessed(ResourceDeliveryMessage theMsg, CanonicalSubscription theSubscription, EncodingEnum thePayloadType, IGenericClient theClient, IBaseResource thePayloadResource)

Parameters that will be added to the HTTP Client and HTTP Request (return null for none):

Map<String, List<String>> preDeliverAddHttpClientParams(ResourceDeliveryMessage theMsg, CanonicalSubscription theSubscription, EncodingEnum thePayloadType, IGenericClient theClient, IBaseResource thePayloadResource)

Headers that will be added to the HTTP Client (return null for none):

List<ca.uhn.fhir.rest.client.api> preDeliverAddHttpHeaders(ResourceDeliveryMessage theMsg, CanonicalSubscription theSubscription, EncodingEnum thePayloadType, IGenericClient theClient, IBaseResource thePayloadResource)

The request that was sent and the response that was received back:

void postDeliver(IHttpRequest request, IHttpResponse response)