Hi

A lot of questions. Let me give a start and try answering a couple of those.



On Thu, Nov 26, 2009 at 1:42 AM, Pete Mueller <p...@routecloud.com> wrote:
>
> Does any one have any documentation on the lifecycle of a camel component and
> it's associated entities (Endpoint,
> Consumer, Producer).  I am attempting to write a component for a
> event-driving wireline protocol.  I understand the basics of:
> 0. Component is created.
> 1. URI in DSL gets passed to to component.
> 2. Component creates Endpoint for each unique URI (if using a singleton)
> 3. Endpoint creates Consumers and Producers.
>
> But I'm looking for a little more detail as to what triggers the creation
> and removal of say Consumers. Specifically,
> - Is a single Consumer around for the life of the CamelContext?

Consumers and Producers are in reality more dynamic as you can have
create a consumer, use it once and then discard it.
CamelContext does not hold a repository for all created
consumers/producers etc. As you can create then without involvement
from CamelContext.

On the other hand when a consumer is used as a input to a route, then
that consumer is around for the life of that route.


> - Does an Endpoint get notified if a Consumer it created is stop()'d?

No there is no such callback. Camel have a very liberal and light API
for Endpoint, Consumer, Producer so its easy to work with an implement
custom components etc.

There is a event API added in Camel 2.1 which have notifications when
routes are started/stopped etc. This can be used in case you need to
do some custom stuff.

> - What is Consumer.stop() used for?  Only during shutdown of the
> CamelContext?  Or is it more like a "pause" than a stop?

Both. You can stop a route at runtime. But when Camel shutdown it will
go through all routes, components, endpoints, services etc. Basically
all what it has and stop them one by one.


> - Is there a way (say in the case of a loss of network connection) to stop()
> an Endpoint and all associated Consumers and Producers? Then later restart
> them after connection has been regained?

Yeah you can for example use Camel error handling and stop a route in
case of an ConnectionException or what you like.


In Camel 2.1 you can use RoutePolicy to that as well. However you must
implement some logic yourself that monitors that particular connection
and can start/stop the route depending on its state. Camel does not do
that for you.


> - Is there a general example/recommendation on how to handle connections to
> unreliable external entities?
>

No not 2 business are the same. Some wants to self heal and just try
at next interval. Others want to try 5 times with X delays and then
alert someone if still a problem.


> I've been using the IRC component as somewhat of a model, but my glance
> through the code doesn't really indicate how the component deals with
> connection loss or net-splits and other networking pit-falls.
>

Again connectivity is not that easy to encompass into a single model
for dealing with lost connections.
Often you only got the wacky java Exceptions that may or may not
indicate a io/connection problem.

However when you have a Camel consumer = input to a route then you got
a chicken egg problem as Camel does not take over
before the consumer has successfully got a message and created an
Exchange to be routed in Camel. At this point Camel take over and you
can use Camel error handling. But before that all error handling etc.
is component specify.


We love contributions so dig into it and help out.
http://camel.apache.org/contributing.html


> Here's a short outline of the wire protocol I have to implement if it helps:
>
> 1. Open TWO TCP connections with Server
> 2. Register Myself with Server, twice, once as a SENDER, once as a RECEIVER.
> Both connections are bi-directional, but the functions I can do on each
> connection is limited by how I register myself.
> 3. At this point I will receive data packets (messages) for some length of
> time over the Receiver connection.
> 4. At some point in the future the Server will send me an "ALL DONE"
> message.  At which point I must un-register my sender and receiver, but the
> TCP connections remail open.
> 5. After the unregister I need to notify Consumers that there is no more
> messages coming and stop Producers from attempting to send more messages.
> 6. After waiting X seconds (X in most cases is 180) I will attempt to
> re-register myself and if successful need to re-activate Consumers and
> Producers.
> 7. I also need to account for the fact that at any time, I may lose a
> network connection to the Server, and will need to stop all Consumers and
> Producers until connection is restored.
>
> Thanks for any help
> -p
> --
> View this message in context: 
> http://old.nabble.com/Lifecycle-of-a-Camel-Component-tp26522808p26522808.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Reply via email to