This example showcases Aidbox SubscriptionTopic producing data to Kafka.
Objectives:
Table of Contents
aidbox-subscriptions-to-kafka
Copy the .env.tpl
file to .env
:
cp .env.tpl .env
Get a self-hosted Aidbox license from the Aidbox Portal.
Add the license key (AIDBOX_LICENSE
) to the .env
file.
docker compose up
admin
password
http://localhost:9092/
(no authorization required)The Docker Compose file initializes the environment for both Kafka and Aidbox with the following configuration:
init-aidbox
service).QuestionnaireResponse
(see init-kafka
service).To create a subscription on the QuestionnaireResponse
resource that has a specific status, open Aidbox UI -> APIs -> REST Console and execute the following request:
POST /fhir/AidboxSubscriptionTopic
content-type: application/json
accept: application/json
{
"resourceType": "AidboxSubscriptionTopic",
"url": "http://example.org/FHIR/R5/SubscriptionTopic/QuestionnaireResponse-topic",
"status": "active",
"trigger": [
{
"resource": "QuestionnaireResponse",
"fhirPathCriteria": "status = 'completed' or status = 'amended'"
}
]
}
This resource describes the data source for the subscription but doesn’t execute any activities from Aidbox.
Creating this resource establishes a connection to the Kafka server. When the system produces an event, it will be processed to the specified Kafka topic.
POST /fhir/AidboxTopicDestination
content-type: application/json
accept: application/json
{
"meta": {
"profile": [
"http://aidbox.app/StructureDefinition/aidboxtopicdestination-kafka-at-least-once"
]
},
"kind": "kafka-at-least-once",
"id": "kafka-destination",
"topic": "http://example.org/FHIR/R5/SubscriptionTopic/QuestionnaireResponse-topic",
"parameter": [
{
"name": "kafkaTopic",
"valueString": "aidbox-forms"
},
{
"name": "bootstrapServers",
"valueString": "kafka:29092"
}
]
}
Open the list of forms, click share
-> enable ‘allow amend’ -> click attach
-> copy the link -> open the link -> fill out the form, and submit it.
Open the Aidbox REST Console and get the AidboxTopicDestination status:
GET /fhir/AidboxTopicDestination/kafka-destination/$status
Open Kafka UI -> Topics
-> aidbox-forms
-> messages
and review the QuestionnaireResponse
that was created after submitting the form.
Also you can find example of k8s deployment:
A deployed and configured Aidbox instance with Kafka is available for you to explore how Aidbox’s SubscriptionTopic works. The SubscriptionTopic in Aidbox is set up to send QuestionnaireResponse
events in the completed
and amended
status to Kafka.
To try it out:
QuestionnaireResponse
in the Kafka messages tab.