views:

56

answers:

2

Hi everyone!

I'm trying to get a scheduler working in JBoss as 5.

So far, I've created my own MBean (it works) and I created my scheduler like this:

<mbean code="org.jboss.varia.scheduler.Scheduler"
          name=":service=Scheduler,name=SchedulableMBeanExample">
  <depends>user:service=Print</depends>
  <attribute name="StartAtStartup">true</attribute>
  <attribute name="SchedulableMBean">user:service=Print</attribute>
  <attribute name="SchedulableMBeanMethod">print(java.lang.String)</attribute>
  <attribute name="InitialStartDate">NOW</attribute>
  <attribute name="SchedulePeriod">10000</attribute>
  <attribute name="InitialRepetitions">10</attribute>
  <attribute name="FixedRate">true</attribute></mbean>

It works, but the main question is how can I specify the string I want to pass as an argument to my method?

I've searched but the only closer thing I've found is this attribute : "SchedulableArguments" but this works only for the constructor.

Thanks for your help guys.

Laurent.

A: 

After installing an MBean in JBoss you can configure MBean parameters by JBoss jmx-console a web interface to configure JBoss.

See this article from JBoss wiki: ExampleHelloWorldService

Daniel Murygin
A: 

You're halfway there; you've got the right attribute -- SchedulableMBeanMethod -- which allows a list of parameters, but only specific ones. According to the jboss 4 guide, your options for parameters are:

  • NOTIFICATION which will be replaced by the timers notification instance (javax.management.Notification)

  • DATE which will be replaced by the date of the notification call (java.util.Date)

  • REPETITIONS which will be replaced by the number of remaining repetitions (long)

  • SCHEDULER_NAME which will be replaced by the ObjectName of the Scheduler

  • Any fully qualified class name which the Scheduler will set to null.

    If you need to pass anything else, I think your best bet is to add a method to your mbean just to calculate & pass parameters to your working function.

Guessing that you want to print the current date, you might set:

  <attribute name="SchedulableMBeanMethod">scheduledPrint(DATE)</attribute>

And define scheduledPrint to format a date string and call your print method.

pra