0
votes

I need to implement a consumer to an XML-RPC based service over TCP. Upon establishing a connection to the server, it requires that

  1. Authentication credentials be sent by the client
  2. An event subscription request be sent by the client, and finally
  3. The client is to switch into a "receiving" mode where messages will be sent asynchronously
  4. When the client is no longer interested in receiving more events, the client ought to "unwind" steps 1-3.

So, I would like to use Apache Camel to implement the client, with an obvious entry endpoint of a Mina Component ("mina:tcp://host:_port_?textline=true&decoderMaxLineLength=10240&sync=true"). My question is, how would I go about implementing steps 1, 2, and 4 above? How would I go about performing those "handshake" steps before the processor in my RouteBuilder gets call? Is this even possible with Camel or will I have to write a straight Mina client to handle this. Are there better options for dealing with this type of integration scenario?

Thank you.

-Santi

2

2 Answers

1
votes

This is a really good tutorial on implementing a session handshaking protocol with Netty, which is quite similar to Mina. You could implement this with Camel's Netty Component or draw on the tutorial to build the same with Mina.

1
votes

it's maybe too late but others may be need the answer. the key point is you need to use a Processor. something like this

from("mina:tcp:////host:_port_?textline=true&decoderMaxLineLength=10240&sync=true")  
.process(new Processor() {  
   public void process(Exchange exchange) throws Exception {  
     String inboundMessage =  exchange.getIn().getBody(String.class);  
     String outboundMessage = "echo:"+inboundMessage;
     exchange.getOut().setBody(outboundMessage);  
   }  
}).to(""mock:result"");

the outboundMessage will be a reply to form end point mina:tcp:////host:_port_?textline=true&decoderMaxLineLength=10240&sync=true