cmoulliard wrote:
> 
> Is there a way to extend the component camel-mina to allow by example
> to add a layer to communicate with the distant TCP server ?
> 
> By example, we must send a message (bytes) at the beginning of the
> session (= login), another to indicate to the server that we close the
> connection (=logout) and another to indicate that we are still alive
> (heartbeat).
> 

In Mina I could see 2 ways of doing this.
a) Implement this inside the IoHandlerAdapter.
b) Use a pool and implement that logic in the pool (commons pool works great
for me).

Case A (Its the faster but I don't like it, that much).
You would need to use mina mask in order to block outgoing messages till,
you send the login and get an acknowledgement. The login could be sent
inside sessionOpened. The keepAlive could be sent inside sessionIdle. You
get the picture. Following this approach has the serious disadvantage that
its not that configurable.

Case B
You modify the MinaProducer so that it uses commons-pool. You can add a
session pool and a session factory. Then you can modify the openConnection
so that instead of creating a session, to requestimg a session from the
pool. You can implement the login/logout/keepalive inside the makeObject,
destroyObject & validateObject of the sessionfactory.

This way each time it tries to create a new session the makeObject will
create but will not return it till it executes the login. The logout can be
implemented in destroyObject and keepAlive in validate (you can configure
the pool to validate object in pool every n secs).

The great advantage of this approach is that the user can pass to the
MinaProducer the sessionfactory of his choice.

This worked for me pretty well (I've done something similar in servicemix.
Custom BC that uses mina). I hope it does the same for you. Let me know if
you require additional information.
 

-----
Ioannis Canellos
http://iocanel.blogspot.com/ http://iocanel.blogspot.com/ 
-- 
View this message in context: 
http://old.nabble.com/Question-Apache-Camel-Mina-component-tp28841802p28857563.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.

Reply via email to