title: Timer Service in ejb 3.1 - schedule calling timeout issue
body: <p>I have created simple example with @Singleton, @Schedule and @Timeout annotations to try if they would solve my problem.</p>
  
  <p>The scenario is this: EJB calls 'check' function every 5 secconds, and if certain conditions are met it will create single action timer that would invoke some long running process in asynchronous fashion. (it's sort of queue implementation type of thing). It then continues to check, but while the long running process is there it won't start another one.</p>
  
  <p>Below is the code I came up with, but this solution does not work, because it looks like asynchronous call I'm making is in fact blocking my @Schedule method.</p>
  
  <pre><code>@Singleton
  @Startup
  public class GenerationQueue {
  
      private Logger logger = Logger.getLogger(GenerationQueue.class.getName());
  
      private List&lt;String&gt; queue = new ArrayList&lt;String&gt;();
  
      private boolean available = true;
  
      @Resource
      TimerService timerService;
  
      @Schedule(persistent=true, minute="*", second="*/5", hour="*")
      public void checkQueueState() {
  
          logger.log(Level.INFO,"Queue state check: "+available+" size: "+queue.size()+", "+new Date());
  
          if (available) {
  
              timerService.createSingleActionTimer(new Date(), new TimerConfig(null, false));
          }
  
      }
  
      @Timeout
      private void generateReport(Timer timer) {
  
          logger.info("!!--timeout invoked here "+new Date());
  
          available = false;
  
          try {
  
              Thread.sleep(1000*60*2); // something that lasts for a bit
  
          } catch (Exception e) {}
  
          available = true;
  
          logger.info("New report generation complete");
  
      }
  </code></pre>
  
  <p>What am I missing here or should I try different aproach? Any ideas most welcome :)</p>
  
  <p>Testing with Glassfish 3.0.1 latest build - forgot to mention</p>