0 Replies Latest reply on Feb 25, 2006 5:59 PM by Piotr Kolaczkowski

    Message driven instance pool size dropping to 0.

    Piotr Kolaczkowski Newbie

      We are using Jboss 4.0.3 and we encountered a strange problem.
      We ran our application on a new AMD Opteron 64 machine with Sun jre 1.5.0_06 64 bit installed and noticed problems with MDBs. On the previous machine, there were no such problems. We tried various JVMs of both IBM and SUN, both 32bit and 64bit and results were always the same. :(

      Our application has many queues, the two most important are the queue for incoming messages and a queue for outgoing ones. The system process SMS messages. Both queues are associated with very similar MDB's. But after some time, the size of a pool of outgoing queue MDBs, drops while the size of the other pool does not. After startup it is usually about 12-15, then it drops until it reaches 0. The MinimumSize for a pool in jboss configuration is set to 5, and the MaximumSize is set to 100.

      We are not able to stop jboss normally because it probably hangs in state of destroying the problematic MDB. It also claims that some transactions have timed out, but it gives only their numbers and nothing more informational.
      From the logs we can tell the system doesn't hang inside the onMessage function (each 'onMessage: called' is followed by '>>>>>> Sent sms...').

      There is also some other code in the application that accesses the outbound queue using a selector and it hasn't got any problems with reading messages from it.

      The both queues are persisted by PostgreSQL 8.0.7.

      The code for MDB is here:

      /**
       * @ejb.bean
       * name="MessageSenderBean"
       * jndi-name="MessageSenderHome"
       * local-jndi-name="MessageSenderLocalHome"
       * destination-type="javax.jms.Queue"
       * transaction-type="Container"
       * acknowledge-mode="Auto-acknowledge"
       * message-selector = "channel='async_phone'"
       *
       * @jboss.destination-jndi-name
       * name = "queue/gameserver-OutboundMessage"
       *
       * @ejb.security-role-ref
       * role-link="admin"
       * role-name="admin"
       *
       * @ejb.permission
       * role-name="admin"
       *
       * @ejb.transaction type="Required"
       */
      public class MessageSenderBean implements MessageDrivenBean, MessageListener {
      
       private static Logger logger = Logger.getLogger(MessageSenderBean.class);
      
       private MessageDrivenContext mdContext;
      
      
       /**
       * @param context the context to set
       */
       public void setMessageDrivenContext(MessageDrivenContext context) {
       this.mdContext = context;
       }
      
       public void ejbRemove() {
       }
      
       public void onMessage(Message inMessage) {
      
       logger.debug("onMessage: called.");
      
       if (!(inMessage instanceof ObjectMessage)) {
       mdContext.setRollbackOnly();
       logger.error("onMessage: Message of wrong type: " +
       inMessage.getClass().getName());
       }
      
      
       ObjectMessage messageToSend = (ObjectMessage) inMessage;
      
       String smsc = null;
       String login = null;
       String url = null;
       String senderClassName = null;
       TextMessage message = null;
      
       try {
      
       logger.debug("onMessage: #0");
      
       message = (TextMessage) messageToSend.getObject();
      
       logger.debug("onMessage: #1");
      
       String text = message.getText();
       String to = message.getTerminalId();
       String from = (String)message.getAttribute(RequestContext.SERVICE_NUMBER);
       String password = (String)message.getAttribute(RequestContext.CONNECTOR_PASSWORD);
       String requestId = (String)message.getAttribute(RequestContext.REQUEST_ID);
      
       smsc = (String)message.getAttribute(RequestContext.SMSC);
       login = (String)message.getAttribute(RequestContext.CONNECTOR_LOGIN);
       url = (String)message.getAttribute(RequestContext.CONNECTOR_URL);
       senderClassName = (String)message.getAttribute(RequestContext.CONNECTOR_CLASS);
      
       ISmsSender sender;
       try {
       sender = (ISmsSender)Class.forName(senderClassName).newInstance();
       } catch (Exception e) {
       logger.error("onMessage: Cannot send message - problem instantiating connector: "
      + e.getMessage());
       return;
       }
       logger.debug("onMessage: #2");
       sender.setLogin(login);
       sender.setPassword(password);
       sender.setUrl(url);
       sender.setSmsc(smsc);
       sender.sendSms(from, to, requestId, text);
      
       logger.info("onMessage: >>>>>>>>>> Sent sms to " + to + " with text '" + text + "'.");
      
       } catch ( JMSException e) {
       logger.error("onMessage: JMSException: " + e);
       mdContext.setRollbackOnly();
       } catch (SmsSenderException e) {
      
       logger.error("onMessage: Connector couldn't send message: " +
       "\n\t\tsmsc = " + smsc +
       "\n\t\tlogin = " + login +
       "\n\t\tsender class = " + senderClassName +
       "\n\t\turl = " + url);
       mdContext.setRollbackOnly();
       }
       }
      
       public void ejbCreate() {}
       public void ejbActivate() {}
       public void ejbPassivate() {}
      }
      


      Please help us debugging the problem. Where should we search, what should we try? Is it a bug in our configuration? Why it worked on the old machine (the slower one)? It worked even on 3 other 32-bit Intel machines. Can it be DBMS-related problem? Why the other MDB's are ok? We used PostgreSQL 7.4.9 before. We can send some more files if needed to solve the problem.