You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Tarun Kumar <ag...@gmail.com> on 2013/06/05 18:33:40 UTC

Restful services using camel

I am writing restful webservices using camel cxfrs components. I want to
expose > 10 services and my service interface looks like this:

@Path("/employees")
public interface EmployeeService {

@Post
@path("/account")
someMethod1();

@Get
@Path("/books")
someMethod2();
...
...
}

For each endPoint, i don't want to create one cxf:rsServer server (because
it won't be scalable solution). I want to expose all the services with one
cxf:rsServer. So, here is what i did:

<cxf:rsServer id="rsServer" address="http://localhost:8080/employee-service/
"

 serviceClass="com.abc. EmployeeServiceImpl" loggingFeatureEnabled="true"
loggingSizeLimit="20">

</cxf:rsServer>

Route for each service is different. i.e. from().to().to().end() for each
of these services is different. How can i make sure that when i invoke
http://localhost:8080/employee-service/employees/account, route for
someMethod1() should get called?

Re: Restful services using camel

Posted by Tarun Kumar <ag...@gmail.com>.
I dont want to create one bean (i.e. one interface and implementation
class) for each service. If i do that, i will end up having as much
interfaces as the number of services.

Also, if i create one rsServer, How will from() in each service route be
different from others? If i keep same endpoint (i.e.
from(cxfrs://bean://rsServer), i get this exception:
"Failed to start route because of Multiple consumers for the same endpoint
is not allowed."



On Thu, Jun 6, 2013 at 3:13 PM, Sergey Beryozkin <sb...@gmail.com>wrote:

> Hi
>
> On 05/06/13 17:33, Tarun Kumar wrote:
>
>> I am writing restful webservices using camel cxfrs components. I want to
>> expose > 10 services and my service interface looks like this:
>>
>> @Path("/employees")
>> public interface EmployeeService {
>>
>> @Post
>> @path("/account")
>> someMethod1();
>>
>> @Get
>> @Path("/books")
>> someMethod2();
>> ...
>> ...
>> }
>>
>> For each endPoint, i don't want to create one cxf:rsServer server (because
>> it won't be scalable solution). I want to expose all the services with one
>> cxf:rsServer. So, here is what i did:
>>
>> <cxf:rsServer id="rsServer" address="http://localhost:**
>> 8080/employee-service/ <http://localhost:8080/employee-service/>
>> "
>>
>>   serviceClass="com.abc. EmployeeServiceImpl" loggingFeatureEnabled="true"
>> loggingSizeLimit="20">
>>
>> </cxf:rsServer>
>>
>> Route for each service is different. i.e. from().to().to().end() for each
>> of these services is different. How can i make sure that when i invoke
>> http://localhost:8080/**employee-service/employees/**account<http://localhost:8080/employee-service/employees/account>,
>> route for
>> someMethod1() should get called?
>>
>>  As far as I understand you may want to have a single cxf:rsServer
> endpoint which has up to 10 resource classes/beans.
> With the regular CXF jaxrs:server, one can do something like this:
>
> <jaxrs:server address="/company">
>    <jaxrs:serviceBeans>
>       <ref bean="bean1"/>
>       <!-- ... -->
>       <ref bean="bean10"/>
>    </jaxrs:serviceBeans>
> </jaxrs:server>
>
> where bean1 to bean10 represent individual root resources, once starting
> with "/employees", another one with "/managers", etc
>
> I guess you may want to do something like this too with cxf:rsServer
> Cheers, Sergey
>
>

Re: Restful services using camel

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 05/06/13 17:33, Tarun Kumar wrote:
> I am writing restful webservices using camel cxfrs components. I want to
> expose > 10 services and my service interface looks like this:
>
> @Path("/employees")
> public interface EmployeeService {
>
> @Post
> @path("/account")
> someMethod1();
>
> @Get
> @Path("/books")
> someMethod2();
> ...
> ...
> }
>
> For each endPoint, i don't want to create one cxf:rsServer server (because
> it won't be scalable solution). I want to expose all the services with one
> cxf:rsServer. So, here is what i did:
>
> <cxf:rsServer id="rsServer" address="http://localhost:8080/employee-service/
> "
>
>   serviceClass="com.abc. EmployeeServiceImpl" loggingFeatureEnabled="true"
> loggingSizeLimit="20">
>
> </cxf:rsServer>
>
> Route for each service is different. i.e. from().to().to().end() for each
> of these services is different. How can i make sure that when i invoke
> http://localhost:8080/employee-service/employees/account, route for
> someMethod1() should get called?
>
As far as I understand you may want to have a single cxf:rsServer 
endpoint which has up to 10 resource classes/beans.
With the regular CXF jaxrs:server, one can do something like this:

<jaxrs:server address="/company">
    <jaxrs:serviceBeans>
       <ref bean="bean1"/>
       <!-- ... -->
       <ref bean="bean10"/>
    </jaxrs:serviceBeans>
</jaxrs:server>

where bean1 to bean10 represent individual root resources, once starting 
with "/employees", another one with "/managers", etc

I guess you may want to do something like this too with cxf:rsServer
Cheers, Sergey