2 Replies Latest reply on Jun 21, 2007 5:37 PM by Saeed Kabiri

    MDB creates itself several times

    Gilcesar Avila Newbie

      When a jms client send several messages for the MDB in JBoss, this MDB creates itself several times.

      @MessageDriven(mappedName = "jms/Server", activationConfig = {
      @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
      @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
      })

      /**Server class*/
      public class Server implements MessageListener {
      public Server() {
      System.out.println("INITIALIZED SERVER!");
      }
      public void onMessage(Message message) {
      System.out.println("Message arrived");
      }
      }

      /**Client class*/

      public class Client {
      ...
      public Client() {
      try {
      ...
      QueueSender sender = queSession.createSender(queue);
      TextMessage message = session.createTextMessage("HELLO");
      ...
      //In this point the client sends several messages
      for(int i=0; i<10; i++){
      sender.send(message);
      }
      }catch(Exception ex){System.out.println(ex.getMessage());}
      }
      public static void main(String args[]){
      new Client();
      }
      }

      The jboss logger show this:

      11:11:16,372 INFO [STDOUT] INITIALIZED SERVER!
      11:11:16,382 INFO [STDOUT] INITIALIZED SERVER!
      11:11:16,382 INFO [STDOUT] Message arrived
      11:11:16,382 INFO [STDOUT] INITIALIZED SERVER!
      11:11:16,382 INFO [STDOUT] Message arrived
      11:11:16,382 INFO [STDOUT] INITIALIZED SERVER!
      11:11:16,382 INFO [STDOUT] Message arrived
      11:11:16,382 INFO [STDOUT] INITIALIZED SERVER!
      11:11:16,382 INFO [STDOUT] Message arrived
      11:11:16,392 INFO [STDOUT] Message arrived
      11:11:16,392 INFO [STDOUT] INITIALIZED SERVER!
      11:11:16,392 INFO [STDOUT] Message arrived
      11:11:16,392 INFO [STDOUT] INITIALIZED SERVER!
      11:11:16,392 INFO [STDOUT] Message arrived
      11:11:16,432 INFO [STDOUT] Message arrived
      11:11:16,432 INFO [STDOUT] Message arrived
      11:11:16,493 INFO [STDOUT] Message arrived