newbie questions

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

newbie questions

mat wang
Why A Producer extends Processor but A Consumer NOT?  What is a
Processor.process method (a place for implement own business logic?) Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: newbie questions

jstrachan
On 8/3/07, mat wang <[hidden email]> wrote:
> Why A Producer extends Processor but A Consumer NOT?

Great question :)

So when you create a producer, you just want to pass message exchanges
into it - so you can treat a producer just like any kind of Processor
object and just call process().

When you create a consumer though, the consumer by default is an event
driven consumer
http://activemq.apache.org/camel/event-driven-consumer.html

this means that the endpoint decides how and when to invoke your code
when a message is received - typically in a background thread
asynchronously. So for a consumer, you provide your own Processor to
handle the messages and pass that into the createConsumer method
http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Endpoint.html#createProducer()

The returned Consumer object is then mostly just to be able to stop it
when you are done (rather like the JMS MessageConsumer interface).

Finally you could also create a Polling Consumer where you pull
message exchanges out of the PollingConsumer interface
http://activemq.apache.org/camel/polling-consumer.html


> What is a
> Processor.process method (a place for implement own business logic?) Thanks.

Yes, a Processor.process() typically processes a message exchange in
some way - this could involve sending it over some protocol (such as
the Producer implementations) or it could involve doing some routing,
or invoking business logic.

Incidentally to invoke business logic, I'd recommend loosly coupling
your business logic to Camel message exchanges. e.g.

http://activemq.apache.org/camel/bean-integration.html

that way your business logic doesn't have to implement any Camel
specific APIs; though it may use some annotations to help describe the
binding.

--
James
-------
http://macstrac.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: newbie questions

mat wang
Thanks a lot for your detailed answers. After reading the documents of
Camel, the materials were not enough for me to grab the whole picture.  I
have to read some of the source code.

I  found out in DefaultEndpoint class:
    public int hashCode() {
        return endpointUri.hashCode() * 37 + 1;
    }

What is this supposed to mean?

I also felt this mail list seemed not very active. Camel is NOT popular?

On 8/3/07, James Strachan <[hidden email]> wrote:

>
> On 8/3/07, mat wang <[hidden email]> wrote:
> > Why A Producer extends Processor but A Consumer NOT?
>
> Great question :)
>
> So when you create a producer, you just want to pass message exchanges
> into it - so you can treat a producer just like any kind of Processor
> object and just call process().
>
> When you create a consumer though, the consumer by default is an event
> driven consumer
> http://activemq.apache.org/camel/event-driven-consumer.html
>
> this means that the endpoint decides how and when to invoke your code
> when a message is received - typically in a background thread
> asynchronously. So for a consumer, you provide your own Processor to
> handle the messages and pass that into the createConsumer method
>
> http://activemq.apache.org/camel/maven/camel-core/apidocs/org/apache/camel/Endpoint.html#createProducer()
>
> The returned Consumer object is then mostly just to be able to stop it
> when you are done (rather like the JMS MessageConsumer interface).
>
> Finally you could also create a Polling Consumer where you pull
> message exchanges out of the PollingConsumer interface
> http://activemq.apache.org/camel/polling-consumer.html
>
>
> > What is a
> > Processor.process method (a place for implement own business logic?)
> Thanks.
>
> Yes, a Processor.process() typically processes a message exchange in
> some way - this could involve sending it over some protocol (such as
> the Producer implementations) or it could involve doing some routing,
> or invoking business logic.
>
> Incidentally to invoke business logic, I'd recommend loosly coupling
> your business logic to Camel message exchanges. e.g.
>
> http://activemq.apache.org/camel/bean-integration.html
>
> that way your business logic doesn't have to implement any Camel
> specific APIs; though it may use some annotations to help describe the
> binding.
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
Reply | Threaded
Open this post in threaded view
|

Re: newbie questions

jstrachan
On 8/6/07, mat wang <[hidden email]> wrote:

> Thanks a lot for your detailed answers. After reading the documents of
> Camel, the materials were not enough for me to grab the whole picture.  I
> have to read some of the source code.
>
> I  found out in DefaultEndpoint class:
>     public int hashCode() {
>         return endpointUri.hashCode() * 37 + 1;
>     }
>
> What is this supposed to mean?

Just that 2 endpoints have the same hashcode if they have the same URL.


> I also felt this mail list seemed not very active. Camel is NOT popular?

Camel is still relatively new; it kinda sprung from requirements in
ActiveMQ, CXF and ServiceMix which are all crazy-popular, so i expect
these lists to gather momentum; particularly as more users of
ActiveMQ/CXF/ServiceMix start using Camel to add easy EIP integration
etc.

--
James
-------
http://macstrac.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: newbie questions

mat wang
On 8/6/07, James Strachan <[hidden email]> wrote:

>
> On 8/6/07, mat wang <[hidden email]> wrote:
> > Thanks a lot for your detailed answers. After reading the documents of
> > Camel, the materials were not enough for me to grab the whole
> picture.  I
> > have to read some of the source code.
> >
> > I  found out in DefaultEndpoint class:
> >     public int hashCode() {
> >         return endpointUri.hashCode() * 37 + 1;
> >     }
> >
> > What is this supposed to mean?
>
> Just that 2 endpoints have the same hashcode if they have the same URL.


Which means: endpointUri.hashCode() * 38 + 1 also works?

> I also felt this mail list seemed not very active. Camel is NOT popular?
>
> Camel is still relatively new; it kinda sprung from requirements in
> ActiveMQ, CXF and ServiceMix which are all crazy-popular, so i expect
> these lists to gather momentum; particularly as more users of
> ActiveMQ/CXF/ServiceMix start using Camel to add easy EIP integration
> etc.


One suggestion: the camel website layout goods pretty good. However, the
reader really needs more information in order to get know Camel. For
instance, what does exactly router do? If a component could be both a
consumer and a producer. But anyways, Thanks.


> --
> James
> -------
> http://macstrac.blogspot.com/
>
Reply | Threaded
Open this post in threaded view
|

Re: newbie questions

jstrachan
On 8/6/07, mat wang <[hidden email]> wrote:

> On 8/6/07, James Strachan <[hidden email]> wrote:
> >
> > On 8/6/07, mat wang <[hidden email]> wrote:
> > > Thanks a lot for your detailed answers. After reading the documents of
> > > Camel, the materials were not enough for me to grab the whole
> > picture.  I
> > > have to read some of the source code.
> > >
> > > I  found out in DefaultEndpoint class:
> > >     public int hashCode() {
> > >         return endpointUri.hashCode() * 37 + 1;
> > >     }
> > >
> > > What is this supposed to mean?
> >
> > Just that 2 endpoints have the same hashcode if they have the same URL.
>
>
> Which means: endpointUri.hashCode() * 38 + 1 also works?

Yeah - its just an attempt to return a different hashcode to the
underlying string, while being equal for two endpoints with the same
endpointUri  really. IIRC the expression comes vaguely from Josh
Bloch's Java book (though the numbers might be a tad wrong).


> > I also felt this mail list seemed not very active. Camel is NOT popular?
> >
> > Camel is still relatively new; it kinda sprung from requirements in
> > ActiveMQ, CXF and ServiceMix which are all crazy-popular, so i expect
> > these lists to gather momentum; particularly as more users of
> > ActiveMQ/CXF/ServiceMix start using Camel to add easy EIP integration
> > etc.
>
>
> One suggestion: the camel website layout goods pretty good. However, the
> reader really needs more information in order to get know Camel. For
> instance, what does exactly router do? If a component could be both a
> consumer and a producer. But anyways, Thanks.

We really value feedback - especially when things are not very clear -
so many thanks.

Here's my first attempt at a FAQ entry to try clear this up...
http://cwiki.apache.org/CAMEL/what-is-a-router.html

Any other thoughts or impressions most welcome - especially if there's
something not clear or missing in the documentation
--
James
-------
http://macstrac.blogspot.com/