2

我正在尝试让调度程序在 JBoss 中工作为 5。

到目前为止,我已经创建了自己的 MBean(它可以工作),并且我创建了这样的调度程序:

<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>

它有效,但主要问题是如何指定要作为参数传递给我的方法的字符串?

我已经搜索过,但我发现的唯一更接近的是这个属性:“SchedulableArguments”,但这仅适用于构造函数。

谢谢你们的帮助。

劳伦特。

4

2 回答 2

0

你已经成功了一半;你有正确的属性 -- SchedulableMBeanMethod-- 它允许参数列表,但只有特定的。根据jboss 4 guide,您的参数选项是:

  • NOTIFICATION 将被计时器通知实例 (javax.management.Notification) 替换

  • DATE 将替换为通知调用的日期 (java.util.Date)

  • REPETITIONS 将替换为剩余重复次数(长)

  • SCHEDULER_NAME 将被调度程序的 ObjectName 替换

  • 调度程序将设置为 null 的任何完全限定的类名。

    如果您需要传递其他任何东西,我认为您最好的选择是向您的 mbean 添加一个方法,只是为了计算并将参数传递给您的工作函数。

猜测您要打印当前日期,您可以设置:

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

并定义scheduledPrint格式化日期字符串并调用您的print方法。

于 2010-07-15T20:39:01.487 回答
0

在 JBoss 中安装 MBean 后,您可以通过 JBoss jmx-console 配置 MBean 参数来配置 JBoss。

请参阅 JBoss wiki 中的这篇文章:ExampleHelloWorldService

于 2010-07-15T10:40:48.870 回答