2009/1/8 Davis Ford <davisf...@gmail.com>:
> Hi, regarding the @Consumed annotation
>
> http://activemq.apache.org/camel/maven/camel-jpa/apidocs/org/apache/camel/component/jpa/Consumed.html
>
> I'm a bit curious how this works.  If I have the following setup:
>
> NodeA <----> OracleDB <----> NodeB
>
> Where I have a JpaProducer on NodeA and a JpaConsumer on NodeB
>
> And I have something like
>
> @Entity
> public class MyEntity {
>
>    etc..
>
>    @Consumed
>    public void consumed() {
>        System.out.println("Message was consumed");
>    }
> }
>
> I tried this out in a single JVM test that hits an oracle database and
> it works.  I get a callback on the @Consumed method.  But in a
> distributed environment -- how does this work?  How would the producer
> on NodeA know that the consumer on NodeB got the Exchange?

The JVM that is processing an entity bean has the @Consumed method
invoked as a kinda lifecycle hook - as an alternative to the entity
bean just being deleted.


> Follow up question:  The @Consumed annotation will come in really
> handy for me if I can get it to work the way I want.  Here's what I am
> attempting to do:
>
> 1. Producer sends message
> 2. Consumer gets message
> 3. Consumer has to do some operation that may fail
>  3a. If it does fail I do not want the producer notified that the
> message was consumed
>  3b. If it does not fail, I want the producer notified so it can do
> some local cleanup

So either your producer could poll using a JPA query for entities
which are marked processed; or you could explicitly send a
notification message?

FWIW if the processing of the consumer fails, you might want to just
rollback the transaction and retry again later?


> Maybe the @Consumed is not what I want -- is there some way to insert
> a hook on the consumer side to control when the producer would get
> notified?

from("jpa:MyEntityBean").to("activemq:TheProducersQueue");


-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Reply via email to