How can I write Spring XML about multiple inputs - apache-camel

I am implementing mediation module.
This system sends many files to target systems with adding some information.
There are many input sources and output targets.
So, I want to write Spring XML for this process. But I cannot find this solution.
I saw some articles in Jboss community.
https://access.redhat.com/documentation/en-us/red_hat_jboss_fuse/6.3/html/apache_camel_development_guide/basicprinciples-multipleinputs
In this article, there is below definition of java dsl.
from("URI1").to("DestinationUri");
from("URI2").to("DestinationUri");
from("URI3").to("DestinationUri");
Is this code possible in springXML?
Please check my question and reply solution.
Thank you.

You should only have 1 from per route. Having 2+ is deprecated and not recommended. And in Camel 3 we have restricted this to exactly 1 input only.
So use 1 route per input. You can link multiple routes together via direct if you want to call something that is shared among those routes
from a
to direct:shared
from b
to direct:shared
from direct:shared
to foo

Related

In Apache Camel, for which component will create endpoints if it's not exist?

I'm new to Camel, and have some basic questions which can't found the answers online. Please help and I'm appreciate it.
I have read many example online, and saw bunch example like this:
from(direct:A).to(jms:queue:B)
But didn't see any configuration for them. My question is what will happen if the direct doesn't exist? How about from(jms:queue:A).to(direct:A)? and what about the other components?
For this example, what's the execution order? does it pass the original message to B first, then process and pass to C?
from(direct:A)
.to(jms:B)
.process(something)
.to(jms:C)
Direct is an in memory queue, provided by Camel. Prior it Camel 3, it was bundled with the camel-core module and you would not need any configuration at all in order to use the direct component. However, due to sake of modularity, since Camel 3, direct has been made its own component and in order to use it camel-direct needs to be imported.
Jms on the other hand is a generic component, using which you can implement connectivity to different Jms providers such as ActiveMq(though in Camel activemq has it's own component), IBM MQ, Weblogic JMS server, and others.
For your 1st question, if direct doesn't not exist, you need to import the direct component into your build. If the uri provided to the component is not present, Camel will create its own. This is true for most of the Camel components. One of the most common is the file component, which is used to pick up files from a given directory. If the given directory is not present, Camel is smart enough to create the directory. Obviously, these are default behaviours and you have a lot of control to pick and choose how you want your route to behave.
For your second question, the route will be processed entirely in order, which is, the message will be picked up from the direct:A, then will be sent to jms:B. After that it will be processed using the something processor and will finally be sent to jms:c.
The thing to note here is that the direct:A is just an example to show the syntax of a route. You can use any component which can act as a consumer.

What is the difference between the methods process(Exchange) and process(Exchange,AsyncCallback)

I am trying to write a custom intercept strategy
What is the difference between over riding the method process(Exchange) by using a processor or over riding the method process(Exchange,AsyncCallback) using a AsyncProcessor.
When one i do i need to use.?
If you have a copy of Camel in Action book then its best explained there in chapter 10. You can also find some details on the Camel web site, and the javadoc.
http://camel.apache.org/asynchronous-processing.html

The Camel way of doing

I have a requirement where in i have to develop components using Camel. I know how to do this in pure Java. But i want to utilize Camel, wherever it is applicable. So here is a my requirement
1) Web service method
2) Validate the request data
3) Insert data into DB
4) Export data into CSV File
5) Move the CSV into a FTP location
6) Call a Stored procedure (which takes a INPUT parameter from Request)
7) Call one more Stored procedure (which takes a INPUT parameter from Request)
8) Call a Web Service and I want this Web Service to run within certain time. If it takes more than that, throw out Time out exception.
Can we achieve this using Camel. I just want to know, whether we can do it or not. If you feel it is achievable, can you show me the right direction. Help appreciated.
These are various basic tasks Camel is built to help you with.
Since Camel is well documented by both reference material and examples you can very easily find documentation online. Try it out and come back for detailed and specific questions. See some starting pages for your various tasks.
http://camel.apache.org/cxf-example.html
http://camel.apache.org/validate.html
http://camel.apache.org/sql-example.html
http://camel.apache.org/csv.html
http://camel.apache.org/ftp-example.html
http://camel.apache.org/sql-component.html
DITO
http://camel.apache.org/cxf.html
Btw, you are receiving down votes since your question lacks some minor research effort, like searching the Camel online documentation.

Table for Longest prefix matching

I want to build a kernel module which will maintain his own table for carrying out longest prefix match. For this purpose, I am trying to use linux's "include/net/ip6_fib.h". Is it possible to meet the required functionality through this? Am I on right path?
If answer is YES then can anyone tell me some good resource which explains the IP6 FIB API?
Thnaks in advance.
Regards
I have very little kernel space experience, but from the user land perspective I know that Linux routing tables can be independent of the routing of packets. If I understood your question correctly, that is what you were asking.
AFAIK Linux routing only uses tables that are defined in the "routing policy" i.e., they have routing rules referencing them. The Linux default is to use tables "local" "main" and "default" (table numbers 255, 254 and 253). So if you put your routes in e.g. table number 100, they will not be used by the regular routing mechanisms, unless you add a rule referencing the table. You can see the routing "policy" by typing ip rule list. This can also be learned from the "official" iproute documentation which has not been updated since Alexey N. Kuznetsov wrote it at the turn of the millennium.
However, I dont know how this affects prefix matching and the ip6_fib api, since route lookups are cached (outside the routing tables). You can see the routing cache by typing ip route list table cache. (side note: an indepth look at the routing cache can be found at http://vincent.bernat.im/en/blog/2011-ipv4-route-cache-linux.html)
I can not provide any help on using the FIB inside the kernel, which was your 2nd inquiry. I can only venture that the kernel source is the most up to date documentation and most probably also the only documentation.

Apache module FORM handling in C

I'm implementing an Apache 2.0.x module in C, to interface with an existing product we have. I need to handle FORM data, most likely using POST but I want to handle the GET case as well.
Nick Kew's Apache Modules book has a section on handling form data. It provides code examples for POST and GET, which return an apr_hash_t of the key+value pairs in the form. parse_form_from_POST marshalls the bucket brigade and flattens it into a buffer, while parse_form_from_GET can simply reference the URL. Both routines rely on a parse_form_from_string routine to walk through each delimited field and extract the information into the hash table.
That would be fine, but it seems like there should be an easier way to do this than adding a couple hundred lines of code to my module. Is there an existing module or routines within apache, apr, or apr-util to extract the field names and associated data from a GET or POST FORM into a structure which C code can more easily access? I cannot find anything relevant, but this seems like a common need for which there should be a solution.
I switched to G-WAN which offers a transparent ANSI C scripts interface for GET and POST forms (and many other goodies like charts, GIF I/O, etc.).
A couple of AJAX examples are available at the GWAN developer page
Hope it helps!
While, on it's surface, this may seem common, cgi-style content handlers in C on apache are pretty rare. Most people just use CGI, FastCGI, or the myriad of frameworks such as mod_perl.
Most of the C apache modules that I've written are targeted at modifying the particular behavior of the web server in specific, targeted ways that are applicable to every request.
If it's at all possible to write your handler outside of an apache module, I would encourage you to pursue that strategy.
I have not yet tried any solution, since I found this SO question as a result of my own frustration with the example in the "Apache Modules" book as well. But here's what I've found, so far. I will update this answer when I have researched more.
Luckily it looks like this is now a solved problem in Apache 2.4 using the ap_parse_form_data funciton.
No idea how well this works compared to your example, but here is a much more concise read_post function.
It is also possible that mod_form could be of value.

Resources