Rest registry has no services

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Rest registry has no services

Alex Soto
Hello,

I have a few Rest Services defined with Camel Blueprint DSL (Camel 3.4.0 running on Karaf 4.2.9).
In my integration test, I want to discover the services for testing.
After the Camel Context reaches status ServiceStatus.Started, the Rest Registry reports no services, although everything is fine with the services.

        List<RestService> services = camelContext.getRestRegistry().listAllRestServices();
        assertTrue(services.size() > 1);

The above assertion is failing even though several services are running and I can use them without any problem.
Any idea why is this happening?

Thanks and best regards,
Alex soto




Reply | Threaded
Open this post in threaded view
|

Re: Rest registry has no services

jbonofre
Hi,

AFAIR, getRestRegistry() will work only for REST DSL. If you use the Blueprint DSL, you should check the consumer of your routes (cafes, rest, whatever).

Regards
JB

> Le 21 juil. 2020 à 16:14, Alex Soto <[hidden email]> a écrit :
>
> Hello,
>
> I have a few Rest Services defined with Camel Blueprint DSL (Camel 3.4.0 running on Karaf 4.2.9).
> In my integration test, I want to discover the services for testing.
> After the Camel Context reaches status ServiceStatus.Started, the Rest Registry reports no services, although everything is fine with the services.
>
> List<RestService> services = camelContext.getRestRegistry().listAllRestServices();
> assertTrue(services.size() > 1);
>
> The above assertion is failing even though several services are running and I can use them without any problem.
> Any idea why is this happening?
>
> Thanks and best regards,
> Alex soto
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Rest registry has no services

Alex Soto
Hi JB,

I am now more confused.  I thought I was using Rest DSL when I defined my services in a Blueprint DSL as in:


                <restConfiguration
                        component="servlet"
  jsonDataFormat="JsonApiDataFormat"
                        bindingMode="json"
                        enableCORS="false"
                        contextPath="{{context.path}}{{api.root.path}}"
                        skipBindingOnErrorCode="false"
                        clientRequestValidation="true">

                        <componentProperty key="matchOnUriPrefix" value="true"/>

                        <endpointProperty key="servletName" value="AdminRestApiServlet"/>
                        <endpointProperty key="disableStreamCache" value="true"/>
                       
                        <dataFormatProperty key="contentTypeHeader" value="false" />
    </restConfiguration>
   
    <rest produces="{{admin.api.media.type}}; version={{admin.api.latest.version}}">
    <get>
    <to uri="direct:resources"/>
    </get>
    </rest>



Rest registry does seem to work sporadically,  but not all the time, which is weird.   For example, from my custom data format I can access the Rest configuration:

                exchange.getContext().getRestConfiguration().getContextPath();

And the registry sometimes has data:

        exchange.getContext().getRestRegistry()

But sometimes it doesn’t, all during in the same execution session.

Best regards,
Alex soto




> On Jul 22, 2020, at 2:13 AM, Jean-Baptiste Onofre <[hidden email]> wrote:
>
> Hi,
>
> AFAIR, getRestRegistry() will work only for REST DSL. If you use the Blueprint DSL, you should check the consumer of your routes (cafes, rest, whatever).
>
> Regards
> JB
>
>> Le 21 juil. 2020 à 16:14, Alex Soto <[hidden email]> a écrit :
>>
>> Hello,
>>
>> I have a few Rest Services defined with Camel Blueprint DSL (Camel 3.4.0 running on Karaf 4.2.9).
>> In my integration test, I want to discover the services for testing.
>> After the Camel Context reaches status ServiceStatus.Started, the Rest Registry reports no services, although everything is fine with the services.
>>
>> List<RestService> services = camelContext.getRestRegistry().listAllRestServices();
>> assertTrue(services.size() > 1);
>>
>> The above assertion is failing even though several services are running and I can use them without any problem.
>> Any idea why is this happening?
>>
>> Thanks and best regards,
>> Alex soto
>>
>>
>>
>>
>