4 Replies Latest reply on Jun 26, 2006 3:29 AM by Joan Bordeau

    Multi threading client to log EBJ3 with ClientLoginModule ??

    Joan Bordeau Newbie

      Hello,

      Configuration :
      JBoss 4.0.4GA installed with run installer, option EJB3, so EJB3RC7.

      I looked for in the WIKI, in this forum, but I don't find my solution really.
      My problem looks like this one :
      http://www.jboss.com/index.html?module=bb&op=viewtopic&t=45414

      I have one client class creating the thread :

      public class ConnectionBDsTest {
      
       public static void main(String args[]) {
       // Test avec differents clients en parallèle
       for (int i = 0; i < 10; i++) {
       new ThreadConnectionSimult("sedet", "m3m0!", 1588).start();
       new ThreadConnectionSimult("j", "1904", 1586).start();
       }
       }
      
      }
      


      Then this one is my thread. The authentification is delegated in the BusinessDelegate in using the LoginContext.login before every the calls to a EJB3.
      public class ThreadConnectionSimult extends Thread {
      
       private JobsTypesSession jobsSession;
       private String login;
       private String passwd;
       private int idCustomer;
       private BusinessDelegate b;
       private final String s55 = "[]";
       private final String s57 = "[id : 10, id : 11, id : 14]";
       private final String s1073 = "[id : 1, id : 2, id : 3, id : 9, id : 11]";
       private final String s1586 = "[]";
       private final String s1588 = "[id : 1, id : 9, id : 10, id : 11, id : 12, id : 14]";
       private final String s1900 = "[id : 1, id : 2, id : 10, id : 11]";
       private final String s1996 = "[id : 8, id : 10, id : 11, id : 12, id : 13]";
       private final String s294 = "[id : 1]";
       // la poste v2
       private final String s2310 = "[id : 1, id : 2, id : 3]";
      
       public ThreadConnectionSimult(String login, String passwd, int idCustomer) {
       this.login = login;
       this.passwd = passwd;
       this.idCustomer = idCustomer;
       this.b = new BusinessDelegate(login, passwd);
       this.jobsSession = (JobsTypesSession) b.getEjb(JobsTypesSession.class.getSimpleName());
      
       }
      
       @Override
       public void run() {
       String comp = new String();
       String result = new String();
       // a refaire pour utiliser les String avec des IF donc.
       switch (this.idCustomer) {
       case 55:
       comp = this.s55;
       break;
       case 57:
       comp = this.s57;
       break;
       case 1073:
       comp = this.s1073;
       break;
       case 294:
       comp = this.s294;
       break;
       case 1586:
       comp = this.s1586;
       break;
       case 1588:
       comp = this.s1588;
       break;
       case 1900:
       comp = this.s1900;
       break;
       case 1996:
       comp = this.s1996;
       case 2310:
       comp = this.s2310;
       break;
       }
      
       result = this.jobsSession.getTypesList().toString();
      // this.b.logout();
       // System.out.println("idCustomer : " + this.idCustomer + ", result : " + result);
       if (comp.equals(result)) {
       System.out.println(this.login + " : OK");
       } else {
       System.out.println(this.login + " : ERROR : " + result + ", comp : " + comp);
       }
       }
      


      I know that the thread code is not great, but the aim is to test the results.

      when I launch my test with many threads with one user, the result is ok. But when I try with many users, like above (users), my results are reversed. My first client retrieves the results of the second client, whereas on the server, the results are ok, incomprehensible.

      My conf file client :
      client-masterServices {
       org.jboss.security.ClientLoginModule required
       multi-threaded=true;
      };
      


      When I use "multi-threaded=true", I have always one error of Authentication failure. Without that, I don't have error anymore.
      The LoginContext.logout seems doing nothing.
      I tried to use the password-stacking=useFirstPast, but with that, nothing works.

      So I would want understand how that works, then above all that my multiples clients can log to my server JBoss, because this one is a simulation, but my clients is a tomcat server standalone using my business delegate. Today, there is no problem, because we don't have many simultaneous connections yet, but that will become it.

      Sorry for my poor english.
      Regards,
      J. Bordeau.