This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-kafka-connector-examples.git
The following commit(s) were added to refs/heads/master by this push: new 23609d6 Added FHIR Source and Sink Examples 23609d6 is described below commit 23609d6e4e53bdfc46f39b11aa5fa29ca387efad Author: Luigi De Masi <ldem...@redhat.com> AuthorDate: Mon Feb 8 15:33:30 2021 +0100 Added FHIR Source and Sink Examples --- fhir/sink/CamelFhirSinkConnector.properties | 31 +++++++++++ fhir/sink/README.adoc | 52 ++++++++++++++++++ fhir/sink/patientAI.json | 1 + fhir/sink/patientKobe.json | 1 + fhir/source/CamelFhirSourceConnector.properties | 38 +++++++++++++ fhir/source/README.adoc | 71 +++++++++++++++++++++++++ 6 files changed, 194 insertions(+) diff --git a/fhir/sink/CamelFhirSinkConnector.properties b/fhir/sink/CamelFhirSinkConnector.properties new file mode 100644 index 0000000..bf79468 --- /dev/null +++ b/fhir/sink/CamelFhirSinkConnector.properties @@ -0,0 +1,31 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +name=CamelFhirSinkConnector +topics=patients +connector.class=org.apache.camel.kafkaconnector.fhir.CamelFhirSinkConnector +key.converter=org.apache.kafka.connect.storage.StringConverter +value.converter=org.apache.kafka.connect.storage.StringConverter +camel.sink.unmarshal=fhirJson +camel.dataformat.fhirJson.fhirVersion=R4 +camel.dataformat.fhirJson.prettyPrint=true +camel.sink.endpoint.serverUrl=http://hapi.fhir.org/baseR4/ +camel.sink.endpoint.inBody=resource +camel.sink.endpoint.log=true +camel.sink.path.apiName=create +camel.sink.path.methodName=resource + + diff --git a/fhir/sink/README.adoc b/fhir/sink/README.adoc new file mode 100644 index 0000000..f573a01 --- /dev/null +++ b/fhir/sink/README.adoc @@ -0,0 +1,52 @@ +# Camel-Kafka-connector FHIR Sink Example + +## Introduction + +This is an example for Camel-Kafka-connector + +## What is needed + +- A Kafka Cluster running + +## Running Kafka + +``` +$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties +$KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties +$KAFKA_HOME/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic patients +``` + + +## Setting up the needed bits and running the example + +You'll need to setup the plugin.path property in your kafka + +Open the `$KAFKA_HOME/config/connect-standalone.properties` + +and set the `plugin.path` property to your choosen location + +In this example we'll use `/home/ldemasi/connectors/` + +``` +> mkdir -p /home/ldemasi/connectors/ && cd /home/ldemasi/connectors/ +> wget https://repo1.maven.org/maven2/org/apache/camel/kafkaconnector/camel-fhir-kafka-connector/0.7.1/camel-fhir-kafka-connector-0.7.1-package.zip +> unzip camel-fhir-kafka-connector-0.7.1-package.zip +``` + +Now you can run the example + +``` +$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties source/CamelFhirSinkConnector.properties +``` + +Just connect to your Kafka +- Produce some sample kafka messages +```bash +$KAFKA_HOME/bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic patients < sink/patientKobe.json +$KAFKA_HOME/bin/kafka-console-producer.sh --bootstrap-server localhost:9092 --topic patients < sink/patientAI.json +``` +- Check with the HAPI FHIR REST server that the patients have been created: +```bash +curl -v http://hapi.fhir.org/baseR4/Patient?given=bean&_pretty=true +curl -v http://hapi.fhir.org/baseR4/Patient?given=Ezail&_pretty=true +``` \ No newline at end of file diff --git a/fhir/sink/patientAI.json b/fhir/sink/patientAI.json new file mode 100644 index 0000000..77e0b04 --- /dev/null +++ b/fhir/sink/patientAI.json @@ -0,0 +1 @@ +{ "resourceType": "Patient", "meta": { "versionId": "1", "lastUpdated": "2020-02-27T15:54:12.956+00:00", "source": "#2mnetMRtkFCKvIZ4" }, "text": { "status": "generated" }, "identifier": [ { "system": "urn:system", "value": "12345bbb" } ], "active": true, "name": [ { "family": "Iverson", "given": [ "Allen", "Ezail" ] } ]} \ No newline at end of file diff --git a/fhir/sink/patientKobe.json b/fhir/sink/patientKobe.json new file mode 100644 index 0000000..c088abb --- /dev/null +++ b/fhir/sink/patientKobe.json @@ -0,0 +1 @@ +{"resourceType":"Patient","meta": {"versionId": "1","lastUpdated":"2020-02-27T15:54:12.956+00:00","source": "#2mnetMRtkFCKvIZ4"},"text": {"status": "generated"},"identifier": [ { "system": "urn:system","value": "12345aaa"}],"active": true,"name":[{"family": "Briant","given": ["Kobe","Bean"]}]} \ No newline at end of file diff --git a/fhir/source/CamelFhirSourceConnector.properties b/fhir/source/CamelFhirSourceConnector.properties new file mode 100644 index 0000000..3715c11 --- /dev/null +++ b/fhir/source/CamelFhirSourceConnector.properties @@ -0,0 +1,38 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +name=CamelFhirSourceConnector +topics=patients +connector.class=org.apache.camel.kafkaconnector.fhir.CamelFhirSourceConnector +key.converter=org.apache.kafka.connect.storage.StringConverter +value.converter=org.apache.kafka.connect.storage.StringConverter +transforms: tostring +transforms.tostring.type: org.apache.camel.kafkaconnector.transforms.CamelTypeConverterTransform$Value +transforms.tostring.target.type: java.lang.String +camel.source.marshal=fhirJson +camel.dataformat.fhirJson.enabled=true +camel.dataformat.fhirJson.fhirVersion=R4 +camel.dataformat.fhirJson.prettyPrint=true +camel.component.fhir.encoding=JSON +camel.component.fhir.fhirVersion=R4 +camel.source.endpoint.forceConformanceCheck=true +camel.source.endpoint.prettyPrint=true +camel.source.endpoint.repeatCount=1 +camel.source.endpoint.serverUrl=http://hapi.fhir.org/baseR4 +camel.source.endpoint.url=/Patient +camel.source.path.apiName=search +camel.source.path.methodName=searchByUrl diff --git a/fhir/source/README.adoc b/fhir/source/README.adoc new file mode 100644 index 0000000..2975aba --- /dev/null +++ b/fhir/source/README.adoc @@ -0,0 +1,71 @@ +# Camel-Kafka-connector FHIR Source Example + +## Introduction + +This is an example for Camel-Kafka-connector + +## What is needed + +- A Kafka Cluster running + +## Running Kafka + +``` +$KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties +$KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties +$KAFKA_HOME/bin/kafka-topics.sh --create --bootstrap-server localhost:9092 --replication-factor 1 --partitions 1 --topic patients +``` + + +## Setting up the needed bits and running the example + +You'll need to setup the plugin.path property in your kafka + +Open the `$KAFKA_HOME/config/connect-standalone.properties` + +and set the `plugin.path` property to your choosen location + +In this example we'll use `/home/ldemasi/connectors/` + +``` +> mkdir -p /home/ldemasi/connectors/ && cd /home/ldemasi/connectors/ +> wget https://repo1.maven.org/maven2/org/apache/camel/kafkaconnector/camel-fhir-kafka-connector/0.7.1/camel-fhir-kafka-connector-0.7.1-package.zip +> unzip camel-fhir-kafka-connector-0.7.1-package.zip +``` + +Now you can run the example + +``` +$KAFKA_HOME/bin/connect-standalone.sh $KAFKA_HOME/config/connect-standalone.properties source/CamelFhirSourceConnector.properties +``` + +Just connect to your Kafka and check with the kafka console consumer that the messages are available in the kafka topic. +```bash +$KAFKA_HOME/bin/kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic mytopic --from-beginning +{ + "resourceType": "Bundle", + "id": "80a62211-eb26-412c-9ebc-f39bc1f1dff7", + "meta": { + "lastUpdated": "2021-02-10T14:22:46.149+00:00" + }, + "type": "searchset", + "link": [ + { + "relation": "self", + "url": "http://hapi.fhir.org/baseR4/Patient?_pretty=true" + }, + { + "relation": "next", + "url": "http://hapi.fhir.org/baseR4?_getpages=80a62211-eb26-412c-9ebc-f39bc1f1dff7&_getpagesoffset=20&_count=20&_pretty=true&_bundletype=searchset" + } + ], + "entry": [ + { + "fullUrl": "http://hapi.fhir.org/baseR4/Patient/628467", + "resource": { + "resourceType": "Patient", + "id": "628467", +......... + +Ctrl+C +```