3 Replies Latest reply on Oct 1, 2013 9:24 AM by aqtwrdnr aqtwrdnr

    Can EJB Timers be managed via CLI?

    Steven Boscarine Apprentice

      Hello,

      I have an application that uses Quartz that I am porting to EAP6 (AS 7.1.1).  I am evaluating EJB Timers as an alternative.  Can the schedules be configured via CLI or are they static?

       

      Looking at http://docs.oracle.com/javaee/6/tutorial/doc/bnboy.html ...if I declare a method to run every 3 minutes with :

       

       

      @Schedule(minute="*/3", hour="*")
          public void automaticTimeout() {
              this.setLastAutomaticTimeout(new Date());
              logger.info("Automatic timeout occured");
          }
      

       

      Can an advanced user override the schedule in CLI and set it to every 10 minutes?

       

      Thanks,
      Steven

        • 1. Re: Can EJB Timers be managed via CLI?
          Stan Silvert Master

          Theoretically, it can be done in AS7.2 because acces to the "timers" attribute is provided.  But to do this, the write-attribute command is really complicated so I used CLI GUI to automatically create the syntax for me:

           

          /deployment=InjectionTest.war/subsystem=ejb3/stateless-session-bean=SimpleEJB/:write-attribute(name=timers,value=["{\"time-remaining\" => 77621L,\"next-timeout\" => 1352487600000L,\"calendar-timer\" => true,\"persistent\" => true,\"schedule\" => {\"year\" => \"*\",\"month\" => \"*\",\"day-of-month\" => \"*\",\"day-of-week\" => \"*\",\"hour\" => \"*\",\"minute\" => \"*/4\",\"second\" => \"0\",\"timezone\" => undefined,\"start\" => undefined,\"end\" => undefined}}"])
          

           

          The result was just a "null".  I'm not sure if that was a CLI GUI bug or a server bug, but I'm guessing it was the former.

           

          Then I tried to cut and paste the command into regular CLI.  I removed all the escapes for the quotes (\").  Here is what that looked like:

           

          [standalone@localhost:9999 /] /deployment=InjectionTest.war/subsystem=ejb3/stateless-session-bean=SimpleEJB/:write-attribute(name=timers,value=["{"time-remaining" => 7762
          1L,"next-timeout" => 1352487600000L,"calendar-timer" => true,"persistent" => true,"schedule" => {"year" => "*","month" => "*","day-of-month" => "*","day-of-week" => "*","
          hour" => "*","minute" => "*/4","second" => "0","timezone" => undefined,"start" => undefined,"end" => undefined}}"])
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          jreadline: can't redirect to more than one file.
          java.lang.ExceptionInInitializerError
                  at org.jboss.jreadline.console.Console.persistRedirection(Console.java:1344)
                  at org.jboss.jreadline.console.Console.parseCurrentOperation(Console.java:1180)
                  at org.jboss.jreadline.console.Console.parseCurrentOperation(Console.java:1191)
                  at org.jboss.jreadline.console.Console.parseCurrentOperation(Console.java:1191)
          

           

          Again, I'm not sure where the real error is.  This one could be an error in jreadline or just an error in my syntax.

           

          Once over the hurdle of getting CLI/CLI GUI to accept my command, there is still some doubt in my mind that the write-attribute operation is equipped to handle the operation.  So how's that for a definite "maybe"?

           

          Stan

          • 2. Re: Can EJB Timers be managed via CLI?
            Steven Boscarine Apprentice

            Hello Stan,

            That is helpful.  However, we do have one complication...our customers insist on paying RedHat   All deployments have to be on an EAP release, but it will be a few months before we complete our port.

             

            I'll try out that syntax and see what happens on EAP6.

             

            Thanks!

            Steven

            • 3. Re: Can EJB Timers be managed via CLI?
              aqtwrdnr aqtwrdnr Newbie

              I have tested this, but jboss-cli.sh fails with the following error message:

               

              {

                  "outcome" => "failed",

                  "failure-description" => "JBAS014639: Attribute timers is not writable",

                  "rolled-back" => true

              }

               

              I've started another question about it here.