[jboss-user] [EJB3] - Event Handling between two EJB-JARs (Observer Pattern?)

Patrick M. do-not-reply at jboss.com
Wed Dec 12 06:12:39 EST 2012

Patrick M. [https://community.jboss.org/people/patsinnervoice] created the discussion

"Event Handling between two EJB-JARs (Observer Pattern?)"

To view the discussion, visit: https://community.jboss.org/message/783044#783044


I'm new to EJB development and currently search for the best/correct way to handle events between two EJB-JARs which are in one EAR.

I tried to use the Observer Pattern. The event gets fired in BeanA but does not reach BeanB (as stated, two different EJB-JARs = two different Eclipse Projects in one Workspace / EAR).

My Code currently looks kind of like this:
public class BeanA implements BeanARemote, BeanBLocal{ 
          private EntityManager em;
          private BeanA beanA;
        public void listenToReceivedEvent(@Observes ReceivedEvent events){
          Query query = em.Query("some query");
public class BeanB implements BeanBLocal {
          Event<ReceivedEvent> events;
          public void fireEvent() {
               ReceivedEvent e = new ReceivedEvent(stringList);
public class ReceivedEvent  {
          private List<String> stringList;
          public ReceivedEvent(final List<String> stringList) {
                    this.stringList= stringList;
          public List<String> getStrings() {
                    return stringList;

Currently, when on BeanB the event is fired at BeanA nothing happens. My question now is: is the Observer Pattern the correct pattern in this case? Did I forgot something in this sample why the BeanA does not gets the event? Is the Observer Pattern made for event communication between two differen EJB-JARs? 


Reply to this message by going to Community

Start a new discussion in EJB3 at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20121212/26e937bd/attachment-0001.html 

More information about the jboss-user mailing list