I was looking up online how to create a Camel's CXF producer (i.e. create a CXF endpoint that would produce a request to some local/remote web service). Generally, all the examples I could find would list the following steps:
First define the cxfEndpoint attributes:
<cxf:cxfEndpoint
id="orderEndpoint"
address="http://localhost:9000/order/"
serviceClass="camelinaction.order.OrderEndpoint"/>
Then send the request to that endpoint:
...to("cxf:bean:orderEndpoint");
Hmmm. I don't understand the concept. If this is a remote web service, all I usually have is the URL of the WSDL. I can get from it the address of the service... but I don't know what the serviceClass is and I don't have it on my classpath.
So how do I define that cxfEndpoint in case I only have the URL of the WSDL?
Or is there another type of endpoint I should use in that case?
I would suggest looking into WSDL first for cxf. Below are two links that I think should help you out quite a lot and has helped me in the past as well.
http://code.notsoclever.cc/camel-cxf-component-wsdl-first-example/
https://access.redhat.com/documentation/en-US/Fuse_ESB_Enterprise/7.0/html-single/Web_Services_and_Routing_with_Camel_CXF/index.html#ImplWs-WsdlFirst
On the Red Hat site you will need to start at chapter 3.
Hope this helps.
Related
Actually I am playing with apache-camel 2.15.2, the REST DSL available since Camel 2.14 is not complicated. However I can't find in the official documentation how to retrieve a query parameter, basically I would like to target my REST service in this way:
http://myServer/myService/myMethod?myQueryParam=myValue
Is that possible, or is there any workaround ?
Thanks in advance.
Camel uses the REST/HTTP component of choice (restlet, jetty, servlet, netty-http, spark-rest, etc) which maps query parameters as Camel message headers.
So yes you can with the rest-dsl exposes a REST service where clients can call it with query parameters, which is then mapped to Camel message headers during routing.
I wanted to know if Apache Camel can be used as a load balancer for any HTTP web server.
I am thinking of Apache as I can add some customization to it.
Yes you can use camel for that.
Something like this might do it for you (in a route builder):
from("jetty://http://0.0.0.0:8080/my/path")
.loadBalance()
.roundRobin()
.to("http://server1:8080/my/path","http://server2:8080/my/path");
You can check out more load balancing options here: http://camel.apache.org/load-balancer.html
Since you want to load balance HTTP, then see this page as well, as you would need to configure the http endpoints to be bridged:
http://camel.apache.org/how-to-use-camel-as-a-http-proxy-between-a-client-and-server.html
And as well the matchOnUriPrefix=true, to match any requests coming in.
And if you use jetty on all the endpoints it can scale up, using non-blocking continuations.
Yeah of course you can use camel as a Load balancer. I have so far used it very successfully. Have a look at this discussion Load balancing using camel. This will be useful to get started. Have fun riding on Camel!
Scenario : I'll try to put an analogy with the loan broker example from the EIP book
The customer sends a quote request
(The loan broker requests customer credit score from the credit bureau)
The loan broker sends quote requests to each bank.
The problem
In my case point 1 and 2 are in the same camel context (or osgi bundle)
Each bank has a separate bundle, exposing endpoints to the loan-broker-bundle through NMR
loan-broker-bundle doesn't know about the banks beforehand since we keep partnering with new banks every now and then
What I did
Created a registry class and a bankDescriptor interface in loan-broker-bundle
each bank bundle when started calls the registery to add its bankDescriptor (spring init) that tells the loan broker what endpoint to call to get a quote.
loan-broker-bundle main route uses recipientList (a processor sets target endpoints by asking the registery) to route quote requests
The question
Hoping my description was clear enough, you can see that this is a really simple implementation. What are its limits ? How can i turn this registery into an osgi service ?
I developed a solution like this based on SpringDM for a client. There's a full write up of how to do this at http://www.jakubkorab.net/2012/05/system-integrations-as-plugins-using-camel-and-servicemix.html with full source code available at https://github.com/FuseByExample/smx-application-plugins
Hope that helps.
In OSGi there is a great registry at your disposal: The OSGi service registry. So my proposal is to do this slightly differently. Define a service interface for the quote requests and store it in a api bundle. Then let each bank implement this interface and publish the implementation as an OSGi service.
The loan broker bundle can then list all OSGi services in the OSGi service registry and call each to get the quote. In blueprint there is a nice tag that you can use to inject the list into a bean property of List. Spring DM perhaps has something similar.
Camel currently does not have way to call all OSGi services of a type. We discussed a new osgi service compomnent that would be able to do this. So probably we will soon have a solution.
We have a Web Service client generated with CXF from a WSDL.
We now need to have an access to the generated SOAP requests in order to persist them.
It seems that the framework does not provide this behaviour by default.
Anyway do you guys ever tried to do such a thing?
I am thinking of building my own interceptor that can access to the fully generated message but maybe there is a better choice?
Any advice?
Thanks in advance.
By default CXF uses stax to stream your requests. If you add an interceptor, you can get access to the stax output writer and copy the events.
There is existing code in CXF to force the existence of a DOM tree; see code related to SAAJ and security.
In general, detailed CXF questions get better answers on the CXF user mailing list than here.
A registry is a list of items with pointers for where to find the items, like the index on a database table or the card catalog for a library.
Correct me if I am wrong, from this definition, what I'd expect from a camel application registry is where a client application can (depending on the client protocol) do a lookup and based on metadata, selects a particular service and uses it as defined.
I am wondering if Apache Camel has anything close to this. Most of the service registries articles/implementations I have seen seems to address only SOAP protocols.
Regards.
You can use the REST API from camel-web to lookup routes and endpoint which is the "services" in Camel.
http://camel.apache.org/web-console.html
In terms of a SOA service registry then you may look at other products which specialize in that such as Apache ZooKepper
http://hadoop.apache.org/zookeeper/
You can use ManagementStrategy SPI to hook into events in Camel and track services as they are created/started/stopped etc. Then you can bridge that to your SOA service registry product of choice.
you can also use the CamelContext getEndpoints() and getEndpointsMap() APIs to browse the endpoints
see this post for some general monitoring information...
http://benoday.blogspot.com/2011/01/apache-camel-monitoring.html