You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by anandsk <sk...@arccorp.com> on 2010/03/12 17:31:36 UTC

custom component using Mina

since there is a bug with async route with Mina in camel 2.2.0, 
I am thinking of writing a custom component to achieve following. I am
assuming that I can use load balancer component in case of connection
failure to rotate IP addresses in combination with custom component.I will
deploy this a war app and I am using spring.
 I have to use single TCP connection and need to send and receive messages
asynchronously. can someone help me with high level steps to achieve this?.
I am assuming I don't need to worry about thread synchronization and thread
safety as I have to use single connection object.

I am thinking all I need to do is 
1. extend defaultcomponent and override createendpoint method to return the
same object everytime(declare a singleton spring defaultconnector bean and
use annotation to inject into this component).

2. extend defaultproducer and override process methos to send message on
singletonobject.

3. extend defaultconsumer and override dostart(establishconnection  and
register IOhandler for message receive events) and dostop(disconnect)

4. implement messagereceived of IOhandleradapter
I am not sure what goes in here, how to pass the message to next
processor/endpoint for futher processing?.

5. extend defaultendpoint and 
override createproducer and return number 2 class above.
overrise createconsumer and return number 3 class above.

can someone validate this and let me know, if I need to do anything else.
 








-- 
View this message in context: http://old.nabble.com/custom-component-using-Mina-tp27879624p27879624.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: custom component using Mina

Posted by anandsk <sk...@arccorp.com>.
I ended up doing this, may be similar functionality can be added in future
releases to existing Mina component.

1. copied all Mina component related classes to create custom Mina component
to fit my needs.
2. receivehandler extends mina api's iohandleradpater 
3. added member variable iohandleradapter to component to share between
Minaproducer and Minaconsumer.
4. create receivehandler in minaconsumer onstart() method and assign it to
the minacomponent. 5.Minaconsumer object instance is passed to
receivehandler to initiate the route on message event.
6.access the receivehandler in Mina producer and pass it to connect method.
used the same receivehandler object between producers in case of
loadbalanced producers.

Please let me know if you guys have any comments/issues with above approach.

Thanks,
Anand



anandsk wrote:
> 
> actually, I copied Mina component and modifying only the code to share
> receivehandler and connection between producer and consumer. I need to be
> able to load balance on failure. procuder loadbalances using loadbalancer
> component on exception.Consumer just listens for message.
>  I just had a question regrading loss of unprocessed messages in case of
> IO/connection failure,suppose I got 3 messages from remote server and I am
> in the middle of processing number 2 onmessage event and connection
> failure happend and reestablish connection with new IP would I loose
> message number 2 or 3.
> 
> Thanks,
> Anand 
> 
> 
> Ashwin Karpe wrote:
>> 
>> Hi,
>> 
>> You might want to look at the Mina component source code for gathering
>> details on how to write a mina like component yourself. But I suspect you
>> have done this already ;)
>> 
>> Cheers,
>> 
>> Ashwin...
>> 
>>  
>> 
>> anandsk wrote:
>>> 
>>> since there is a bug with async route with Mina in camel 2.2.0, 
>>> I am thinking of writing a custom component to achieve following as per
>>> huntc suggestion. I am assuming that I can use load balancer component
>>> in case of connection failure to rotate IP addresses in combination with
>>> custom component.I will deploy this as a war app and I am using spring.
>>>  I have to use single TCP connection and need to send and receive
>>> messages asynchronously. can someone help me with high level steps to
>>> achieve this?. I am assuming I don't need to worry about thread
>>> synchronization and thread safety as I have to use single connection
>>> object.
>>> 
>>> I am thinking all I need to do is 
>>> 1. extend defaultcomponent and override createendpoint method to return
>>> the same object everytime(declare a singleton spring minaconnector bean
>>> and use annotation to inject into this component).
>>> 
>>> 2. extend defaultproducer and override process method to send message on
>>> using singleton spring object.
>>> 
>>> 3. extend defaultconsumer and override dostart(establishconnection  and
>>> register IOhandler for message receive events) and dostop(disconnect)
>>> 
>>> 4. implement messagereceived of IOhandleradapter
>>> I am not sure what goes in here, how to pass the message to next
>>> processor/endpoint for futher processing?.
>>> 
>>> 5. extend defaultendpoint and 
>>> override createproducer and return number 2 class above.
>>> overrise createconsumer and return number 3 class above.
>>> 
>>> 6. ofcourse I need to define this component in spring, so that it is
>>> visible to camel.
>>> 
>>> can someone validate above items and let me know, if I need to do
>>> anything else.
>>> 
>>> I am thing my sample route would like this.
>>> 
>>> from("file:///test/test/response") 
>>>   .convertBodyTo(String.class) 
>>>   .to("mycomponent://localhost:6202"); 
>>>                 
>>> from("mycomponent://localhost:6202") 
>>>   .to("log:+++ reply++++");
>>> 
>>> 
>>>  
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/custom-component-using-Mina-tp27879624p27937811.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: custom component using Mina

Posted by anandsk <sk...@arccorp.com>.
actually, I copied Mina component and modifying only the code to share
receivehandler and connection between producer and consumer. I need to be
able to load balance on failure. procuder loadbalances using loadbalancer
component on exception.Consumer just listens for message.
 I just had a question regrading loss of unprocessed messages in case of
IO/connection failure,suppose I got 3 messages from remote server and I am
in the middle of processing number 2 onmessage event and connection failure
happend and reestablish connection with new IP would I loose message number
2 or 3.

Thanks,
Anand 


Ashwin Karpe wrote:
> 
> Hi,
> 
> You might want to look at the Mina component source code for gathering
> details on how to write a mina like component yourself. But I suspect you
> have done this already ;)
> 
> Cheers,
> 
> Ashwin...
> 
>  
> 
> anandsk wrote:
>> 
>> since there is a bug with async route with Mina in camel 2.2.0, 
>> I am thinking of writing a custom component to achieve following as per
>> huntc suggestion. I am assuming that I can use load balancer component in
>> case of connection failure to rotate IP addresses in combination with
>> custom component.I will deploy this as a war app and I am using spring.
>>  I have to use single TCP connection and need to send and receive
>> messages asynchronously. can someone help me with high level steps to
>> achieve this?. I am assuming I don't need to worry about thread
>> synchronization and thread safety as I have to use single connection
>> object.
>> 
>> I am thinking all I need to do is 
>> 1. extend defaultcomponent and override createendpoint method to return
>> the same object everytime(declare a singleton spring minaconnector bean
>> and use annotation to inject into this component).
>> 
>> 2. extend defaultproducer and override process method to send message on
>> using singleton spring object.
>> 
>> 3. extend defaultconsumer and override dostart(establishconnection  and
>> register IOhandler for message receive events) and dostop(disconnect)
>> 
>> 4. implement messagereceived of IOhandleradapter
>> I am not sure what goes in here, how to pass the message to next
>> processor/endpoint for futher processing?.
>> 
>> 5. extend defaultendpoint and 
>> override createproducer and return number 2 class above.
>> overrise createconsumer and return number 3 class above.
>> 
>> 6. ofcourse I need to define this component in spring, so that it is
>> visible to camel.
>> 
>> can someone validate above items and let me know, if I need to do
>> anything else.
>> 
>> I am thing my sample route would like this.
>> 
>> from("file:///test/test/response") 
>>   .convertBodyTo(String.class) 
>>   .to("mycomponent://localhost:6202"); 
>>                 
>> from("mycomponent://localhost:6202") 
>>   .to("log:+++ reply++++");
>> 
>> 
>>  
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://old.nabble.com/custom-component-using-Mina-tp27879624p27905906.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: custom component using Mina

Posted by Ashwin Karpe <as...@progress.com>.
Hi,

You might want to look at the Mina component source code for gathering
details on how to write a mina like component yourself. But I suspect you
have done this already ;)

Cheers,

Ashwin...

 

anandsk wrote:
> 
> since there is a bug with async route with Mina in camel 2.2.0, 
> I am thinking of writing a custom component to achieve following as per
> huntc suggestion. I am assuming that I can use load balancer component in
> case of connection failure to rotate IP addresses in combination with
> custom component.I will deploy this as a war app and I am using spring.
>  I have to use single TCP connection and need to send and receive messages
> asynchronously. can someone help me with high level steps to achieve
> this?. I am assuming I don't need to worry about thread synchronization
> and thread safety as I have to use single connection object.
> 
> I am thinking all I need to do is 
> 1. extend defaultcomponent and override createendpoint method to return
> the same object everytime(declare a singleton spring minaconnector bean
> and use annotation to inject into this component).
> 
> 2. extend defaultproducer and override process method to send message on
> using singleton spring object.
> 
> 3. extend defaultconsumer and override dostart(establishconnection  and
> register IOhandler for message receive events) and dostop(disconnect)
> 
> 4. implement messagereceived of IOhandleradapter
> I am not sure what goes in here, how to pass the message to next
> processor/endpoint for futher processing?.
> 
> 5. extend defaultendpoint and 
> override createproducer and return number 2 class above.
> overrise createconsumer and return number 3 class above.
> 
> 6. ofcourse I need to define this component in spring, so that it is
> visible to camel.
> 
> can someone validate above items and let me know, if I need to do anything
> else.
> 
> I am thing my sample route would like this.
> 
> from("file:///test/test/response") 
>   .convertBodyTo(String.class) 
>   .to("mycomponent://localhost:6202"); 
>                 
> from("mycomponent://localhost:6202") 
>   .to("log:+++ reply++++");
> 
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 


-----
--- 
Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence 
Progress Software Corporation
14 Oak Park Drive
Bedford, MA 01730
--- 
+1-972-304-9084 (Office) 
+1-972-971-1700 (Mobile) 
---- 
Blog: http://opensourceknowledge.blogspot.com/


-- 
View this message in context: http://old.nabble.com/custom-component-using-Mina-tp27879624p27902524.html
Sent from the Camel - Users mailing list archive at Nabble.com.