Five Stars

tRESTResponse: Exception Rest response already sent.

So I am working on reconciliation service for OpenRefine. OpenRefine send query with the following payload as Form.
Below an example of query sent by OpenRefine

My Talend job:
1. parse the payload into different record for q0, q1 ....
2. do some computing for each record and build individual JSON answer using a tMap (screenshot 02)
3. wrap all results in a single payload and pass it to tRESTResponse (screenshot 03)

As the first query got parsed the job failed with the following Exception:
Exception in component tRESTResponse_2
java.lang.RuntimeException: Rest response already sent.
at openrefinereconciliation.restservice2_0_1.RESTService2.tRESTRequest_1_LoopProcess(
at openrefinereconciliation.restservice2_0_1.RESTService2$RestServiceProviderImpl4TalendJob.processRequest(
at openrefinereconciliation.restservice2_0_1.RESTService2$RestServiceProviderImpl4TalendJob.queries(
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(
at sun.reflect.DelegatingMethodAccessorImpl.invoke(
at java.lang.reflect.Method.invoke(
at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(
at org.apache.cxf.service.invoker.AbstractInvoker.invoke(
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(
at org.apache.cxf.jaxrs.JAXRSInvoker.invoke(
at org.apache.cxf.interceptor.ServiceInvokerInterceptor$
at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(
at org.apache.cxf.transport.ChainInitiationObserver.onMessage(
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.serviceRequest(
at org.apache.cxf.transport.http_jetty.JettyHTTPDestination.doService(
at org.apache.cxf.transport.http_jetty.JettyHTTPHandler.handle(
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(
at org.eclipse.jetty.server.handler.ContextHandler.doScope(
at org.eclipse.jetty.server.handler.ScopedHandler.handle(
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(
at org.eclipse.jetty.server.Server.handle(
at org.eclipse.jetty.server.AbstractHttpConnection.handleRequest(
at org.eclipse.jetty.server.AbstractHttpConnection.content(
at org.eclipse.jetty.server.AbstractHttpConnection$RequestHandler.content(
at org.eclipse.jetty.http.HttpParser.parseNext(
at org.eclipse.jetty.http.HttpParser.parseAvailable(
at org.eclipse.jetty.server.AsyncHttpConnection.handle(
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(
at org.eclipse.jetty.util.thread.QueuedThreadPool$

and I am clueless on what I am doing wrong? Is my document not formed properly at the tXMLMap level? Did I missed some configuration in the tRESTResponse (ie should I configure specific response header?)
Thanks in advance for your help.

Re: tRESTResponse: Exception Rest response already sent.

The error message suggests that an attempt is made to repeatedly write a response into the back channel representing a current client request.
Unfortunately it is not possible to do it at the Studio level, there's an enhancement request to support streaming of the response data into a single tRESTRequest response, but it is not supported yet.
Can you open an enhancement request on your own and I will link to it from the internal JIRA issue ?

Cheers, Sergey
Five Stars

Re: tRESTResponse: Exception Rest response already sent.

Thanks Sergey,
I've created the following issue:
I was not able to track back the issue to request to support streaming of the response data into a single tRESTRequest response. May you provide a link to it?

Re: tRESTResponse: Exception Rest response already sent.

Thanks, I've linked to it from TESB-12039
Cheers, Sergey
One Star

Re: tRESTResponse: Exception Rest response already sent.

this may be helpful: setting the XMLMap's output option "All in one" to "true" shovels all rows to one document before passing the row out... this helped me in a similar problem