First of all, I don't know how to answer your question. Sorry. However,
after I google "Camel", it seems exactly what I wanted. A routing
component could be used along with Mina server as a message router. My
original purpose is to build a server framework which is not depentent on
any protocols(http, row rocket, web service, db access)(kinda like a Mule).
I believe Mina + Camel can make building this system possible.

I also found this:

Apache Camel can be used as a routing and mediation engine for the following
projects:

Apache mina a networking framework
On 8/1/07, daniel golesny (innoWake gmbh) <[EMAIL PROTECTED]>
wrote:
>
> Hi,
>
> I want to integrate a socket based application which is sending xml
> data. The data should be routed by analysing the content.
> I may not change to current protocol.
>
> I tried Camel that is very good for routing, but I couldn't find a way
> to open a socket.
> With Mina I could open a socket, so I tried to use Mina and Camel by the
> MinaComponent with this uri mina:tcp://127.0.0.1:22345
>
> But on sending some bytes (does not matter if "abc" or valid xml) I get
> an exception on deserializing. I can't find any example with mina and
> camel, can someone send me an example with camel and mina? Or is this
> the wrong way for routing data over raw socket?
>
>
> Version:
> Camel 1.0.0
>
> ------------------ exception on sending bytes ---------
> WARNUNG: [/127.0.0.1:1294] EXCEPTION, please implement
> org.apache.camel.component.mina.MinaConsumer$1.exceptionCaught() for
> proper handling:
> org.apache.mina.filter.codec.ProtocolDecoderException:
> org.apache.mina.common.BufferDataException: dataLength: 1010792557
> (Hexdump: 3C 3F 78 6D 6C 20 76 65 72 73 69 6F 6E 3D 22 31 2E 30 22 20 65
> 6E 63 6F 64 69 6E 67 3D 22 49 53 4F 2D 38 38 35 39 2D 31 22 3F 3E 0D 0A
> 3C 72 6F 75 74 65 54 6F 3E 41 3C 2F 72 6F 75 74 65 54 6F 3E 0D 0A)
>        at
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Protoco
> lCodecFilter.java:161)
>        at
> org.apache.mina.common.support.AbstractIoFilterChain.callNextMessageRece
> ived(AbstractIoFilterChain.java:298)
>        at
> org.apache.mina.common.support.AbstractIoFilterChain.access$5(AbstractIo
> FilterChain.java:295)
>        at
> org.apache.mina.common.support.AbstractIoFilterChain$1.messageReceived(A
> bstractIoFilterChain.java:646)
>        at
> org.apache.mina.filter.executor.ExecutorFilter.processEvent(ExecutorFilt
> er.java:220)
>        at
> org.apache.mina.filter.executor.ExecutorFilter$ProcessEventsRunnable.run
> (ExecutorFilter.java:267)
>        at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker
> .runTask(ThreadPoolExecutor.java:665)
>        at
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker
> .run(ThreadPoolExecutor.java:690)
>        at java.lang.Thread.run(Thread.java:595)
> Caused by: org.apache.mina.common.BufferDataException: dataLength:
> 1010792557
>        at
> org.apache.mina.common.ByteBuffer.prefixedDataAvailable(ByteBuffer.java:
> 1571)
>        at
> org.apache.mina.filter.codec.serialization.ObjectSerializationDecoder.do
> Decode(ObjectSerializationDecoder.java:88)
>        at
> org.apache.mina.filter.codec.CumulativeProtocolDecoder.decode(Cumulative
> ProtocolDecoder.java:133)
>        at
> org.apache.mina.filter.codec.ProtocolCodecFilter.messageReceived(Protoco
> lCodecFilter.java:154)
>        ... 8 more
>
> -------------- Server -----------------
> CamelContext context=new DefaultCamelContext();
> // server component
> MinaComponent inComponent = new MinaComponent();
> context.addComponent("in", inComponent);
> final Endpoint inEndpoint = context.getEndpoint(ENDPOINT_INCOMING);
> // Route BUilder
> context.addRoutes(new RouteBuilder(){
>         public void configure() {
>        FromBuilder from = from(inEndpoint);
>        from.to("file://testA");
>        from("file://testA").process(new Processor(){
>                public void process(Exchange e){
>                        System.out.println("Received exchange for
> file://test: "+e.getIn().getMessageId());
>                }
>        });
>         }
> });
>
> System.out.println("Starting Context");
> context.start();
>
> ------------- Client ----------------
> Socket theSocket = new Socket("127.0.0.1", MinaServerTest1.PORT);
> PrintWriter out = new PrintWriter(theSocket.getOutputStream(), false);
>
> out.println("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
> out.println("<routeTo>A</routeTo>");
> out.flush();
> out.close();
>
>
>
>

Reply via email to