camel-kafka-connector-examples
camel-kafka-connector-examples copied to clipboard
FHIR Source Connector config fails ro resolve endpoint
I want to add a source connector for polling Bundles from a FHIR API. Therefore I put together the following config:
{
"name": "my-fhir-source-connector",
"config": {
"connector.class": "org.apache.camel.kafkaconnector.fhir.CamelFhirSourceConnector",
"tasks.max": 1,
"topic": "fhir.input",
"camel.source.path.apiName": "OPERATION",
"camel.source.path.methodName": "$customOperation",
"camel.source.endpoint.serverUrl": "https://url-of-fhir-api-com/fhir",
"camel.source.endpoint.delay": 60000,
"camel.source.endpoint.password": "password",
"camel.source.endpoint.username": "user",
"camel.component.fhir.fhirVersion": "R4"
}
}
(This results in the error message listed at the end.)
The $customOperation returns a Collection Bundle.
Manually I am able to query this bundle by doing a POST on:
https://url-of-fhir-api-com/fhir/$customOperation
with a request body:
<Parameters xmlns="http://hl7.org/fhir">
<parameter>
<name value="domain" />
<valueString value="customDomain" />
</parameter>
</Parameters>
-
But I see no possibility to add a request body to the connector config. I played around with
camel.source.endpoint.inBodybut cannot get any result. How can I add parameters/body? -
And another question is, if the endpoint URL is correct? Because it seems the connector constructs the URL like:
https://url-of-fhir-api-com/fhir/operation/$customOperationinstead ofhttps://url-of-fhir-api-com/fhir/$customOperationIs this also a problem? -
Also, the log does not show the full URL it is accessing. Does it ignore the
serverUrlproperty?
The error log:
org.apache.kafka.connect.errors.ConnectException: Failed to create and start Camel context
at org.apache.camel.kafkaconnector.CamelSourceTask.start(CamelSourceTask.java:175)
at org.apache.kafka.connect.runtime.WorkerSourceTask.initializeAndStart(WorkerSourceTask.java:225)
at org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:186)
at org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:243)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
Caused by: org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[From[fhir:operation/$customOperation?dela... because of Failed to resolve endpoint: fhir://operation/$customOperation?delay=60000&password=xxxxxx due to: No matching method for operation/$customOperation, with arguments []
at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:80)
at org.apache.camel.impl.DefaultModelReifierFactory.createRoute(DefaultModelReifierFactory.java:49)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:826)
at org.apache.camel.impl.DefaultCamelContext.startRouteDefinitions(DefaultCamelContext.java:716)
at org.apache.camel.impl.engine.AbstractCamelContext.doInit(AbstractCamelContext.java:2757)
at org.apache.camel.support.service.BaseService.init(BaseService.java:83)
at org.apache.camel.impl.engine.AbstractCamelContext.init(AbstractCamelContext.java:2475)
at org.apache.camel.support.service.BaseService.start(BaseService.java:111)
at org.apache.camel.impl.engine.AbstractCamelContext.start(AbstractCamelContext.java:2494)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:245)
at org.apache.camel.main.SimpleMain.doStart(SimpleMain.java:43)
at org.apache.camel.support.service.BaseService.start(BaseService.java:119)
at org.apache.camel.kafkaconnector.CamelSourceTask.start(CamelSourceTask.java:172)
... 8 more
Caused by: org.apache.camel.ResolveEndpointFailedException: Failed to resolve endpoint: fhir://operation/$customOperation?delay=60000&password=xxxxxx due to: No matching method for operation/$customOperation, with arguments []
at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:962)
at org.apache.camel.impl.engine.AbstractCamelContext.getEndpoint(AbstractCamelContext.java:844)
at org.apache.camel.support.CamelContextHelper.getMandatoryEndpoint(CamelContextHelper.java:58)
at org.apache.camel.reifier.AbstractReifier.resolveEndpoint(AbstractReifier.java:177)
at org.apache.camel.reifier.RouteReifier.doCreateRoute(RouteReifier.java:94)
at org.apache.camel.reifier.RouteReifier.createRoute(RouteReifier.java:74)
... 20 more
Caused by: java.lang.IllegalArgumentException: No matching method for operation/$customOperation, with arguments []
at org.apache.camel.support.component.AbstractApiEndpoint.initState(AbstractApiEndpoint.java:172)
at org.apache.camel.support.component.AbstractApiEndpoint.configureProperties(AbstractApiEndpoint.java:134)
at org.apache.camel.support.DefaultComponent.setProperties(DefaultComponent.java:425)
at org.apache.camel.support.component.AbstractApiComponent.createEndpoint(AbstractApiComponent.java:90)
at org.apache.camel.support.DefaultComponent.createEndpoint(DefaultComponent.java:171)
at org.apache.camel.impl.engine.AbstractCamelContext.doGetEndpoint(AbstractCamelContext.java:928)
... 25 more
Thanks in advance for any help or hints
https://camel.apache.org/components/3.11.x/fhir-component.html#_api_operation
Those are the supported method for the operation API.
Thank you very much, that pointed me in the right direction. I have to learn more about REST and Operation syntax.
With the following connector config:
{
"name": "my-fhir-source-connector",
"config": {
"connector.class": "org.apache.camel.kafkaconnector.fhir.CamelFhirSourceConnector",
"tasks.max": 1,
"topic": "fhir.input",
"camel.source.path.apiName": "OPERATION",
"camel.source.path.methodName": "onServer?name=$customOperation&useHttpGet=false&extraParameters=domain=testDomain",
"camel.source.endpoint.serverUrl": "https://url-of-fhir-api-com/fhir",
"camel.source.endpoint.delay": 60000,
"camel.source.endpoint.password": "password",
"camel.source.endpoint.username": "user",
"camel.component.fhir.fhirVersion": "R4"
}
}
I receive the following error:
Caused by: [org.apache.camel.RuntimeCamelException - Error invoking onServer with {name=$customOperation, useHttpGet=false, extraParameters={}}: theParameters can not be null] (org.apache.camel.component.fhir.FhirConsumer)
org.apache.camel.RuntimeCamelException: Error invoking onServer with {name=$customOperation, useHttpGet=false, extraParameters={}}: theParameters can not be null
at org.apache.camel.support.component.ApiMethodHelper.invokeMethod(ApiMethodHelper.java:530)
I tried different variants to pass the required domain paramater, e.g. with parameters instead of extraParameters, or different kinds of brackets, but it doesnt help. Maybe you can help me on how to pass the domain parameter correctly? (domain=testDomain)
Thanks in advance