1 Reply Latest reply on Sep 3, 2008 12:35 PM by Alexey Semenov

    message recovery takes too long on jboss 4.0.5

    Alexey Semenov Newbie

      Hi All!

      I use JBoss 4.0.5 and MaxDB to store JMS queues. To put a long story short, when there are too many messages in the queues, I see the following:

      2008-08-28 13:34:42,538 WARN [org.jboss.tm.TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=GMLXD187/15, BranchQual=, localId=15] timed out. status=STATUS_ACTIVE
      2008-08-28 13:34:43,038 ERROR [org.jboss.resource.adapter.jdbc.xa.XAManagedConnectionFactory] End transaction failed for XAResource
      javax.transaction.xa.XAException
       at com.sap.dbtech.jdbcext.XAConnectionSapDB.xaerror(XAConnectionSapDB.java:442)
       at com.sap.dbtech.jdbcext.XAConnectionSapDB.end(XAConnectionSapDB.java:199)
      


      (The excerpts from my config files will be at the end of the post)

      When starting, JBoss attempts to load all messages from JMS_MESSAGES into memory, which takes longer than transaction timeout. So, the transaction rolls back and the queue fails to initialize.

      I have the following ideas.

      - Increase xa-resource-timeout on my XA DS, or set the RecoveryTimeout attribute value of the persistence manager
      to something sufficiently big. But the first is dirty, and setting RecoveryTimeout doesn't affect the XA timeout :-(

      - Configure chunked messages loading, as in JBAS-1336 - for some reason, this does not work for me either. It really retrieves keys first and keys+blobs then, and at this point the usual transaction timeout occurs.

      - Apply some size constrainst to MemoryCache - not sure that this will ever work, at least for me doesn't, as I have not a OutOfMemoryError, but it's the transaction which times out.

      So, could anyone please point me in the right direction?

      Here go excerpts from my configs.
      deploy-hasingleton/maxdb-jdbc-service.xml:
      ...
       <mbean code="org.jboss.mq.server.jmx.DestinationManager" name="jboss.mq:service=DestinationManager">
       <depends optional-attribute-name="MessageCache">jboss.mq:service=MessageCache</depends>
       <depends optional-attribute-name="PersistenceManager">jboss.mq:service=PersistenceManager</depends>
       <depends optional-attribute-name="StateManager">jboss.mq:service=StateManager</depends>
       </mbean>
      ...
       <mbean code="org.jboss.mq.server.MessageCache"
       name="jboss.mq:service=MessageCache">
       <attribute name="HighMemoryMark">50</attribute>
       <attribute name="MaxMemoryMark">60</attribute>
       <attribute name="CacheStore">jboss.mq:service=PersistenceManager</attribute>
       </mbean>
      ...
       <mbean code="org.jboss.mq.pm.jdbc2.PersistenceManager"
       name="jboss.mq:service=PersistenceManager">
       <depends optional-attribute-name="ConnectionManager">jboss.jca:service=DataSourceBinding,name=JmsXADS</depends>
      
       <attribute name="RecoveryTimeout">300</attribute>
       <attribute name="RecoveryRetries">2</attribute>
      
       <attribute name="SqlProperties">
       BLOB_TYPE=BYTES_BLOB
       INSERT_TX = INSERT INTO JMS_TRANSACTIONS (TXID) values(?)
       INSERT_MESSAGE = INSERT INTO JMS_MESSAGES (MESSAGEID, DESTINATION, MESSAGEBLOB, TXID, TXOP) VALUES(?,?,?,?,?)
       SELECT_ALL_UNCOMMITED_TXS = SELECT TXID FROM JMS_TRANSACTIONS
       SELECT_MAX_TX = SELECT MAX(TXID) FROM JMS_MESSAGES
       SELECT_MESSAGES_IN_DEST = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE DESTINATION=?
      
       SELECT_MESSAGE_KEYS_IN_DEST = SELECT MESSAGEID FROM JMS_MESSAGES WHERE DESTINATION=?
      
       SELECT_MESSAGE = SELECT MESSAGEID, MESSAGEBLOB FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=?
       MARK_MESSAGE = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE MESSAGEID=? AND DESTINATION=?
       UPDATE_MESSAGE = UPDATE JMS_MESSAGES SET MESSAGEBLOB=? WHERE MESSAGEID=? AND DESTINATION=?
       UPDATE_MARKED_MESSAGES = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE TXOP=?
       UPDATE_MARKED_MESSAGES_WITH_TX = UPDATE JMS_MESSAGES SET TXID=?, TXOP=? WHERE TXOP=? AND TXID=?
       DELETE_MARKED_MESSAGES_WITH_TX = DELETE FROM JMS_MESSAGES WHERE TXOP=? AND JMS_MESSAGES.TXID IN (SELECT TXID FROM JMS_TRANSACTIONS)
       DELETE_TX = DELETE FROM JMS_TRANSACTIONS WHERE TXID = ?
       DELETE_MARKED_MESSAGES = DELETE FROM JMS_MESSAGES WHERE TXID=? AND TXOP=?
       DELETE_TEMPORARY_MESSAGES = DELETE FROM JMS_MESSAGES WHERE TXOP='T'
       DELETE_MESSAGE = DELETE FROM JMS_MESSAGES WHERE MESSAGEID=? AND DESTINATION=?
       CREATE_MESSAGE_TABLE = CREATE TABLE JMS_MESSAGES ( MESSAGEID INTEGER NOT NULL, \
       DESTINATION VARCHAR(150) ASCII NOT NULL, TXID INTEGER, TXOP CHAR(1) ASCII, \
       MESSAGEBLOB LONG BYTE, PRIMARY KEY (MESSAGEID, DESTINATION) )
       CREATE_IDX_MESSAGE_TXOP_TXID = CREATE INDEX JMS_MESSAGES_TXOP_TXID ON JMS_MESSAGES (TXOP, TXID)
       CREATE_IDX_MESSAGE_DESTINATION = CREATE INDEX JMS_MESSAGES_DESTINATION ON JMS_MESSAGES (DESTINATION)
       CREATE_TX_TABLE = CREATE TABLE JMS_TRANSACTIONS ( TXID INTEGER, PRIMARY KEY (TXID) )
       CREATE_TABLES_ON_STARTUP = TRUE
       </attribute>
       <!-- <attribute name="RecoverMessagesChunk">1</attribute> -->
       <!-- note also SELECT_MESSAGE_KEYS_IN_DEST query required when chunking enabled -->
       </mbean>
      


      deploy/jms-ds.xml:
      <xa-datasource>
       <jndi-name>JmsXADS</jndi-name>
       <track-connection-by-tx>true</track-connection-by-tx>
       <xa-datasource-class>com.sap.dbtech.jdbcext.XADataSourceSapDB</xa-datasource-class>
       <xa-datasource-property name="ServerName">localhost</xa-datasource-property>
       <xa-datasource-property name="DatabaseName">LOC-520</xa-datasource-property>
       <xa-datasource-property name="User">JMS</xa-datasource-property>
       <xa-datasource-property name="Password">JMS</xa-datasource-property>
       <type-mapping>SapDB</type-mapping>
       <xa-resource-timeout>300</xa-resource-timeout>
       </xa-datasource>
      


      Thanks in advance,
      Alexey