Uploaded image for project: 'JBoss Enterprise Application Platform 4 and 5'
  1. JBoss Enterprise Application Platform 4 and 5
  2. JBPAPP-1636

Port [JBAS-6400] - ExecutionContext returns the trasnaction timeout in seconds, but we use that argument to schedule the thread that is in milliseconds.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 4.2.0.GA_CP05, 4.3.0.GA_CP03, 4.3.0.GA_CP03_FP01
    • None
    • None
    • Release Notes
    • Hide

      When specifying transaction timout, assume the transaction is in milliseconds. So if you want 6 seconds, specify 6000 for your transaction timeout when using the custom adapter.

      Show
      When specifying transaction timout, assume the transaction is in milliseconds. So if you want 6 seconds, specify 6000 for your transaction timeout when using the custom adapter.

    Description

      PLEASE NOTE: THIS ONLY AFFECTS 3RD PARTY ADAPTERS RUNNING INSIDE THE JBOSS APP SERVER. THIS DOES NOT AFFECT ANY OF THE ADAPTERS THAT JBOSS SHIPS WITH.

      The implementing adapter handles scheduling work to be performed. So they usually do something like..

      WorkManager wm = adapter.ctx.getWorkManager();
      TestWork work = new Somework();
      ExecutionContext ec = new ExecutionContext();
      ...
      ec.TransactionTimeout(trans.getTimeout())
      wm.doWork(work, 0l, ec, null);

      Usually the work class schedules the work by telling the WorkManager to do some work(dowork). If you don't specify a timeout in the execution context, the thread will wait indefinilty to finish the work. In our adapters(JMS, MAIL), I don't see where we ever set a timout in the ExecutionContext. So we will never run into the but I'm getting ready to describe.

      The ExecutionContext, is required to express the timeout in seconds(not milliseconds). http://java.sun.com/j2ee/1.4/docs/api/javax/resource/spi/work/ExecutionContext.html

      The org.jboss.resource.work.WorkWrapper(implements Task) is the task that gets passed to the thread pool. It implements getCompletionTimeout. getCompletionTimeout on the task is in milliseconds. You can see by the following method we pass the executionContext.getTransactionTimeout() as the completion time for the task. So we go from seconds to milliseconds.

      public long getCompletionTimeout()

      { return executionContext.getTransactionTimeout(); }

      This means that if you initially have a timeout as 6 seconds, it will be passed to the thread pool as 6 milliseconds.

      to move further down the stack(skipping a few layers ), you can see that in BasicThreadPool, you can see that we pass the timeout into the runTaskWrapper method, which constructs the TimeoutInfo Object.

      long completionTimeout = wrapper.getTaskCompletionTimeout();
      TimeoutInfo info = null;
      if( completionTimeout > 0 )

      { checkTimeoutMonitor(); // Install the task in the info = new TimeoutInfo(wrapper, completionTimeout); tasksWithTimeouts.insert(info); }

      then in the TimeoutInfo constructor we set the timout time in milliseconds...

      TimeoutInfo(TaskWrapper wrapper, long timeout)

      { this.start = System.currentTimeMillis(); this.timeoutMS = start + timeout; this.wrapper = wrapper; }

      What we should do to fix this is inside the org.jboss.resource.work.WorkWrapper

      public long getCompletionTimeout()

      { //get completionTimout on the task is in milliseconds. We need to convert. return executionContext.getTransactionTimeout()*1000; }

      Attachments

        Issue Links

          Activity

            People

              rhn-support-jhowell William Howell
              rhn-support-jhowell William Howell
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: