InvalidPayloadException: No body available of type ... concurrency issue?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

InvalidPayloadException: No body available of type ... concurrency issue?

Clemens Wyss DEV
Camel: 2.15.3 (I know «outdated»)

When I «call» one of our routes "concurrently" I am getting:

java.lang.reflect.UndeclaredThrowableException: null
        at ch.mysign.prj.interfaces.campaign.$Proxy54.getCodeMessage(Unknown Source)
        at ch.mysign.prj.interfaces.campaign.CampaignProxy.getCode(CampaignProxy.java:159)
.

Caused by: org.apache.camel.InvalidPayloadException: No body available of type: ch.mysign.prj.interfaces.campaign.CodeRequestReply but has value:
{"user":"aUser","password":"aPassword","ordernr":"15330669"}
 of type: java.lang.String on: Message: {"user":"aUser","password":"aPassword","ordernr":"15330669"}. Caused by: No type converter available to convert from type: java.lang.String to the required type: ch.mysign.prj.interfaces.campaign.CodeRequestReply with value {"user":"aUser","password":"aPassword","ordernr":"15330669"}. Exchange[Message: {"user":"aUser","password":"aPassword","ordernr":"15330669"}]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: java.lang.String to the required type: ch.mysign.prj.interfaces.campaign.CodeRequestReply with value {"user":"aUser","password":"aPassword","ordernr":"15330669"}]
        at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:101)
        at org.apache.camel.component.bean.AbstractCamelInvocationHandler.getBody(AbstractCamelInvocationHandler.java:66)
        at org.apache.camel.component.bean.AbstractCamelInvocationHandler.afterInvoke(AbstractCamelInvocationHandler.java:175)
        at org.apache.camel.component.bean.AbstractCamelInvocationHandler$1.call(AbstractCamelInvocationHandler.java:112)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invokeWithBody(AbstractCamelInvocationHandler.java:128)
        at org.apache.camel.component.bean.CamelInvocationHandler.doInvokeProxy(CamelInvocationHandler.java:45)
        at org.apache.camel.component.bean.AbstractCamelInvocationHandler.invoke(AbstractCamelInvocationHandler.java:82)
        ... 53 common frames omitted
Caused by: org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert from type: java.lang.String to the required type: ch.mysign.prj.interfaces.campaign.CodeRequestReply with value {"user":"aUser","password":"aPassword","ordernr":"15330669"}
        at org.apache.camel.impl.converter.BaseTypeConverterRegistry.mandatoryConvertTo(BaseTypeConverterRegistry.java:177)
        at org.apache.camel.impl.MessageSupport.getMandatoryBody(MessageSupport.java:99)
        ... 60 common frames omitted

ch.mysign.prj.interfaces.campaign.CodeRequestReply Indicates that camel is trying to unmarshal the json response/reply. Interestingly the value mentioned :
{"user":"aUser","password":"aPassword","ordernr":"15330669"}
is the request-Payload.

The route configuration is as follows :
public class CampaignRouteBuilder extends RouteBuilder
...
GsonDataFormat gsonRequest = new GsonDataFormat();
GsonDataFormat gsonResponse = new GsonDataFormat();
gsonResponse.setUnmarshalType( CodeRequestReply.class );
               
String codeEndpoint = this.createGetCodeEndpoint();
from( CampaignConstants.DIRECT_GET_CODE )
        .handleFault()
        .routeId( CampaignConstants.GET_CODE_ROUTE )
        .process( ex -> {
                        BeanInvocation b = (BeanInvocation) ex.getIn().getBody();
                        if ( b.getArgs() != null && b.getArgs().length > 0 )
                        {
                                CodeRequestData data = (CodeRequestData) b.getArgs()[0];
                                ex.getIn().setBody( data );
                        }
                        else
                        {
                                throw new CampaignException( "Couldn't find the right argument for getting a code" );
                        }

        } )
        .marshal( gsonRequest )
        .convertBodyTo( String.class, "utf-8" )
        .setHeader(Exchange.CONTENT_TYPE, simple( ERPUtil.HTTP_HEADER_CONTENT_TYPE ))
        .to( codeEndpoint )
        .unmarshal( gsonResponse )
.end();


Calling the route only every 3secs causes no errors. Does camel confuse/mix request and response (in the exchange) under load or is it rather a server-error/problem (possibly due to keep-alive?)?