0

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

Santi
  • 1
  • 1

2 Answers2

1

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.

Nicholas
  • 15,916
  • 4
  • 42
  • 66
  • Thank you, Nicholas. That is a nice design indeed but it is a lot more than what I need, as I am simply implementing the consumer side (i.e., client) . Also, I am most interested in a Camel implementation, if one is possible at all. I am already well on my way implementing plan B; i.e.; a Mina based client. – Santi Jul 18 '12 at 16:45
1

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

milh_cbt
  • 11
  • 3