-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Broker Api Redesign
HAPI-FHIR requires a message broker to provide asynchronous messaging services for
- subscription processing
- mdm processing
- batch processing
Prior to HAPI version 8.2.0, HAPI-FHIR's broker api was built on top of Spring Messaging, a Spring API for JMS, the original Java API for asynchronous message processing. HAPI ships with the simple in-memory implementation of this API.
Since that time, a number of new message broker paradigms have emerged, and JMS no longer makes sense as the foundational API for HAPI-FHIR's messaging services.
In release 8.2.0, HAPI-FHIR decouples the message broker services from Spring Messaging. SpringMessaging adapters are provided for backwards compatibility.
The new API largely mirrors the Spring Messaging API, with a few important differences. Here is a mapping from the old API to the new API.
Old New |
Notes |
---|---|
ca.uhn.fhir.jpa.subscription.channel.api.IChannelFactory ca.uhn.fhir.broker.api.IBrokerClient |
Creates producers and consumers |
org.springframework.messaging.Message ca.uhn.fhir.rest.server.messaging.IMessage<T> |
ResourceModifiedJsonMessage used to implement Message now it implements IMessage<ResourceModifiedMessage> |
ca.uhn.fhir.jpa.subscription.channel.api.IChannelProducer ca.uhn.fhir.broker.api.IChannelProducer<T> |
send() return value changed from boolean to ISendResult |
org.springframework.messaging.MessageHandler ca.uhn.fhir.broker.api.IMessageListener<T> |
|
ca.uhn.fhir.jpa.subscription.channel.api.IChannelReceiver ca.uhn.fhir.broker.api.IChannelConsumer<T> |
Every IChannelConsumer<T>now has exactly one IMessageListener<T> associated to it |
One significant change with the new API is that consumers and listeners now store the type of messages they expect to receive. Consumers are expected to validate the received message type before calling their attached listener. Generic typing on the new classes and methods helps with this enforcement.
If a channel requires more than one listener, HAPI provides a MultiplexingListener class that can be used to split one message handling call into many.