2 Replies Latest reply on Aug 19, 2005 10:32 AM by Jens Elkner

    Client notifications or callbacks

    Carlos Gama Newbie

      I'm trying to implement some kind of client notification or callback.

      I have a set of EJB3 entity beans, a couple of session and message driven beans on my JBoss 4.0.3 RC2 server, and a Swing 1.5 client application that invokes methods on my session beans to manipulate the entities (add, remove, etc.). All it's working just fine.

      Now, I want to implement a JList where I list all the instances of an entity, let's say Customer, i.e. I want to display a list of all the customer names in the database. I've implemented a custom ListModel that it's fetched by the Swing client from the server via a session bean method call. So far, so good! The problem is that this model contains all customer names that were in the database when the client app fetched the ListModel object from the server.

      What I would like to have now is some mechanism to forward notifications of inserts, updates or deletes of customers on the database to the client application so that it can update its copy of the model and the associated JList component, i.e. I want the GUI to automatically display the name of a new customer, inserted in the database by some other client.

      Does anyone have any idea on how to implement this, using EJB3 built-in features? (e.g. any annotation I can use to mark a method on a class as a remote callback!?)

      I would like to avoid setting up any RMI communication or something like that, i.e. ideally I would like to use some sort of EJB3 or JBoss annotation!?

      Thanks in advance for any thoughts!

        • 1. Re: Client notifications or callbacks
          Bieth Bruno Newbie

          Sorry I have no idea to do that :(

          In fact I would like to do exactly what you did : a remote client which invoke methods on sessions beans to manipulate entities beans. Could you please tell me how to do that ?

          I try to use this simple client :

          import javax.naming.Context;
          import javax.naming.InitialContext;
          import javax.naming.NamingException;

          import org.wiskee.bd.Massifs;
          import org.wiskee.bd.Massif;

          public class Client {
          public static void main(String[] args) {
          try {
          System.out.println( "CLIENT" );
          Context context = new InitialContext();
          Massifs massifs = (Massifs) context.lookup(Massifs.class.getName());

          System.out.println( "Ajout du massif pyrenees" );
          massifs.addMassif( "Pyrenees" );

          System.out.println( "Liste des massifs : ");
          for( Massif m : massifs.getAllMassif() ) {
          System.out.println( m.getMassifId() + " : " + m.getNom() );
          }
          } catch (NamingException e) {
          e.printStackTrace();
          }
          }
          }


          I put this library in my build path :
          - jbossall-client.jar
          - jboss-ejb3.jar
          - jboss-aop-jdk50.jar
          - jboss-aspect-library-jdk50.jar
          - jboss-remoting.jar
          - commons-httpclient.jar
          - my beans interface definition in a jar (wiskee.jar)

          But I get the following error :
          CLIENT
          Ajout du massif pyrenees
          java.lang.reflect.UndeclaredThrowableException
          at $Proxy0.addMassif(Unknown Source)
          at Client.main(Client.java:20)
          Caused by: java.rmi.ConnectException: Failed to communicate. Problem during marshalling/unmarshalling; nested exception is:
          java.io.EOFException
          at org.jboss.remoting.transport.socket.SocketClientInvoker.transport(SocketClientInvoker.java:266)
          ...


          I use eclipse 3.1 and JBoss 4.0.2 with EJB 3.0 RC1

          Thank you

          • 2. Re: Client notifications or callbacks
            Jens Elkner Apprentice

             

            "gamac" wrote:
            What I would like to have now is some mechanism to forward notifications of inserts, updates or deletes of customers on the database to the client application ...


            Have a look at the JMS examples ...