Apache Camel - Definition has no children on Aggregate - jboss

I am trying to implement an aggregate on Apache Camel (Version: 2.18.0) with the following route:
<route id="AggregateExtraRoute">
<from uri="direct:AggregateExtraRoute"/>
<aggregate strategyRef="CustomAggregationStrategy">
<correlationExpression>
<simple>header.AggregationHeader</simple>
</correlationExpression>
<log message="Route After Aggregate: ${body}" loggingLevel="INFO"/>
</aggregate>
</route>
I have also tried:
<header>AggregationHeader</header>
The error above appears when i am trying to deploy to JBoss.

Looks like you're missing completion criteria. You must provide at least one.

Related

Removing namespace from Soap Response Camel CXF

Below is my sample Soap Response for a service hosted in camel cxf
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:XpgIntegratedPaymentResponse xmlns:ns2="http://test:9090/wsx/services/WemXpgPaymentService"/>
</soap:Body>
</soap:Envelope>
Now I don't want to generate "ns2" namespace prefix in response.
Can anyone help?
if you want to drop the namespace of that element so that it is serialized as no-namespaced XpgIntegratedPaymentResponse, the common approach is to use CXF's transform feature.
see more info here:
http://cxf.apache.org/docs/transformationfeature.html#TransformationFeature-Changinginputandoutputelementnamesandnamespaces
in your particular case, you will need the following entry
<entry key="{http://test:9090/wsx/services/WemXpgPaymentService"}XpgIntegratedPaymentResponse"
value="XpgIntegratedPaymentResponse"/>
Are you using Camel 2.11+ ? You can control the namespaces mapping:
Taken from:
http://camel.apache.org/jaxb.html
When marshalling using JAXB or SOAP then the JAXB implementation will automatic assign namespace prefixes, such as ns2, ns3, ns4 etc. To control this mapping, Camel allows you to refer to a map which contains the desired mapping.
Notice this requires having JAXB-RI 2.1 or better (from SUN) on the classpath, as the mapping functionality is dependent on the implementation of JAXB, whether its supported.
For example in Spring XML we can define a Map with the mapping. In the mapping file below, we map SOAP to use soap as prefix. While our custom namespace "http://www.mycompany.com/foo/2" is not using any prefix.
<util:map id="myMap">
<entry key="http://www.w3.org/2003/05/soap-envelope" value="soap"/>
<!-- we dont want any prefix for our namespace -->
<entry key="http://www.mycompany.com/foo/2" value=""/>
</util:map>
To use this in JAXB or SOAP you refer to this map, using the namespacePrefixRef attribute as shown below. Then Camel will lookup in the Registry a java.util.Map with the id "myMap", which was what we defined above.
<marshal>
<soapjaxb version="1.2" contextPath="com.mycompany.foo" namespacePrefixRef="myMap"/>
</marshal>

WSO2 Data Service Server - Adding a Custom Data Source

Can anyone help me on how to configure/create a Custom Data Source and using WSO2 4.0.2
Here is a sample wso2-dss-connector for Mongo DB ( Link : https://github.com/wso2/wso2-dss-connectors/tree/master/mongodb) . How to deploy this with WSO2. While building this project,we can get a jar ,so how to integrate this with wso2 for creating a custom datasource
I am new to wso2,i didn't get a clear picture from the official doc
Thanks in advance
If you want a connector for mongo db you can use the above link you mentioned and build this jar and you can put this in the DSSHOME/repository/component/dropins folder and restart the server. Once you have added the jar to dropins you can use the following database descriptor file (dbs) to test this
In this example we create a data source call "mongo_ds" and our query will be called mongo_find, which will retreive set of Documents elements.
<config id="mongo_ds">
<property name="custom_query_datasource_class">org.wso2.dss.connectors.mongodb.MongoDBDataSource</property>
<property name="custom_datasource_props">
<property name="servers">localhost</property>
<property name="database">mydb</property>
</property>
</config>
<query id="mongo_find" useConfig="mongo_ds">
<expression>things.find()</expression>
<result element="Documents" rowName="Document">
<element column="document" name="Data" xsdType="string"/>
</result>
</query>
If you want to write custom data sources for other data sources please refer the following guide.

Camel XSD validation not working: Camel 2.12.1 / JBoss 5.1.0.GA / JDK 1.6

Camel validation is not working when i deploy to jboss, work perfectly with mvn jetty:run. See error below:
Stacktrace
---------------------------------------------------------------------------------------------------------------------------------------
java.lang.IllegalArgumentException: Source parameter of type 'org.apache.camel.StringSource' is not compatible with result parameter of type 'javax.xml.transform.stream.StreamResult'.
at org.apache.xerces.jaxp.validation.StreamValidatorHelper.validate(Unknown Source)
at org.apache.xerces.jaxp.validation.ValidatorImpl.validate(Unknown Source)
at org.apache.camel.processor.validation.ValidatingProcessor.doProcess(ValidatingProcessor.java:152)
at org.apache.camel.processor.validation.ValidatingProcessor.process(ValidatingProcessor.java:87)
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:105)
at org.apache.camel.processor.validation.ValidatingProcessor.process(ValidatingProcessor.java:82)
at org.apache.camel.impl.ProcessorEndpoint.onExchange(ProcessorEndpoint.java:103)
at org.apache.camel.impl.ProcessorEndpoint$1.process(ProcessorEndpoint.java:71)
....
Camel Route configuration below:
<camel:route id="process-xml-file" startupOrder="200">
<from uri="direct:process-xml-file"/>
<log message="processing file ${file:name}"/>
<choice>
<when>
<xpath>/invoices/#region='regionA'</xpath>
<split streaming="true" parallelProcessing="true">
<tokenize token="invoice" inheritNamespaceTagName="dataexport" xml="true"/>
<doTry>
<to uri="validator:xml/invoice.xsd"/>
<to uri="processInv"/>
<doCatch>
<exception>org.apache.camel.ValidationException</exception>
<exception>java.sql.SQLException</exception>
<setBody>
<simple>${exception.message}\n${body}</simple>
</setBody>
<to uri="direct:error-notification"/>
</doCatch>
</doTry>
</split>
</when>
<otherwise>
<log message="ignoring file ${file:name}, not 'invoice'"/>
</otherwise>
</choice>
</camel:route>
I just checked the code of
org.apache.xerces.jaxp.validation.StreamValidatorHelper and found out we can solve this issue by not setting the result type when call the validate method.
So I fill a JIRA in camel to track this issue, you can fix this issue by porting the patch or using the latest snapshot which includes the patch

Camel Restlet maxThreads Component Option

I have a problem. The apache camel documentation states that for the camel-restlet component (starting from 2.10 version) is possible to define the max number of threads that will service requests (http://camel.apache.org/restlet.html).
How can i specify this parameter?
This is the route that I made
from(
"restlet:http://localhost:" + config.getEmergencyRESTPort()
+ "?restletMethods=post,get&restletUriPatterns=#emergencyUriTemplates&maxThreads=64").process(
new EmergencyServerProcessor(config, emergencyService));
I used the maxThreads parameter in the url but it doesn't work.
What is the error?
maxThreads is not a URI option but rather it is a component option.
You can configure your restlet component by creating a bean like this:
<bean id="restlet" class="org.apache.camel.component.restlet.RestletComponent">
<property name="maxThreads" value="50"/>
</bean>

Order of execution of RequestHandlers configured in Apache CXF and JAX-RS

I am in process of implementing a REST API server using Apache CXF JAX-RS v(2.30). I am using spring as container. I am thinking of making use of org.apache.cxf.jaxrs.ext.RequestHandler to implement few features like license check, authentication, authorization (All of which has custom code). My idea is to segregate this code in individual implementation classes (implementing RequestHandler) and configure it for a base REST url something like /rest/*. Being new to Apache CXF and JAX-RS, I want to understand following things.
Is this approach the right way to implement the features I want to?
If yes, then is the order in which the RequestHandlers are declared is the order of their invocation?
For example if in my definition I declare:
<beans>
<jaxrs:server id="abcRestService" address="/rest">
<jaxrs:serviceBeans>
<bean class="com.abc.api.rest.service.FooService" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref bean="licenseFilter" />
<ref bean="authorizationFilter" />
</jaxrs:providers>
</jaxrs:server>
<bean id="licenseFilter" class="com.abc.api.rest.providers.LicenseValidator">
<!-- License check bean properties -->
</bean>
<bean id="authorizationFilter" class="com.abc.api.rest.providers.AuthorizationFilter">
<!-- authorization bean properties -->
</bean>
</beans>
then will the licenseFilter always get invoked before authorizationFilter?
I did not find a mention of invocation ordering of RequestHandlers as well as ResponseHandlers.
Thanks in advance.
Figured this out.
It gets invoked in the order of declaration of beans in <jaxrs:providers>. Thus in case mentioned in question, licenseFilter will get invoked before authorizationFilter.