Re: Camel CXFRS and Swagger/OpenAPI Feature

2018-11-26 Thread Sergey Beryozkin
Hi Zoran

CXF RS endpoint can have JAX-RS ContainerRequestFilters attached, and this
is where a bit of ambiguity occurs. You are right, if if were only the case
of the actual RS implementation immediately returning some value then it
would be questionable why to involve Camel at all.
But ContainerRequestFilters can be blocking and the CXF Swagger/OpenApi
feature which was updated to optionally run as a filter specifically to
support a Camel case, produces JAX-RS Response which is not really related
to what Camel route itself does... I agree in most cases one would block if
needed in the route itself, it is one of the exceptions...

Cheers, Sergey

On Thu, Nov 22, 2018 at 7:09 PM Zoran Regvart  wrote:

> Hi Sergey,
> I think we might have that as an option, though if Camel simply
> returns what the resource method generates, why have it pass through
> Camel at all? Perhaps I don't fully understand the use case.
>
> I think it's quite easy to mix purely JAX-RS implemented resources and
> Camel implemented ones.
>
> Sergey and Jens, if you think we should improve on this, can you
> please create a JIRA issue and describe a brief use case where this
> would be a good addition to Camel CXFRS component.
>
> thanks & keep riding :)
>
> zoran
>
> On Tue, Nov 20, 2018 at 6:31 PM Sergey Beryozkin 
> wrote:
> >
> > As far as I recall, a corresponding CXF filter is a blocking one and
> > returns a JAX-RS Response. May be the CamelCXF RS code needs to be
> tweaked
> > a bit to check if JAX-RS Response is already available before continuing
> > with the route flow...
> >
> > Cheers, Sergey
> >
> >
> > On Tue, Nov 20, 2018 at 5:20 PM #S-SmixDev  wrote:
> >
> > > Hi Zoran,
> > >
> > > yeah, I suspected that might be the way it's supposed to work, but the
> > > problem here of course is that I don't actually have a ResourceImpl of
> my
> > > real service, only an interface, and therefore performInvocation
> doesn't
> > > work for me unless I write a Dummy implementation, too.
> > >
> > > Cheers,
> > > Jens
> > >
> > > [image: Inactive hide details for "Zoran Regvart" ---20.11.2018
> > > 17:28:53---Hi Jens, from the little exploration I did I think you
> need]"Zoran
> > > Regvart" ---20.11.2018 17:28:53---Hi Jens, from the little exploration
> I
> > > did I think you need to set
> > >
> > > Von: "Zoran Regvart" 
> > > An: users@camel.apache.org,
> > > Datum: 20.11.2018 17:28
> > > Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature
> > > --
> > >
> > >
> > > Hi Jens,
> > > from the little exploration I did I think you need to set
> > > `performInvocation` to `true`: the way OpenAPI support in CXF works is
> > > by registering a resource that will generate the OpenAPI
> > > specification, and that JAX-RS resource class[1] has an `getOpenApi`
> > > method.
> > >
> > > So your routes need to look something like this:
> > >
> > > from("cxfrs://
> > >
> http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true
> > > ")
> > > .toD("direct:${header.operationName}");
> > >
> > > from("direct:getOpenApi").log("Fetching OpenAPI specification");
> > >
> > > The `log` here is just in place of a dummy processor so that the route
> > > has a `from` and a `to`.
> > >
> > > The way I came to think of it is that the resource classes give the
> > > REST API shape, and the implementation is provided by Camel route,
> > > which is kinda difficult to grasp since the most natural thing would
> > > be to write the implementation within the resource method.
> > >
> > > zoran
> > >
> > > [1]
> > >
> https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28
> > > On Mon, Nov 19, 2018 at 2:03 PM #S-SmixDev  wrote:
> > > >
> > > >
> > > > Hi Camel Riders,
> > > >
> > > > I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using
> the
> > > > Swagger/OpenAPI Feature.
> > > >
> > > > This works fine with a "pure" CXF endpoint, no Camel involved.
> > > >
> > > > When using Camel-CXFRS, however, I can't make it work properly
> without
> > > > extra implementation work in the Camel route.
> > > >
> > > > Using runAsFilter=false a call to
> > > > http://localhost:8080/services/myCamelService/openapi.json
> > > > results in a call of the Camel route with an operation "getOpenApi"
> > > >
> > > >
> http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
> > > > results in call of the Camel route with an operation "getResource"
> > > >
> > > > Using runAsFilter=true the situation improves marginally:
> > > > http://localhost:8080/services/myCamelService/openapi.json
> > > > still results in a call of the Camel route with an operation
> "getOpenApi"
> > > >
> > > >
> http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
> > > > at least now shows the Swagger UI page frame but still fails to load
> the
> > > > actual service description since it again calls th

Re: Camel CXFRS and Swagger/OpenAPI Feature

2018-11-26 Thread #S-SmixDev

Done:
https://issues.apache.org/jira/browse/CAMEL-12957

Cheers,
Jens



Von:"Zoran Regvart" 
An: users@camel.apache.org,
Datum:  22.11.2018 20:09
Betreff:Re: Camel CXFRS and Swagger/OpenAPI Feature


Hi Sergey,
I think we might have that as an option, though if Camel simply
returns what the resource method generates, why have it pass through
Camel at all? Perhaps I don't fully understand the use case.

I think it's quite easy to mix purely JAX-RS implemented resources and
Camel implemented ones.

Sergey and Jens, if you think we should improve on this, can you
please create a JIRA issue and describe a brief use case where this
would be a good addition to Camel CXFRS component.

thanks & keep riding :)

zoran

On Tue, Nov 20, 2018 at 6:31 PM Sergey Beryozkin 
wrote:
>
> As far as I recall, a corresponding CXF filter is a blocking one and
> returns a JAX-RS Response. May be the CamelCXF RS code needs to be
tweaked
> a bit to check if JAX-RS Response is already available before continuing
> with the route flow...
>
> Cheers, Sergey
>
>
> On Tue, Nov 20, 2018 at 5:20 PM #S-SmixDev  wrote:
>
> > Hi Zoran,
> >
> > yeah, I suspected that might be the way it's supposed to work, but the
> > problem here of course is that I don't actually have a ResourceImpl of
my
> > real service, only an interface, and therefore performInvocation
doesn't
> > work for me unless I write a Dummy implementation, too.
> >
> > Cheers,
> > Jens
> >
> > [image: Inactive hide details for "Zoran Regvart" ---20.11.2018
> > 17:28:53---Hi Jens, from the little exploration I did I think you
need]"Zoran
> > Regvart" ---20.11.2018 17:28:53---Hi Jens, from the little exploration
I
> > did I think you need to set
> >
> > Von: "Zoran Regvart" 
> > An: users@camel.apache.org,
> > Datum: 20.11.2018 17:28
> > Betreff: Re: Camel CXFRS and Swagger/OpenAPI Feature
> > --
> >
> >
> > Hi Jens,
> > from the little exploration I did I think you need to set
> > `performInvocation` to `true`: the way OpenAPI support in CXF works is
> > by registering a resource that will generate the OpenAPI
> > specification, and that JAX-RS resource class[1] has an `getOpenApi`
> > method.
> >
> > So your routes need to look something like this:
> >
> > from("cxfrs://
> >
http://localhost:8080/api?features=#openApi&resourceClasses=...&performInvocation=true

> > ")
> > .toD("direct:${header.operationName}");
> >
> > from("direct:getOpenApi").log("Fetching OpenAPI specification");
> >
> > The `log` here is just in place of a dummy processor so that the route
> > has a `from` and a `to`.
> >
> > The way I came to think of it is that the resource classes give the
> > REST API shape, and the implementation is provided by Camel route,
> > which is kinda difficult to grasp since the most natural thing would
> > be to write the implementation within the resource method.
> >
> > zoran
> >
> > [1]
> >
https://github.com/swagger-api/swagger-core/blob/master/modules/swagger-jaxrs2/src/main/java/io/swagger/v3/jaxrs2/integration/resources/OpenApiResource.java#L28

> > On Mon, Nov 19, 2018 at 2:03 PM #S-SmixDev  wrote:
> > >
> > >
> > > Hi Camel Riders,
> > >
> > > I'm trying to integrate a Camel-CXFRS endpoint with Swagger UI using
the
> > > Swagger/OpenAPI Feature.
> > >
> > > This works fine with a "pure" CXF endpoint, no Camel involved.
> > >
> > > When using Camel-CXFRS, however, I can't make it work properly
without
> > > extra implementation work in the Camel route.
> > >
> > > Using runAsFilter=false a call to
> > > http://localhost:8080/services/myCamelService/openapi.json
> > > results in a call of the Camel route with an operation "getOpenApi"
> > >
> > >
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
> > > results in call of the Camel route with an operation "getResource"
> > >
> > > Using runAsFilter=true the situation improves marginally:
> > > http://localhost:8080/services/myCamelService/openapi.json
> > > still results in a call of the Camel route with an operation
"getOpenApi"
> > >
> > >
http://localhost:8080/services/myCamelServive/api-docs?url=openapi.json
> > > at least now shows the Swagger UI page frame but still fails to load
the
> > > actual service description since it again calls the Camel route with
the
> > > "getOpenApi" operation.
> > >
> > > As far as I can see, calling the API description endpoints should not
> > > involve the Camel route at all, and this "getOpenApi" call should
instead
> > > happen on the internal service resource.
> > >
> > > Has anyone successfully set this up just using the CXF feature out of
the
> > > box? Is this even possible?
> > >
> > > Cheers,
> > > Jens
> > > ___
> > >
> > > DZ BANK AG
> > > Deutsche Zentral-Genossenschaftsbank, Frankfurt am Main
> > > Platz der Republik, 60325 Frankfurt am Main
> > > Deutschland/Germany
> > >
> > > https://www.dzbank.de
> > > mailto:m...@dzbank.de , T +4

large xml files using groovy

2018-11-26 Thread Raymond de Hond
Hi,

I created a camel route using a soap endpoint (contract first) using format
PAYLOAD.

My question is, what's the best approach to read large xml messages (up to
20mb)  using groovy xmlSlurper? This slurper accepts a java.io.Reader as
input. Is it possible to do something like:


def xml = exchange.getIn().getBody(java.io.Reader);


And should I enable streamCache = true on my route?


Regards,


Raymond