1 Reply Latest reply on Jul 21, 2014 10:10 AM by Alex Wursel

    Message driven beans created twice, PostConstruct and PreDestroy not called.

    Alex Wursel Newbie

      Hello there,


      we are migrating from JBoss 4.2.1 to WildFly 8.1.0 Final. So far

      eveything seems to work. The only problem arises with

      message driven beans.


      Here is a short example:



      @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),

              @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/acd-agent-signals"),

              @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "400") }, messageListenerInterface = MessageListener.class)

      public class AgentMessageDistributorBean implements MessageDistributor, MessageListener {



          private int                id;

          private static int         icount         = 0;


          public AgentMessageDistributorBean() {

              this.id = icount++;

              System.out.println("[Constructor called for AgentMessageDistributorBean#" + this.id + "]");





          public void init() {

              System.out.println("[init() called for AgentMessageDistributorBean#" + this.id + "]");







      Basically, it prints out the number of instances everytime the constructor is called.


      The weird part is, that during the startup sequence of WildFly the constructor

      is called 800 times (double the size of maxSession). In my logfile I can see


      2014-07-17 12:35:52,770 INFO  [stdout] (default-threads - 15) [AgentMessageDistributorBean#799]


      But the "PostConstruct"-part ist not called.

      After the server is complety started and the mdb's are used I can see the following lines in my log:



      2014-07-17 12:39:26,526 INFO  [stdout] (Thread-71 (HornetQ-client-global-threads-1183561475)) [Constructor called for AgentMessageDistributorBean#800]

      2014-07-17 12:39:26,530 INFO  [stdout] (Thread-71 (HornetQ-client-global-threads-1183561475)) [init() called for AgentMessageDistributorBean#800]



      My questions are:

      1) Why is the constructor called 800 times ? Why double the amount of maxSession?

      2) What happend to the first 800 instances? I think they should not have been created. Memory leak?

      3) Why doesn't the "PostConstruct"-Method init() get called during startup?

      4) How do I limit the number of concurrent mdb's ? In JBoss 4.2.1. the property "maxSession" did the job.


      Thanks a lot for your help.