Category Archives: apache-camel

type conversion in apache camel

I am pretty new to Apache Camel and currently I am making a test project. Currently I am trying to write some previously processed objects from custom class into a file using the file component (i dont know a better option).

from("direct:processedDecimals")
            .to("file:data/output")

but i have the following problem

   Caused by: org.apache.camel.InvalidPayloadException: No body available of type: java.io.InputStream but has value: Add{x=5.63, y=78.016} of type: org.example.math.Add on: Message[ID-NTB828-1537281187742-0-10]. Caused by: No type converter available to convert from type: org.example.math.Add to the required type: java.io.InputStream with value Add{x=5.63, y=78.016}. Exchange[ID-NTB828-1537281187742-0-9]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: org.example.math.Add to the required type: java.io.InputStream with value Add{x=5.63, y=78.016}]

I saw on the internet that some people suggests writing custom TypeConverter and then register it in a file in the WEB-INF folder. But I am using SpringBoot and its internal Tomcat and I dont have this directory.

Add endpoint dynamically to camel Context using Java DSL

I do like to create/add client endpoint ( Endpoint.class ) to camel context using java DSL ( not to define it in blueprint.xml).

In this time I have this endpoint specified in blueprint.xml:

<!-- SOAP client settings -->
<camelcxf:cxfEndpoint id="primeSmsMT2"
                      address="{{prime2.url}}"
                      wsdlURL="META-INF/wsdl/primeSmsMT.wsdl">
    <camelcxf:inInterceptors>
        <bean class="org.apache.cxf.transport.common.gzip.GZIPInInterceptor" />
    </camelcxf:inInterceptors>
</camelcxf:cxfEndpoint>

BUT I like to create it dynamically. I search in this way and I didn't find something.

An example is this but is not working:

CxfEndpoint primeSmsMTEndpoint = getContext().getEndpoint("cxf: 
{prime2.url}", CxfEndpoint.class);
primeSmsMTEndpoint.setWsdlURL("META-INF/wsdl/primeSmsMT.wsdl");

Could you please help me? Thank you.

Splitter group attribute inject variable parameter

can you inject a value from the config params file in to the splitter group attribute? if so, what is the proper way of doing it? thanks!

I've tried,

<split streaming="true" >
<tokenize token="\n" group="{{noOfLines}}" />
<log message="Split Group Body: ${body}"/>
    <to uri="bean:extractHeader" />
    <to id="acceptedFileType" ref="pConsumer" /> 
</split>

<split streaming="true" >
<tokenize token="\n" group={{noOfLines}} />
<log message="Split Group Body: ${body}"/>
    <to uri="bean:extractHeader" />
    <to id="acceptedFileType" ref="pConsumer" /> 
</split>

what am I doing wrong?

ERROR:  'Open quote is expected for attribute "group" associated with an  element type  "tokenize".

Splitter group attribute inject variable parameter

can you inject a value from the config params file in to the splitter group attribute? if so, what is the proper way of doing it? thanks!

I've tried,

<split streaming="true" >
<tokenize token="\n" group="{{noOfLines}}" />
<log message="Split Group Body: ${body}"/>
    <to uri="bean:extractHeader" />
    <to id="acceptedFileType" ref="pConsumer" /> 
</split>

<split streaming="true" >
<tokenize token="\n" group={{noOfLines}} />
<log message="Split Group Body: ${body}"/>
    <to uri="bean:extractHeader" />
    <to id="acceptedFileType" ref="pConsumer" /> 
</split>

what am I doing wrong?

ERROR:  'Open quote is expected for attribute "group" associated with an  element type  "tokenize".