
Package ca.uhn.fhir.broker.api
Interface IBrokerClient
- All Known Implementing Classes:
LinkedBlockingBrokerClient
public interface IBrokerClient
IBrokerClient implementations communicate with Message Brokers to exchange messages. HAPI-FHIR uses a Message Broker for asynchronous
processing tasks such as Batch Jobs, Subscription Processing, and MDM. HAPI-FHIR uses the term "Channel" to represent a Queue (JMS)
or Topic (Kafka etc.) Services that send messages create a
IChannelProducer
. Services that
receive messages from a channel create a IChannelConsumer
. Each IChannelConsumer
is created with a single
IMessageListener
that defines how messages are handled. A IChannelConsumer
creates threads that are notified by the broker
when new messages arrive so IChannelConsumer
instances need to be properly closed when shutting down.-
Method Summary
Modifier and TypeMethodDescription<T> IChannelConsumer
<T> getOrCreateConsumer
(String theChannelName, Class<? extends ca.uhn.fhir.rest.server.messaging.IMessage<T>> theMessageType, IMessageListener<T> theMessageListener, ChannelConsumerSettings theChannelConsumerSettings) Create a consumer that receives messages from the channel.<T> IChannelProducer
<T> getOrCreateProducer
(String theChannelName, Class<? extends ca.uhn.fhir.rest.server.messaging.IMessage<T>> theMessageType, ChannelProducerSettings theChannelProducerSettings) Create a producer that is used to send messages to the channel.
-
Method Details
-
getOrCreateConsumer
<T> IChannelConsumer<T> getOrCreateConsumer(String theChannelName, Class<? extends ca.uhn.fhir.rest.server.messaging.IMessage<T>> theMessageType, IMessageListener<T> theMessageListener, ChannelConsumerSettings theChannelConsumerSettings) Create a consumer that receives messages from the channel.Implementations can choose to return the same object for multiple invocations of this method when invoked with the same theChannelName if they need to, or they can create a new instance.
- Parameters:
theChannelName
- The actual underlying channel nametheMessageType
- The object type that will be placed on this chanel. Objects will usually be a Jackson-annotated class.theMessageListener
- The message handler that will be called for each arriving message. If more than one message listeners is required for a single consumer,MultiplexingListener
can be used for the listener.theChannelConsumerSettings
- Defines the consumer configuration (e.g. number of listening threads)
-
getOrCreateProducer
<T> IChannelProducer<T> getOrCreateProducer(String theChannelName, Class<? extends ca.uhn.fhir.rest.server.messaging.IMessage<T>> theMessageType, ChannelProducerSettings theChannelProducerSettings) Create a producer that is used to send messages to the channel.Implementations can choose to return the same object for multiple invocations of this method when invoked with the same theChannelName if they need to, or they can create a new instance.
- Parameters:
theChannelName
- The actual underlying channel nametheMessageType
- The object type that will be placed on this channel. Objects will be Jackson-annotated structures.theChannelProducerSettings
- Contains the configuration for senders.
-
getChannelNamer
- Returns:
- the IChannelNamer used by this broker client.
-