0 Replies Latest reply on Mar 27, 2007 6:13 AM by momo0

    When/where to create TopicConnection objects in a stateless

    momo0 Newbie

      Our configuration:
      - We installed JBoss jboss-4.0.5.GA
      - we use stateless SBs, MDBs, and JMX services
      - JMS producers are one of our stateless SB and our JMX services
      - JMS consumers are our MDBs and our JMX services.

      The context:
      In most of the methods of one of our session beans, we need to publish JMS messages. Considering that TopicConnection creation is expensive, I first added a TopicConnection member to the sessionBean. I created and started the TopicConnection during the @PostConstruct method, and closed it in the @PreDestroy method.


      The problem:
      - Session beans are pooled components, so if 100 of them are in the pool, they all have an established connection on port 8093. That?s already not good. (100 is the default ?MaximumSize? for ?Standard Stateless SessionBean? in standardjboss.xml)
      - Furthermore, it seems to have an impact on the pooling of the session bean, because I get more than 200 instances of the session bean, and it just keep on growing with normal load of our application. Of course the number of established connections on port 8093 grows as well.

      My solutions (work around)
      - (1) I create and start a TopicConnection instance every time I need to send a message in the SB. This way I have few established connections on port 8093. A (good) side effect is that there are less instances of the session bean in JBoss (about 40, and stable with normal load of our application).
      - (2) I change the setting in standardjboss.xml in order to have 10 for the ?MaximumSize? of ?Standard Stateless SessionBean. I added also strictMaximumSize setting with true value. The number of the stateless SB and the number of the established connection on port 8093 is then limited.


      My questions:
      I spent a lot of time testing and looking at the JBoss forum. I still have the following questions:
      - (1) Is it a bad idea to create a TopicConnection member instance per SessionBean instance?
      - (2) Is there a better way to do it? Limiting the stateless SB pool size does not seems a good idea. Creating/starting a connection for every publish message neither.


      Any help is welcome, thanks.

      Frank