REST interface ...is exceeding the 65535 bytes limit

Six Stars

REST interface ...is exceeding the 65535 bytes limit

Hello,
I have design an REST interface for an sql db. After the 22 URI for the rest interface, I receive the following error:
 The code of method tRESTRequest_1_LoopProcess(Map<String,Object>) is exceeding the 65535 bytes limit.
I think I need to split the rest interface, but I cant set second rest interface in job. I can create a second job with an rest interface over an other ports, but this solution is not so nice.
Have anybody an other solution?
Greets Benjamin
Sixteen Stars

Re: REST interface ...is exceeding the 65535 bytes limit

The first thing to try is to use childjobs (jobs run using the tRunJob component) in your REST service. It sounds like you have a lot of components in your service to handle the 22 URIs. You should be able to package each of the URI processing paths into child jobs. Doing this will massively reduce the amount of code in your service.
Six Stars

Re: REST interface ...is exceeding the 65535 bytes limit

for every uri I have 4 child jobs: tflowtoiterate,tpostgresqlinput,txmlmap and trestresponse
Employee

Re: REST interface ...is exceeding the 65535 bytes limit

Can some parts in your URIs be captured as templates ?
Example, instead of
/1/2/a
/1/3/a
etc
do
/1/{id}/a
and then have an 'id' variable in a schema.
Another option to try is to capture several segments with regular expressions:
/1/{id:.*}
in this case 'id' will capture either 2/a or 3/a
Sergey
Six Stars

Re: REST interface ...is exceeding the 65535 bytes limit

so I have to create 22 subjobs with these 4 child element? Or can I sumirize it?
Six Stars

Re: REST interface ...is exceeding the 65535 bytes limit

The problem is that the sql queries and the received data (tablename) are very different vor every uri.
Employee

Re: REST interface ...is exceeding the 65535 bytes limit

Perhaps you might want to try query parameters
Sixteen Stars

Re: REST interface ...is exceeding the 65535 bytes limit

Hang on, are you trying to run this from the Studio? It sounds like you are trying to run the service from the Studio and that maybe why you are feeling limited. You can create a service for each URI (in my opinion that would be better) and have them all running with the same port in Apache Karaf (the Runtime). When running in the Studio you really are limited.
Six Stars

Re: REST interface ...is exceeding the 65535 bytes limit

yes I trying to run this from the studio. So I can create more then one REST interface and run this in karaf under one kaf file (job)?
Sixteen Stars

Re: REST interface ...is exceeding the 65535 bytes limit

I would recommend putting a local version of Karaf on your development machine and creating a kar file for every service you want to provide. This way you can have them all running in karaf together and test other components with them using the Studio. There is also the issue of Talend Studio not being a perfect copy of the Karaf environment. You will find that some things that work on Studio will not work the same in Karaf (and vice versa). The development lifecycle of a Talend service/route should be to build it on the Studio and then move it to test in the Karaf. Then keep your successful routes and services in your local Karaf so that you can test new routes and services being built in Studio with the ones running in Karaf. It's a bit fiddly, but makes life a lot easier in the long run. 
Six Stars

Re: REST interface ...is exceeding the 65535 bytes limit

but it is a job I can only create a jar file. I have split the rest interfaces into 2, build two jars and put it into karaf. It says endpoint already running.
Sixteen Stars

Re: REST interface ...is exceeding the 65535 bytes limit

OK, so if your single service currently has an endpoint like below...
http://myservices:8090/services/mydbservices
...and your HTTP request URIs are something like....
/select
/insert
/update
....you could try something like this. Create 22 web services each with an endpoint that includes the HTTP request URI. Like below...
http://myservices:8090/services/mydbservices/select
http://myservices:8090/services/mydbservices/insert
http://myservices:8090/services/mydbservices/update
Yes, this will mean more services, but it is arguably better to decouple your functionality. 22 different requests in a single service is a bit much to be honest. This way you can keep you endpoints consistent and won't have an issue with size.
Six Stars

Re: REST interface ...is exceeding the 65535 bytes limit

So I create 22 tRestRequest with: http://localhost:8088/REST/Operation1, http://localhost:8088/REST/Operation2 .....
http://localhost:8088/REST/Operation22?
Sixteen Stars

Re: REST interface ...is exceeding the 65535 bytes limit

Yes. While it appears to be extra work, it actually makes life a lot easier.