OnException does not work for Camel CXF used as Producer - apache-camel

Camel / CXF versions used:
<camel-version>2.18.1</camel-version>
<cxf-version>3.1.7</cxf-version>
Using Spring DSL to define routes. Sample code:
<cxf:cxfEndpoint address="{{ws.url}}" id="wsCallCxfBean"
serviceClass="com.some.package.GeneratedClassEndpoint">
<cxf:properties>
<entry key="username" value="${ws.username}" />
<entry key="password" value="${ws.password}" />
</cxf:properties>
<cxf:outInterceptors>
<ref bean="logOutbound" />
</cxf:outInterceptors>
</cxf:cxfEndpoint>
Camel Context:
<camel:errorHandler id="deadLetterErrorHandler" type="DeadLetterChannel" deadLetterUri="log:dead" />
<camelContext id="camelCxtId" trace="{{trace}}" handleFault="true" errorHandlerRef="deadLetterErrorHandler"
xmlns="http://camel.apache.org/schema/spring">
<onException id="onCContextException_Common">
<exception>java.lang.Exception</exception>
<redeliveryPolicy maximumRedeliveries="2" />
<!-- mark this as handled -->
<handled>
<constant>true</constant>
</handled>
<to id="onCContextExceptionHandling_Common" pattern="OutOnly" uri="vm:onRouteErrorOutMsgCaught" />
</onException>
.....
Route:
<route id="wsCall_RouteID" handleFault="true">
<description>Call the web service</description>
<from id="vmFrom_id" uri="vm:fromPOJOVM" />
<to id="wsCall_id" uri="cxf:bean:wsCallCxfBean" />
<onException id="onRouteException_WS">
<exception>java.lang.Exception</exception>
<redeliveryPolicy maximumRedeliveries="2" />
<handled>
<constant>true</constant>
</handled>
<to id="onRouteExceptionHandling_WS" pattern="OutOnly"
uri="vm:onRouteErrorOutMsgCaught" />
</onException>
</route>
Issue that I am facing:
Whenever exception is thrown in CXF, it is not handled by the Camel onException.
I can see the exception in the log. Sample exception from log (truncated):
WARN PhaseInterceptorChain:449 - Interceptor for {http://someaddress}WSEndpointService#
{http://someaddress}WSOperation has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: Connection timed out: connect
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:266)
...
Caused by: javax.xml.bind.MarshalException
- with linked exception:
[java.net.ConnectException: Connection timed out: connect]
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:328)
... 20 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
...
at com.sun.xml.bind.v2.runtime.MarshallerImpl.write(MarshallerImpl.java:323)
I have tried adding handleFault="true" in my camel context and Route - but that did not help.
How can I catch the exception thrown in CXF (for eg: the timeout, unknown host etc) in my camel route?
Thanks

Related

Unable to start blueprint container for bundle abc, org.osgi.service.blueprint.container.ComponentDefinitionException: java.lang.NullPointerException

I'm trying to deploy my application in fuse server but it gives me an error "Unable to start blueprint container for bundle abc,
org.osgi.service.blueprint.container.ComponentDefinitionException: java.lang.NullPointerException". I have camel-core and camel-blueprint jars but still it gives me the error. Not sure what it refers. Please can anyone help on this?
<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
xmlns:ext="http://aries.apache.org/blueprint/xmlns/blueprint-ext/v1.0.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xsi:schemaLocation="
http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<camelContext xmlns="http://camel.apache.org/schema/blueprint"
id="abc" threadNamePattern="#camelId#-#longName#-#counter#">
<propertyPlaceholder id="properties" location="blueprint:sql.prop.id" />
<route id="logMessageRoute" startupOrder="5">
<from uri="direct:logMessage" />
<camel:setProperty propertyName="originalMap">
<camel:simple>${body}</camel:simple>
</camel:setProperty>
<to uri="direct:insertMessage" />
<log message="INSERT COMPLETED" loggingLevel="INFO" />
<onException>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<camel:log message="EXCEPTION IN direct:Message ROUTE " />
</onException>
</route>
<camel:route id="insertLogRoute" startupOrder="4">
<camel:from uri="direct:insertMessage" />
<!-- <transacted ref="PROPAGATION_REQUIRED" /> -->
<recipientList delimiter="~" id="insertLogMessageRecipientId">
<simple>sql:{{insertQuery}}</simple>
</recipientList>
<onException>
<exception>java.lang.Exception</exception>
<handled>
<constant>true</constant>
</handled>
<camel:log message="EXCEPTION IN direct:insertLogMessage ROUTE "
loggingLevel="INFO" />
<!-- <camel:to uri="direct:generateCSV" /> -->
</onException>
</camel:route>
</camelContext>
</blueprint>```
Stack trace:
```
2019-11-17 19:22:11,239 | ERROR | pool-15-thread-1 | BlueprintContainerImpl | 23 - org.apache.aries.blueprint.core - 1.4.5 | Unable to start blueprint container for bundle abc,
org.osgi.service.blueprint.container.ComponentDefinitionException: java.lang.NullPointerException
at org.apache.aries.blueprint.di.ValueRecipe.internalCreate(ValueRecipe.java:56)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:106)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BeanRecipe.setProperty(BeanRecipe.java:955)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:929)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BeanRecipe.setProperties(BeanRecipe.java:910)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate2(BeanRecipe.java:844)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BeanRecipe.internalCreate(BeanRecipe.java:811)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.di.AbstractRecipe$1.call(AbstractRecipe.java:79)[23:org.apache.aries.blueprint.core:1.4.5]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_80]
at org.apache.aries.blueprint.di.AbstractRecipe.create(AbstractRecipe.java:88)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintRepository.createInstances(BlueprintRepository.java:247)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintRepository.createAll(BlueprintRepository.java:183)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.instantiateEagerComponents(BlueprintContainerImpl.java:688)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.doRun(BlueprintContainerImpl.java:383)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintContainerImpl.run(BlueprintContainerImpl.java:270)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:294)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintExtender.createContainer(BlueprintExtender.java:263)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.container.BlueprintExtender.modifiedBundle(BlueprintExtender.java:253)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:500)[17:org.apache.aries.util:1.1.0]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.customizerModified(BundleHookBundleTracker.java:433)[17:org.apache.aries.util:1.1.0]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$AbstractTracked.track(BundleHookBundleTracker.java:725)[17:org.apache.aries.util:1.1.0]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$Tracked.bundleChanged(BundleHookBundleTracker.java:463)[17:org.apache.aries.util:1.1.0]
at org.apache.aries.util.tracker.hook.BundleHookBundleTracker$BundleEventHook.event(BundleHookBundleTracker.java:422)[17:org.apache.aries.util:1.1.0]
at org.apache.felix.framework.util.SecureAction.invokeBundleEventHook(SecureAction.java:1127)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.createWhitelistFromHooks(EventDispatcher.java:696)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.util.EventDispatcher.fireBundleEvent(EventDispatcher.java:484)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.Felix.fireBundleEvent(Felix.java:4429)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.Felix.startBundle(Felix.java:2100)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:976)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.felix.framework.BundleImpl.start(BundleImpl.java:963)[org.apache.felix.framework-4.4.1.jar:]
at org.apache.karaf.features.internal.FeaturesServiceImpl.doInstallFeatures(FeaturesServiceImpl.java:546)[10:org.apache.karaf.features.core:2.4.0.redhat-621166]
at org.apache.karaf.features.internal.FeaturesServiceImpl$1.call(FeaturesServiceImpl.java:432)[10:org.apache.karaf.features.core:2.4.0.redhat-621166]
at java.util.concurrent.FutureTask.run(FutureTask.java:262)[:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)[:1.7.0_80]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)[:1.7.0_80]
at java.lang.Thread.run(Thread.java:745)[:1.7.0_80]
Caused by: java.lang.NullPointerException
at org.jasypt.encryption.pbe.config.SimplePBEConfig.getPasswordCharArray(SimplePBEConfig.java:434)[28:org.apache.servicemix.bundles.jasypt:1.9.3.redhat_3]
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.resolveConfigurationPassword(StandardPBEByteEncryptor.java:804)[28:org.apache.servicemix.bundles.jasypt:1.9.3.redhat_3]
at org.jasypt.encryption.pbe.StandardPBEByteEncryptor.initialize(StandardPBEByteEncryptor.java:617)[28:org.apache.servicemix.bundles.jasypt:1.9.3.redhat_3]
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.initialize(StandardPBEStringEncryptor.java:553)[28:org.apache.servicemix.bundles.jasypt:1.9.3.redhat_3]
at org.jasypt.encryption.pbe.StandardPBEStringEncryptor.decrypt(StandardPBEStringEncryptor.java:705)[28:org.apache.servicemix.bundles.jasypt:1.9.3.redhat_3]
at org.apache.karaf.jaas.jasypt.handler.EncryptablePropertyPlaceholder.getProperty(EncryptablePropertyPlaceholder.java:38)[29:org.apache.karaf.jaas.jasypt:2.4.0.redhat-621166]
at org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder.retrieveValue(AbstractPropertyPlaceholder.java:430)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder.processString(AbstractPropertyPlaceholder.java:437)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder$LateBindingValueMetadata.getStringValue(AbstractPropertyPlaceholder.java:471)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.ext.AbstractPropertyPlaceholder$LateBindingValueMetadata.getStringValue(AbstractPropertyPlaceholder.java:469)[23:org.apache.aries.blueprint.core:1.4.5]
at org.apache.aries.blueprint.di.ValueRecipe.internalCreate(ValueRecipe.java:54)[23:org.apache.aries.blueprint.core:1.4.5]
... 35 more ```

Camel rest JSON deserialize with START_ARRAY

I'm try to convert a application/json from rest service to a list of POJO.
But I can't
My input is a list of Event in camel:put I cannot refer a list.
<dataFormats>
<json id="eventJsonList" prettyPrint="true" library="Jackson" useList="true"
unmarshalTypeName="example.model.Event" />
</dataFormats>
<camel:rest path="events" consumes="application/json" produces="application/json">
<camel:put
uri="/save">
<to uri="direct:save-events" />
</camel:put>
</camel:rest>
using Camel 2.22
I think you need to use camel:unmarshall to tell the route to use your data format.
<camel:rest path="events" consumes="application/json" produces="application/json">
<camel:put uri="/save">
<camel:route>
<camel:unmarshal ref="eventJsonList" />
<camel:to uri="direct:save-events" />
</camel:route>
</camel:put>
</camel:rest>
Property bindingMode="off" must be disabled and the body converted to String:
<dataFormats>
<json id="eventJsonList" prettyPrint="true" library="Jackson" useList="true"
unmarshalTypeName="example.model.Event" />
</dataFormats>
<camel:rest path="events" bindingMode="off" consumes="application/json" produces="application/json">
<camel:put
uri="/save">
<to uri="direct:save-events" />
</camel:put>
</camel:rest>
<camel:route id="save-events">
<from uri="direct:save-events" />
<camel:convertBodyTo type="java.lang.String"/>
<camel:unmarshal ref="eventJsonList"/>
<to uri="mock:result"/>
</camel:route>

Setting timeout for Apache Camel CXF consumer component

I want to set timeout for Apache Camel CXF consumer component.
My code looks something like:
<route>
<from uri="direct:NDS/getUserInformation" />
<to uri="freemarker:file:/application/DT/adapter/NDSLookupService.ftl" />
<bean ref="ndsServiceLogger" method="logNDSRequest" />
<setHeader headerName="SOAPAction">
<simple>getLookUpServiceDetails</simple>
</setHeader>
<bean ref="ndsServiceLogger" method="logNDSServiceStartTime" />
<toD uri="${headers.nds_url}?wsdlURL=/application/DT/adapter/NDSLookupService.wsdl&serviceName={http://webservices.lookup.sdp.bharti.ibm.com}NDSLookupServiceService&portName={http://webservices.lookup.sdp.bharti.ibm.com}NDSLookupService&dataFormat=MESSAGE" />
<bean ref="ndsServiceLogger" method="logNDSServiceEndTime" />
<bean ref="ndsServiceLogger" method="logNDSResponse" />
<convertBodyTo type="java.lang.String" />
</route>
How about to try properties http.connection.timeout and
http.receive.timeout?
UPD: it does not work... I can just give you ideas where to go...
I use CXF bus for endpoints and Asynchronous transport (doc at Asynchronous Client HTTP Transport .
It is possible to set timeouts there like below.
<cxf-core:bus bus="bus-common-outbound">
<cxf-core:properties>
<spring:entry key="use.async.http.conduit" value="true" />
<spring:entry key="org.apache.cxf.transport.http.async.usePolicy" value="ALWAYS" />
<spring:entry key="org.apache.cxf.transport.http.async.SO_TIMEOUT" value="45000" />
</cxf-core:properties>
</cxf-core:bus>
and endpoint has property "bus" pointed to that by its "bus" property like: bus=bus-common-outbound
maybe you can use something like that or dig deeper for default synchronous transport...

Exchange edifact message with smooks - error during response

I need to write osgi bundle to simple unmarshal edifact message (invoice), and persist invoice in database. I receive an exception during response
My environment:
- ServiceMix 5.0.0
I have following camel route
<route>
<from uri="mina2:tcp://localhost:9999?textline=true&encoding=utf-8" />
<to uri="smooks://smooks-config.xml" />
</route>
<route>
<from uri="direct:invoice" />
<process ref="invoiceProcessor" />
</route>
where smooks-config.xml is:
<?xml version="1.0"?>
<smooks-resource-list
xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:csv="http://www.milyn.org/xsd/smooks/csv-1.2.xsd"
xmlns:edi="http://www.milyn.org/xsd/smooks/edi-1.2.xsd"
xmlns:unedifact="http://www.milyn.org/xsd/smooks/unedifact-1.4.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd"
xmlns:camel="http://www.milyn.org/xsd/smooks/camel-1.4.xsd"
>
<unedifact:reader mappingModel="urn:org.milyn.edi.unedifact:d96a-mapping:1.4" ignoreNewLines="true" />
<import file="/org/milyn/edi/unedifact/d96a/message-bindingconfig.xml" />
<camel:route beanId="INVOIC">
<camel:to endpoint="direct:invoice"/>
</camel:route>
<core:exports>
<core:result type="org.milyn.payload.StringResult"/>
</core:exports>
</smooks-resource-list>
As you can see I am using standard d96a binding and mapping.
When I call netcat to send sample edifact message, all processing is going to be fine except response. During response I receive:
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
org.milyn.SmooksException: Failed to filter source.
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:97)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:64)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.Smooks._filter(Smooks.java:526)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.Smooks.filterSource(Smooks.java:477)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.smooks.camel.processor.SmooksProcessor.process(SmooksProcessor.java:107)[221:org.milyn.smooks.osgi:1.5.2]
at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.util.AsyncProcessorConverterHelper$ProcessorToAsyncProcessorBridge.process(AsyncProcessorConverterHelper.java:61)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:110)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.management.InstrumentationProcessor.process(InstrumentationProcessor.java:72)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:398)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:118)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.processor.Pipeline.process(Pipeline.java:80)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87)[98:org.apache.camel.camel-core:2.12.3]
at org.apache.camel.component.mina2.Mina2Consumer$ReceiveHandler.messageReceived(Mina2Consumer.java:339)[186:org.apache.camel.camel-mina2:2.12.3]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:690)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:417)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1200(DefaultIoFilterChain.java:47)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:765)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:74)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.core.session.IoEvent.run(IoEvent.java:63)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTask(OrderedThreadPoolExecutor.java:769)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.runTasks(OrderedThreadPoolExecutor.java:761)[26:org.apache.mina.core:2.0.7]
at org.apache.mina.filter.executor.OrderedThreadPoolExecutor$Worker.run(OrderedThreadPoolExecutor.java:703)[26:org.apache.mina.core:2.0.7]
at java.lang.Thread.run(Thread.java:744)[:1.7.0_51]
Caused by: java.util.EmptyStackException
at java.util.Stack.peek(Stack.java:102)[:1.7.0_51]
at java.util.Stack.pop(Stack.java:84)[:1.7.0_51]
at org.milyn.namespace.NamespaceDeclarationStack.popNamespaces(NamespaceDeclarationStack.java:132)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.edisax.unedifact.UNEdifactInterchangeParser.parse(UNEdifactInterchangeParser.java:125)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.smooks.edi.unedifact.UNEdifactReader.parse(UNEdifactReader.java:75)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.delivery.sax.SAXParser.parse(SAXParser.java:76)[221:org.milyn.smooks.osgi:1.5.2]
at org.milyn.delivery.sax.SmooksSAXFilter.doFilter(SmooksSAXFilter.java:86)[221:org.milyn.smooks.osgi:1.5.2]
... 27 more
Im new with smooks and i dont know the source of the problem, but you can change your camel route for this:
<route>
<from uri="mina2:tcp://localhost:9999?textline=true&encoding=utf-8" />
<to uri="smooks://smooks-config.xml" />
<to uri="direct:invoice" />
</route>
<route>
<from uri="direct:invoice" />
<process ref="invoiceProcessor" />
</route>
And change your smooks-config.xml
<?xml version="1.0"?>
<smooks-resource-list
xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
xmlns:unedifact="http://www.milyn.org/xsd/smooks/unedifact-1.4.xsd"
xmlns:core="http://www.milyn.org/xsd/smooks/smooks-core-1.4.xsd"
>
<unedifact:reader mappingModel="urn:org.milyn.edi.unedifact:d96a-mapping:1.4" ignoreNewLines="true" />
<core:exports>
<core:result type="org.milyn.payload.StringResult"/>
</core:exports>
</smooks-resource-list>
This is the same that they do in their example : https://github.com/smooks/smooks/tree/67b38b41a17510758ea9f00b7d6fad189916b2ed/smooks-examples/camel/camel-unedifact-to-xml

How to scale Apache Camel route?

I have the following routes:
<camelContext xmlns="http://camel.apache.org/schema/spring">
<threadPoolProfile id="defaultProfile"
defaultProfile="true" poolSize="100" maxPoolSize="200" />
<route>
<from uri="amq:example.MyQueue" />
<setHeader headerName="myRoutingSlipHeader">
<constant>amq:one#amq:two#amq:three#amq:four</constant>
</setHeader>
<log message="Makan" />
<setExchangePattern pattern="InOut" />
<routingSlip uriDelimiter="#">
<header>myRoutingSlipHeader</header>
</routingSlip>
<setExchangePattern pattern="InOnly" />
<log message="End: ${body}" />
</route>
<route>
<from uri="amq:one" />
<to uri="bean:helloBean?method=stepOne" />
</route>
<route>
<from uri="amq:two" />
<to uri="bean:helloBean?method=stepTwo" />
</route>
<route>
<from uri="amq:three" />
<to uri="bean:helloBean?method=stepThree" />
</route>
<route>
<from uri="amq:four" />
<to uri="bean:helloBean?method=stepFour" />
</route>
</camelContext>
<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent"
p:brokerURL="tcp://localhost:61616" p:transacted="true"
p:cacheLevelName="CACHE_CONSUMER" p:concurrentConsumers="20"
p:maxConcurrentConsumers="500" p:idleConsumerLimit="10"
/>
Given that example.MyQueue is preloaded with 1000 messages, and each hello bean's step* methods takes 250ms, when I do camel:run, the performance is still bad. It prints "End: ..." each 1 secs in sequence not parallel. What would be the problem here?
In the following much simple case, I see a strange behavior. When there is no JMS producer putting messages into the queue, the printings happen in sequence. But when there is, the printings happen in parallel. What's the explanation?
<threadPoolProfile id="defaultProfile"
defaultProfile="true" poolSize="100" maxPoolSize="200" />
<route>
<from uri="amq:example.MyQueue" />
<delay>
<constant>1000</constant>
</delay>
<log message="End: ${body}" />
</route>
<bean id="amq" class="org.apache.activemq.camel.component.ActiveMQComponent"
p:brokerURL="tcp://localhost:61616" p:transacted="true"
p:cacheLevelName="CACHE_CONSUMER" p:concurrentConsumers="20"
p:maxConcurrentConsumers="500" p:idleConsumerLimit="10"
/>
Try replacing
<from uri="amq:example.MyQueue" />
with
<from uri="amq:example.MyQueue?concurrentConsumers=200&maxConcurrentConsumers=500" />
The routing slip runs in sequence, and yo do request/reply over JMS (eg the MEP is InOut) so processing one message would take
call amq:one = 250 millis (request/reply)
call amq:two = 250 millis (request/reply)
call amq:three = 250 millis (request/reply)
call amq:four = 250 millis (request/reply)
A total of 1 sec per message.
The AMQ route in < from > could process messages in parallel though. But each message would still take 1 second to process.
I guess routingSlip pattern is synchronized. you need something asynchronized component to handle this. Please check this:http://camel.apache.org/async.html
Just one question, why you need set the ExchangePattern?

Resources