Hi Stig,

Endpoint options are set at a later stage[1] which is why you don't see the
desired cutstom client.

You could also set a breakpoint at [2] to see which client is really used
for the update method. From what I see you're setting it up correctly.

HTH,

John.

[1]
https://github.com/apache/camel/blob/f88ca73cf730a83cd99b5389f79a82ca3c7abdc3/core/camel-support/src/main/java/org/apache/camel/support/component/AbstractApiEndpoint.java#L105
[2]
https://github.com/apache/camel/blob/b9a3117f19dd19abd2ea8b789c42c3e86fe4c488/components/camel-fhir/camel-fhir-api/src/main/java/org/apache/camel/component/fhir/api/FhirUpdate.java#L37

On Thu, Jun 27, 2019 at 1:19 PM Stig Døssing <stig.doss...@systematic.com>
wrote:

> Hi John,
>
> I work with Paw. We're trying to set either the client or client factory
> via the URI header, because we'd like to add a request interceptor to the
> client. We would like to log error response bodies.
>
> You are right that it was weird to use HTTP_QUERY. Instead we've done the
> following:
>
> .process(exchange -> {
>   LOG.error("The client in the registry {}",
> getContext().getRegistry().lookupByName("testClient"));
> }
> .toD("fhir:update/resource?client=#testClient ").
>
> We've verified that our test client is in the Camel registry by looking it
> up in the registry in the processor immediately before sending to the FHIR
> endpoint.
> When we set a breakpoint in the processor, and then break on the next
> invocation of
> https://github.com/apache/camel/blob/789f1b26cf8b5ce7e40741c1236c3e1622c3550d/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirComponent.java#L52,
> we are seeing the FhirConfiguration.client field be null.
>
>
> -----Original Message-----
> From: John Poth <poth.j...@gmail.com>
> Sent: 26. juni 2019 15:13
> To: users@camel.apache.org
> Subject: Re: How to set client or clientFactory in the FhirConfiguration
> object?
>
> Hi Paw, I'm not sure why you're trying to set the custom IGenericClient
> through the Camel header; I'd need more info on your requirements. If you
> can link to a github project or whatnot that'd be great.
>
> As stated, you can set the custom client in your route URI directly [1]
> referencing your bean in your spring registry e.g
> .to('fhir://create/resource?client=#customClientBeanName')
>
> You can also set it directly on the component level if you want to use it
> in multiple URIs [2]
>
> HTH,
>
> John.
>
>
> [1]
>
> https://github.com/apache/camel/blob/b9a3117f19dd19abd2ea8b789c42c3e86fe4c488/components/camel-fhir/camel-fhir-component/src/test/java/org/apache/camel/component/fhir/FhirCustomClientConfigurationIT.java#L67
> [2]
>
> https://github.com/apache/camel/blob/b9a3117f19dd19abd2ea8b789c42c3e86fe4c488/components/camel-fhir/camel-fhir-component/src/main/java/org/apache/camel/component/fhir/FhirComponent.java#L79
>
>
>
>
>
> On Wed, Jun 26, 2019 at 12:43 PM Paw B Sørensen <
> paw.b.soren...@systematic.com> wrote:
>
> > I still have problem setting my custom client in the
> > FhirConfiguration. I have implemented a custom client TestClient
> > implementing the IGenericClient interface and I annotated the class
> > with @Component. I also implemented a route where I try to set my
> > custom client using the following strategy
> >
> >         .setHeader(Exchange.HTTP_QUERY, simple("client=#testClient"))
> >
> > When I debug a test that activates the route I  break in the first
> > line of the createEndpoint method of the FhirComponent and inspect the
> > client variable of the endpoint it is null.
> >
> > I am running this in a Spring configuration.
> >
> > Paw B Sørensen
> > paw.b.soren...@systematic.com
> >
> >
> > -----Original Message-----
> > From: Claus Ibsen <claus.ib...@gmail.com>
> > Sent: 25. juni 2019 07:42
> > To: users@camel.apache.org
> > Subject: Re: How to set client or clientFactory in the
> > FhirConfiguration object?
> >
> > Hi
> >
> > I have fixed this for master, eg Camel 3
> >
> > On Fri, Jun 21, 2019 at 2:20 PM Claus Ibsen <claus.ib...@gmail.com>
> wrote:
> > >
> > > And btw you should still be able to configure them as query
> > > parameters, as those @UriParam etc are for documentation purposes.
> > >
> > > On Fri, Jun 21, 2019 at 2:19 PM Claus Ibsen <claus.ib...@gmail.com>
> > wrote:
> > > >
> > > > Hi
> > > >
> > > > Ah those 2 are wrong they should be @UriParam also. You are
> > > > welcome to log a JIRA and provide a PR
> > > >
> > > > On Fri, Jun 21, 2019 at 10:10 AM Paw B Sørensen
> > > > <paw.b.soren...@systematic.com> wrote:
> > > > >
> > > > > The camel fhir component supports setting several query
> > > > > parameters. In the implementation of FhirConfiguration all of
> > > > > these
> > parameters are annotated with @UriParam. Also in the implementation of
> > FhirConfiguration I find the client and clientFactory variables but
> > they are annotated with @Metadata. Can I make my own custom
> > implementation of the client to intercept whenever a response code 4xx
> > is received? And is it possible to set these Metadata values in my camel
> route?
> > > > >
> > > >
> > > >
> > > > --
> > > > Claus Ibsen
> > > > -----------------
> > > > http://davsclaus.com @davsclaus
> > > > Camel in Action 2: https://www.manning.com/ibsen2
> > >
> > >
> > >
> > > --
> > > Claus Ibsen
> > > -----------------
> > > http://davsclaus.com @davsclaus
> > > Camel in Action 2: https://www.manning.com/ibsen2
> >
> >
> >
> > --
> > Claus Ibsen
> > -----------------
> > http://davsclaus.com @davsclaus
> > Camel in Action 2: https://www.manning.com/ibsen2
> >
>

Reply via email to