Touko
Touko

Reputation: 11779

Apache Camel throttling with a SOAP endpoint -> TransformerException

We have an Apache Camel application providing SOAP service. The "initial route" starts from a Apache CFX -provided endpoint.

We need a simple mechanism to prevent the messages from being handled "too fast" (and don't have massive scalability needs).

Thus we ended up trying Throttler. Now, the problem is that after adding throttle to our route, something goes wrong.

The initial route, somewhat cleaned:

from("cxf:bean:sapEndpoint").routeId(SOAP_ENDPOINT)
    .throttle(1)
    .onException(Exception.class)
        .to("direct:emailFaultNotification").handled(false)
    .end()
    .transacted(joinJpaTx)
    .to(xsltRemoveEmptyElements) // Cleaning done with XSLT endpoint
    .to("direct:inboundWorkOrderXml"); // Forward to actual processing

// direct:inboundWorkOrderXml contains various validation, persistance & response

Error in our log:

2013-02-18 16:50:16,257 [tp1636587648-50] ERROR DefaultErrorHandler            - Failed delivery for exchangeId: ID-...-4. Exhausted after delivery attempt: 1 caught: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Content is not allowed in prolog.
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: com.sun.org.apache.xml.internal.utils.WrappedRuntimeException: Content is not allowed in prolog.
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:735)[:1.6.0_37]
    at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:336)[:1.6.0_37]
    at org.apache.camel.builder.xml.XsltBuilder.process(XsltBuilder.java:98)[camel-core-2.7.0.jar:2.7.0]
    at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:102)[camel-core-2.7.0.jar:2.7.0]
    at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:72)[camel-core-2.7.0.jar:2.7.0]
    ...

I suppose that throttler doesn't work straight the way I supposed.

It seems that with throttling enabled, the XSLT endpoint receives empty or invalid XML? Without throttle definition everything works fine. With short try, the message body still seems to contain XML string?

Some ideas?

Upvotes: 0

Views: 1208

Answers (1)

Touko
Touko

Reputation: 11779

Finally the solution was more simple than I thought. Instead of using throttle in the route starting from "cxf:bean:sapEndpoint", I added throttle to route handling "direct:inboundWorkOrderXml".

Don't know the exact reason, could be somehow related to that some parts of throttle functionality might vary related on the from-endpoint of the route. (So problem with cxf-endpoint not encountered with direct-endpoint)

Upvotes: 0

Related Questions