0 Replies Latest reply on Oct 11, 2011 10:02 AM by Juan Ignacio Garzon

    Observe Events raised by another conversation

    Juan Ignacio Garzon Newbie

      Hi, I'm developing a messaging subsystem that has two main beans.

      The first one is an APPLICATION scoped bean, that has a method to publish a message:

      public class GestorMensajeria {
           EntityManager entityManager;
           public void publicarMensaje(Mensaje mensaje) {

      It simply flushes the message, and raises an event, passing the user that should receive the message (mensaje.getDestinatario() has a reference to the receiver user object)

      On the other hand (the receiver of the message), I have a CONVERSATION scoped Entity Query that lists the messages for the current user. I want to refresh the query every time a message is received for the current user:

      public class MensajesRecibidosEntityQuery extends EntityQueryPaginada<Mensaje> {
           Usuario usuarioActual;
           public void onMensajeRecibido(Usuario usuario) {
                if (usuario != null && usuario.equals(usuarioActual)) {
           public MensajesRecibidosEntityQuery() {
                setEjbql("select m from Mensaje m ");
                List<String> restricciones = new ArrayList<String>();

      The problem is that the method marked as @Observer(mensajeEnviado) is called only for the MensajesRecibidosEntityQuery bean in the Conversation scope of the sender. I mean, there are multiple instances of mensajesRecibidosQuery Entity Query objects living in different conversation scopes, and only one (the one that belongs to the sender of the message) is called. Is this a bug? Shouldn't the event mechanism ignore scopes and call every single bean instance that is marked as @Observer?

      Please help!
      Thanks for you time.