1 Reply Latest reply on Oct 17, 2007 4:17 PM by jfrankman

    How to avoid transaction Timeouts for long running MDB

    jfrankman Novice

      If I have a single SLSB with method A and Method B which are called sequentially (first A then B) by a MDB how do I keep Method B from getting a transaction timeout error when method A takes a very long time to complete?

      I have a MDB which firsts downloads some files from a FTP site and processes the files. The download can take several minutes depending upon the size of the file and the network speed. Once the download is complete I use hibernate to read the contents of the text file downloaded from the FTP site. The problem I am having is that after 5 minutes or so while the file is still downloading I get:

      16:55:48,266 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=fbmis011/19, BranchQual=, localId=19] timed out. status=STATUS_ACTIVE

      At first I tried to up the timeout limit, by using

      "@TransactionTimeout(1800)" on the MDB. However, this is a poor workaround since a download could take a very long time depending upon the size of the file. What I would like to do is not have the transaction begin until after the download has completed. Both the download and the hibernate query happen in the same SLSB. Despite my efforts, I still get a transaction time out error in the method that uses hibernate to query the file (getIndexFileDetailRecords()). Here is my code in its current state:


      @MessageDriven(activationConfig =
      public class KeyBankCheckImagesMessageHandler implements MessageListener{
       @In(create=true) KeyBankServices keybankServices;
       public void onMessage (Message msg) {
       MapMessage mapMessage=(MapMessage)msg;
       try {
       System.out.println("process checks.");
       InitialContext ctx = new InitialContext();
       //JNDI tests. I settled with using the jboss-services.xml, but the SystemPropertiesService could have been used.
       //String text = (String) ctx.lookup("keybankchecks/path");
       //SystemPropertiesService abc = new SystemPropertiesService();
       try {
       } catch (Exception e) {
       catch (NamingException e) {

      Here is the SLSB with the method that times out (getIndexFileDetailRecords()).

      public class KeyBankServicesImpl implements KeyBankServices
       private EntityManager em;
       private KeyBankConfiguration keyBankConfig;
       //private File batchDirectory;
       private static Logger logger;
       //private Log logger;
       private static final String DOWNLOADING="downloading_";
       public KeyBankServicesImpl()
       public void init()
       System.setProperty("line.separator", "\r\n");
       //enable logger
       logger.info("KeyBankServicesImpl class instantiated.");
       try {
       keyBankConfig=new KeyBankConfiguration();
       } catch (NamingException e) {
       logger.info("KeyBankServicesImpl configuration:" + keyBankConfig);
       public void downloadKeyBankFiles()
       public void processKeyBankFiles()
       private Collection<IndexDetail> getIndexFileDetailRecords()
       Collection<IndexDetail> returnCollection;
       String query = "from IndexDetail";
       Query hqlQuery =em.createQuery(query);
       returnCollection =hqlQuery.getResultList();
       return returnCollection;

      Any help would be appreciated.