On 8/3/07, mat wang <[EMAIL PROTECTED]> 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/