Category Archives: apache-camel

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".

How to resolve the 400 The plain HTTP request was sent to HTTPS port issue in Apache Camel?

How to resolve the 400 The plain HTTP request was sent to HTTPS port issue?

from: empValidation
to: myhost:443/EmpValidation/EmpValidationAPIService
 rules.getRules().forEach(x->{
        final LoadBalanceDefinition lb =  from("jetty:http://0.0.0.0:"+rules.getPort()+"/"+x.getFrom()+"??matchOnUriPrefix=true").log(LoggingLevel.DEBUG, "Processing ${id}").log("Incoming Context Request :"+x.getFrom())
        .loadBalance().roundRobin();
        x.getTo().forEach(z->lb.to("http4://"+z+"?bridgeEndpoint=true&throwExceptionOnFailure=true").log("Outgoing mapping urls :"+z)) ;
      });

if i use "https4" component it's working the above url(empValidation) but it's not working for below url.

Url: myhost:9008/emp-web-service/services/addEmp

Error:
 javax.net.ssl.SSLHandshakeException: Remote host closed connection during 
 handshake
          at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
          at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
          at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)

I think if we use default port it's not working, what is solution for the above scenario?

What can slow down Apache Camel’s ActiveMQ message sending?

Recently, I have performance problem with Apache Camel and ActiveMQ where there's lots of message in pending queue. So I have add logs to print out Apache Camel message history when there's a performance problem with the time used in each steps. And from the log below, it is the sending message to ActiveMq part which took more than 50 seconds to finish.

....
activemqShared:sendToQueueA : 50699 ms, timeStamp : 10:08:43.173,
activemqShared:sendToQueueB : 59010 ms, timeStamp : 10:09:33.872,

And That part of the Camel route is like this

...
.to("activemqShared:sendToQueueA")
.to("activemqShared:sendToQueueB)

Basically this part should just send the message to ActiveMq and that's finished. Then there're consumers that would receive the tasks to be processed asynchronously.

So what can cause sending a message to ActiveMQ take such a long time? My speculation right now is network problem or something that make camel not receive notification that the message has been processed (?)

GET-Request with Apache Camel + Jetty Component

I'm currently trying to to get the JSON-Response from the following URL using Apache Camel with its Jetty Component:

https://maps.dwd.de/geoserver/dwd/ows?service=WFS&version=2.11.0&request=GetFeature&typeName=dwd:RBSN_RR&outputFormat=application%2Fjson

At this point, I have the following snippet:

public void configure() {
    from("direct:dwd")
            .setHeader(Exchange.HTTP_PATH, simple("/geoserver/dwd/ows"))
            .setHeader(Exchange.HTTP_QUERY, simple("service=WFS&version=2.11.0&request=GetFeature&typeName=dwd:RBSN_RR&outputFormat=application%2Fjson"))
            .setHeader(Exchange.HTTP_PATH, simple("GET"))
            .to("jetty:https://maps.dwd.de")
            .log("${body}");
}

What should I do to get the JSON-Response?

Apache Camel Exception. Caused by: org.apache.camel.component.bean.MethodNotFoundException

I receive an xml message from the queue:

<v1:ct_ChangeDateRequest xmlns:v1="http://www.sm.ru/phone/apptypes/ChangeDate/v1">
  <v1:Name>string</v1:Name>
  <v1:getNewDate>3</v1:getNewDate>

  <v1:Channel>string</v1:Channel>

  <v1:CarNumber>1000.00</v1:CarNumber>
</v1:ct_ChangeDateRequest>

In Spring context, I'm trying to put a message to a stored procedure:

<unmarshal ref="jaxb"/>
            <setHeader headerName="setnewdate">
                <simple>${in.body.getName().getNewDate().getChannel().getCarNumber()}</simple>
            </setHeader>
            <to uri="storedproc:dataSource?procedureName={{setNewDate}}"/>

And I catch this exception:

Caused by: org.apache.camel.component.bean.MethodNotFoundException: Method with name: getNewDate() not found on bean: string of type: java.lang.String.