What HAPI FHIR subscriptions do and when teams need them
A clinical or operational system often needs to know when a FHIR resource changes, such as a new Encounter, an updated Observation or a Task that moves to a new status. Polling the server on a timer works for small volumes, but it adds load, delays notices and makes it hard to tell which change triggered which action. HAPI FHIR subscriptions let the JPA server push a notification when a resource matching a subscription criteria is created or updated. The starter documentation describes three channels: REST hook for outgoing HTTP calls to a receiving endpoint, email for notices sent over SMTP, and websocket for incoming connections that stay open to receive notifications.
Each channel fits a different kind of downstream system. REST hooks suit integration engines, workflow tools or backend services that can expose an HTTP endpoint and handle retries. Email suits staff notification where a person, not a program, is the consumer, and it depends on SMTP settings your mail team must provide and secure. Websocket suits a client application that can hold a long-lived connection and needs changes almost immediately. Before enabling any channel, decide which systems will receive notices, what clinical or operational action each notice triggers, and what happens when a receiver is down. Those answers determine whether a subscription is the right tool at all, or whether a messaging platform such as Apache Kafka would serve better for high-volume fan-out. Confirm the exact subscription model and resource criteria your HAPI FHIR version supports in the official documentation before you design receivers.
Which HAPI FHIR subscriptions channel fits each integration
This table compares the three subscription channels by direction of traffic, the starter property that enables each one, what the receiving system must run, and the main trade-off. Read each row as a question: which channel matches the way the other system receives changes. The main takeaway is that the channel choice sets what your receiving system must host, not only how the notification arrives.
| Channel | Direction and enabling property | What the receiving system must run | Main trade-off |
|---|---|---|---|
| REST hook | Server pushes outgoing HTTP calls to a receiver. Enabled with hapi.fhir.subscription.resthook_enabled | An HTTP endpoint that accepts POST requests and can authenticate the server | Simple to integrate, but the receiver must be reachable from the server and handle retries and duplicates |
| Server sends notification messages outward over SMTP. Requires hapi.fhir.subscription.email.* with SMTP details | A mailbox or mail-processing service that can read the message content | Works where HTTP is blocked, but SMTP settings must be complete and payloads are less structured for machines | |
| Websocket | Receiver opens an incoming connection to the server. Enabled with hapi.fhir.subscription.websocket_enabled | A long-lived client that connects to the server and keeps the connection open | Near-real-time delivery for connected clients, but the client must stay connected and the setup depends on the server's topic cache and broker |
| Multi-instance impact | Topic cache and internal message broker default to in-memory implementations not shared across instances | Confirm with your platform team whether a shared cache and broker are needed before scaling out | Each channel can miss or duplicate events across instances unless shared components are planned |
How a data change reaches each subscriber
A create or update on the JPA server is matched against active subscriptions, and the notification then travels through the internal message broker to one of three channels. The REST hook channel posts outward to a receiver endpoint, the email channel sends through SMTP, and the websocket channel pushes to clients that connected inbound. The subscription topic cache and the message broker are in-memory by default and live inside each server instance, so a deployment with several instances needs shared implementations for these components before notifications can be relied on.
Notification path from a resource change to each channel and receiver.
Single instance or multi-instance: which subscription setup applies
A single HAPI FHIR JPA server instance is the simplest case for subscriptions. The default in-memory subscription topic cache and internal message broker live in the same process that receives writes, so a change made through the API is seen by the same memory that evaluates subscriptions and sends notifications. This fits a test environment, a proof of concept, or a small production service where one instance handles all traffic and a restart is an accepted interruption. The trade-off is that no second instance exists to take over, so a crash or restart pauses delivery until the server comes back.
- Delivery state: Notifications are produced by the one process, so there is no cross-instance coordination to fail.
- Restart behavior: Confirm what happens to in-flight notifications and subscriptions when the process restarts, and whether your consumers can tolerate a gap.
- Channel choice: Enable only the channels you need, starting with
hapi.fhir.subscription.resthook_enabledfor outgoing REST hooks. - SMTP details: If you use email, the
hapi.fhir.subscription.email.*settings must point to a mail relay you operate or have approved. - Capacity ceiling: Decide in advance when a single instance stops meeting your load or availability needs, since that is the point to revisit this design.
Before enabling channels, confirm the expected notification volume, the consumers that receive each notification, and how the team will know a notification was missed.
When several HAPI FHIR JPA server instances run behind a load balancer or on Kubernetes, each instance has its own in-memory subscription topic cache and internal message broker. A write accepted by one instance is not automatically known to the others through those defaults, so a subscription may be evaluated inconsistently, or notifications may be missed or duplicated depending on where requests land. The starter README warns that these defaults are not shared across server instances, so this shape needs an explicit design decision before channels are turned on.
- Topic cache: Confirm how each instance learns about subscription topics and whether the cache is consistent across replicas.
- Message broker: Decide which shared broker or channel implementation will carry notifications between instances, and who operates it.
- Replica behavior: Test a write sent to one replica and check that every subscribed consumer receives exactly one notification.
- Rolling updates: Plan how notifications behave during a Kubernetes rollout, when old and new replicas run side by side.
- Ownership: Name the team that owns the broker, its monitoring and its failure handling.
Before enabling channels, ask the vendor or your platform team to confirm which shared components the starter supports in your version, and run a multi-replica test before production traffic depends on it.
On Kubernetes, the HAPI FHIR JPA starter can be deployed with its Helm chart, and replica counts are usually changed for scaling or availability. Each pod carries its own default in-memory cache and broker, so the same multi-instance concerns apply, along with pod restarts, autoscaling and node drains that move work around. Subscription behavior during these events should be tested rather than assumed.
- Replica count: Set the number of replicas only after the shared topic and broker design is confirmed.
- Autoscaling and drains: Check how pod termination and scale-down affect notifications already in progress.
- Ingress and webhooks: Confirm that outbound REST hook targets and any inbound websocket connections are reachable from every pod.
- Configuration: Keep subscription settings in the same chart values or configuration source across replicas so each pod enables the same channels.
- Monitoring: Alert on failed notifications and on channel errors per pod, not only on the service as a whole.
Before enabling channels, confirm the chart version you run, the replica count you plan, and the test that proves a single write produces one correct notification across all pods.
Why the in-memory topic cache and broker limit multi-instance deployments
The subscription topic cache and the internal message broker channel in the HAPI FHIR JPA server starter default to in-memory implementations that are not shared across server instances. The starter README warns about this directly. In practice, each running copy of the server keeps its own view of subscription topics and its own internal channel, so a deployment with more than one instance behind a load balancer does not behave as one subscription engine. Plan for this before you add a second replica, not after a notification goes missing.
The practical effect depends on which instance receives the write. The instance that stores a changed resource is the one whose in-memory state records the change and tries to match it to active subscriptions. Another instance has no access to that state, so it may never evaluate the change, and the instance that should deliver the notification may not know it exists. An outgoing REST hook, email or websocket notification can therefore be sent by one replica, skipped by another, or sent late, depending on routing and restarts. Ask your team to confirm exactly which component owns matching and delivery in the starter version you run, because the answer determines where failures show up.
Before production use, confirm in the starter documentation whether a shared topic cache and a shared broker implementation are supported in your version and how to configure them. Then test the setup yourself: create a subscription, write resources through each replica in turn, restart one instance mid-test, and check that every expected notification arrives exactly where intended. Record the results and keep the test in your release process, since subscription behavior is one of the easiest things to break during a scaling change.
How to enable HAPI FHIR subscriptions in the starter
This sequence takes a team from a confirmed starter version to a server where REST hook, email and websocket subscriptions each send notifications and retry failed deliveries. It also settles the cache and broker choice before any multi-instance rollout.
Confirm the starter version and Java runtime
The platform engineering lead checks which hapi-fhir-jpaserver-starter release and HAPI FHIR version the server will run, then confirms the JDK that release requires. HAPI FHIR 8.2.0 requires JDK 17, and newer releases may raise that requirement, so read the release notes for the exact version you pick. Record the chosen versions in the deployment runbook. The step is done when the JDK on the build and runtime hosts matches the documented requirement and the version is pinned in configuration, not left as a floating tag.
Choose the deployment method
Decide how the starter will run: the hapiproject/hapi Docker image, Docker Compose, Spring Boot, a WAR on Tomcat, Jetty or Wildfly, or a Kubernetes deployment with the Helm chart. The choice sets where subscription properties are supplied, such as environment variables, a Spring Boot configuration file or the Helm values, so keep the subscription settings in the same place as the rest of the server configuration. Confirm the deployment method against your platform standards. The step is done when a test instance starts from that method with the starter's default configuration and answers a metadata request.
Set the enable properties for each channel
Turn on only the channels you need. Set hapi.fhir.subscription.resthook_enabled to true for outgoing REST hook notifications, and set hapi.fhir.subscription.websocket_enabled to true for incoming websocket connections. Leave channels you do not use disabled, because each enabled channel adds a surface to secure and monitor. Store these values in version control with the rest of the configuration. The step is done when the server log on startup shows the enabled channels and no subscription-related errors appear during initialization.
Add SMTP settings for email subscriptions
If email notifications are required, configure the hapi.fhir.subscription.email.* properties with your SMTP host, port, sender address and authentication details. Take SMTP credentials from your secrets store rather than writing them into plain configuration files, and confirm with your mail team that the relay accepts messages from the server's network location. Send only the minimum data needed in notifications, because email leaves your controlled systems. The step is done when a test message reaches a mailbox you control from a subscription that fires on a test resource change.
Decide the cache and broker for multiple instances
The starter's subscription topic cache and internal message broker channel default to in-memory implementations that are not shared across server instances. On a single instance this is workable, but with several replicas a subscription created on one instance may not be seen by another, and notifications can be missed or duplicated. Before scaling out, ask the vendor documentation and the starter README which shared cache and broker options your release supports, and agree on one with your architecture team. The step is done when the decision is written down, with a single-instance deployment accepted as the explicit limit or a shared implementation selected and validated in a staging environment.
Test the REST hook channel
Create a sample subscription with a REST hook channel that points to a receiving endpoint you control, such as a test listener in a non-production environment. Change a resource that matches the subscription criteria and confirm the listener receives the notification with the expected payload. Then make the listener return an error status and check that the server retries delivery according to its configured behavior. Verify the retry against the server logs. The step is done when a successful delivery and a failed delivery followed by a retry are both observed and recorded in the test log.
Test the email and websocket channels
Repeat the sample subscription test for the email channel, confirming delivery to a test mailbox and checking the message content for data you did not intend to send. For websocket, connect a test client to the websocket endpoint, bind it to a subscription, change a matching resource and confirm the client receives the event. Disconnect the client mid-test and reconnect to observe how the server handles the dropped connection. The step is done when each channel has a recorded successful notification and a recorded failure or reconnection result, with any gaps logged as defects before go-live.
Verify retries and multi-instance behavior before go-live
Run a final check against the deployment that will go live. Confirm that retry behavior after an endpoint outage matches what your receiving systems expect, and that notifications are not lost when a single instance restarts. If more than one replica is planned, run the same subscription tests while sending traffic to each replica and compare results against the cache and broker decision from the previous step. The step is done when the test results, configuration values and the signed-off cache and broker decision are stored together in the runbook for the operations team.
Security controls around outbound and inbound subscriptions
HAPI FHIR provides building blocks for subscriptions, not a finished security layer, so the team has to design who can create subscriptions, where notifications may go, what they carry and how they are recorded. The six controls below connect the REST hook, email and websocket channels and should be decided together before any channel is switched on in a shared environment.
Authorize subscription creation
Subscription resources decide what data leaves the server and where it is sent, so creating or changing them is a privileged action. Limit create and update rights on Subscription resources to a small set of administrative clients, and confirm through testing that ordinary clients cannot register a REST hook endpoint of their choosing. Treat the endpoint URL as untrusted input and review it as part of every subscription request.
HAPI FHIR security docsNarrow access with AuthorizationInterceptor
A subscription that matches a broad set of resources can deliver data a receiving system was never meant to see. Use the AuthorizationInterceptor and search narrowing so that the criteria a subscription evaluates respect the same rules that govern reads. Test the combination with a client that has limited rights, because a subscription created by an administrator may otherwise notify on records that the eventual receiver should not get.
Minimize notification payloads
Notifications can carry the full resource or only its identifiers, and the choice changes what the receiving system stores and what a leaked message exposes. Decide per channel whether a notification should include the resource, a reference or only an event signal, and document the choice with the receiving team. Confirm that the payload format you pick matches what the receiver is designed to handle.
Handle SMTP credentials carefully
The email channel needs SMTP details configured through the hapi.fhir.subscription.email.* settings, which means a mail account password is stored in the deployment. Keep the values in your secrets store and inject them at runtime rather than committing them to a configuration file. Use a dedicated sending account with rights limited to sending, and rotate its credentials on a schedule your security team sets.
Protect websocket connections
Enabling hapi.fhir.subscription.websocket_enabled opens an inbound connection that clients use to receive notifications. Confirm that the connection requires the same authentication as the REST API, and that the reverse proxy in front of the server passes upgrade requests only for the paths you intend. Check that a client cannot subscribe to resources it could not read over ordinary search.
Audit notification delivery
When a subscriber claims it never received an update, or an update reached the wrong system, you need a record of what was sent and when. Plan audit logging for subscription creation, changes and delivery attempts, and decide how long those records are kept. Use the BALP audit logging building block where it fits your needs, and confirm with your compliance team which events must be retained.
Questions teams ask before enabling HAPI FHIR subscriptions
What drives the cost of enabling HAPI FHIR subscriptions?
The cost depends mostly on how many channels you enable, how many systems receive notifications, and how much of the surrounding platform you must build. The starter turns on REST hook, email and websocket channels through configuration, but each receiving system, SMTP relay, certificate and monitoring check still needs an owner. Internal labor is the largest component for most teams, followed by any partner fees for the written scope. Ask for a quote that separates one-time work (topic design, configuration, testing, runbooks) from recurring work (patching the server, reviewing failed deliveries, rotating credentials). Costs rise when subscription criteria are complex, when delivery must be guaranteed across several instances, or when receiving endpoints are owned by other teams with slow change processes.
How long does a first subscriptions setup usually take?
Duration depends on scope rather than on the switch itself. Enabling one channel against a single server with a test receiver is a small configuration change, while a production rollout includes topic design, receiver onboarding, security review, load testing and operational handoff. No fixed timeline applies across organizations, so ask for a schedule built from the written scope, with named milestones and the dependencies on other teams. The longest items are usually approvals and receiver readiness, not the configuration itself. Plan extra time if the receiving systems have never accepted inbound FHIR notifications.
What must our team provide before the work starts?
Most of the prerequisites sit with your organization. Expect to provide:
- A running HAPI FHIR JPA server with a supported Java runtime and a PostgreSQL or Microsoft SQL Server database, plus an owner for each
- An SMTP service and sender account if email notifications are needed
- Reachable receiving endpoints for REST hook deliveries, with agreed authentication and an owner who can change them
- Network rules that allow outbound calls from the server and inbound websocket connections where used
- Decisions on which resources and criteria trigger notifications, and who approves them
Confirm the Java version for your release in the HAPI FHIR versions documentation before you commit to a runtime.
Can an internal team set up subscriptions alone?
Yes, a team with Java, Spring Boot or servlet container experience and database administration skills can enable the starter's channels without outside help, using the project's README as the starting point. The harder questions are operational: how notifications are secured, how failed deliveries are retried, and how the platform behaves across restarts and multiple instances. Teams without someone who owns those decisions often find the configuration quick and the production design slow. DeployOpen can plan, implement, test and document this work in your infrastructure under a fixed scope, or support your team on a retainer.
Which subscription channel should we enable first?
Start with the channel that matches a receiver you already control. REST hook sends outbound HTTP calls to a receiving system and usually needs the fewest moving parts. Email depends on SMTP settings under hapi.fhir.subscription.email.*, so it adds mail relay ownership and deliverability checks. Websocket is configured with hapi.fhir.subscription.websocket_enabled for incoming connections, so the client must be able to reach the server and hold a session. Enable each channel in a test environment, confirm delivery and failure behavior, then add the next one.
What changes when we add a second HAPI FHIR server instance?
The default subscription topic cache and internal message broker channel are in-memory and are not shared across server instances, according to the starter README. With a single instance, that is a known and manageable design. With two or more instances, a change made on one node may not reach subscription processing on another, so notifications can be missed or handled inconsistently. Before scaling out, plan a shared implementation for the topic cache and message broker, test it under load, and confirm the behavior with the HAPI FHIR maintainers or your vendor documentation. Treat this as an architecture decision, not a load balancer setting.
How do we secure notifications sent to other systems?
Security is designed around your receivers and your network, because HAPI FHIR provides building blocks rather than a single security layer. Decide how the server authenticates to each REST hook endpoint, how credentials are stored and rotated, which networks can receive traffic, and what happens to payloads that contain personal health information. Email content should be reviewed for minimum necessary data, and websocket access should be limited to known clients. Your compliance and security teams should review these choices before production, and an independent auditor or certification body, not DeployOpen, decides whether controls meet any specific obligation.
Limits to confirm before you commit to subscriptions
The starter enables REST hook, email and websocket subscriptions with a few configuration keys, but the defaults assume a single server instance. The cards below cover what to confirm in your own version and environment before a design depends on subscription delivery.
Shared topic cache and broker
The starter README warns that the subscription topic cache and internal message broker default to in-memory implementations that are not shared across server instances. Confirm whether your chosen version lets you replace both with shared implementations, and who builds and operates that replacement. Until you confirm it, plan for one active instance handling subscription traffic.
Starter READMEDelivery guarantees under failure
Confirm what the server guarantees when a delivery fails, including whether notifications are retried, how many attempts are made, how long retries continue, and whether a notification can be lost if the server restarts before delivery. Ask for the documented behavior for your version rather than assuming at-least-once or at-most-once semantics. Your receivers must tolerate duplicates or gaps according to what you confirm.
Receiver availability and endpoints
REST hook subscriptions push to endpoints you do not control on the receiving side. Confirm how the server behaves when a receiver is slow, returns errors or is unreachable, and whether a failing subscription is paused, dropped or left active. Also confirm which network paths, TLS settings and authentication headers the server can use to reach each receiver from your deployment network.
Email deliverability and SMTP
The email channel depends on the SMTP settings under hapi.fhir.subscription.email.*. Confirm the relay your organization permits, sender authentication, bounce handling and whether messages carry clinical content that your mail policy allows. Confirm who owns the mail relay and its logs, because the server reports only what it hands to SMTP, not what a recipient receives.
Websocket connection handling
The hapi.fhir.subscription.websocket_enabled key accepts incoming websocket connections, so you must confirm how clients authenticate, how many concurrent connections your instance and load balancer can hold, and how sticky sessions behave behind a proxy. Confirm how a reconnecting client recovers notifications it missed, since the answer depends on the version and on the shared components above.
Subscription volume and load
Each subscription adds evaluation and delivery work on every matching write, so the number of subscriptions and the rate of resource changes both drive load. Test with your expected subscription count and write volume against your database and instance sizing. Confirm the version-specific guidance in the starter documentation before you size the deployment, and record the results so the sizing decision can be reviewed later.
How DeployOpen scopes and delivers HAPI FHIR subscriptions
DeployOpen plans, implements, hardens and documents HAPI FHIR subscriptions inside infrastructure you control, including the REST hook, email and websocket channels. The work starts with a written scope that names which channels you need, which systems receive notifications, and how the topic cache and message broker will run across your server instances.
How we scope
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts.
- The scope lists which subscription channels are enabled and which receiving systems and endpoints they notify.
- We record the number of server instances planned and whether the in-memory topic cache and broker must be replaced.
How we build
- We configure the starter's REST hook, email and websocket settings in your environment, including SMTP details for email.
- We design the cache and message broker layer so notifications behave consistently across every server instance.
- We test each subscription path end to end, including authentication, delivery failure handling and what happens after a restart.
How we hand over
- You receive a written configuration record with each enabled channel, its settings and the systems it notifies.
- Runbooks cover subscription creation, monitoring of delivery, and steps to recover when a receiving endpoint fails.
- Your team gets a walkthrough of the test results and a list of open decisions for your security and operations owners.
How we support
- Ongoing support, upgrades and continuous testing are available as a retainer, scoped in writing.
- We can retest subscription paths after a HAPI FHIR version upgrade or a change to your server topology.
- Support scope, response expectations and any SLA terms are confirmed in the written agreement before work starts.

