如何在一个节点和全部的群集中运行计划方法? [英] How to run a Scheduled Method in a Cluster for one Node and for All?

查看:119
本文介绍了如何在一个节点和全部的群集中运行计划方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Glassfish 3.1.2在一个集群和一个EJB 3.1应用程序中运行。在我的应用程序中我需要两种计划方法:




  • 一种每天只运行一次(在单个节点上) / li>
  • 和所有节点上运行的其他类型(每1-2分钟) - 他们不需要运行syncron方式!这个要求只是在每个节点上运行。



我不知道如何从这个集群开始 - 问题是这是可能用 @Schedule (以及如何)或需要其他东西?

解决方案

我遇到完全相同的问题(需要一个集群计时器和一个每个节点计时器),并遇到这个题。所以,对于任何有兴趣的人:



如果你使用@Schedule(...,persistent = true)声明定时器,你将得到一个集群定时器存储在定时器db(可以迁移)中



如果您使用@Schedule(...,persistent = false)声明定时器),您将得到一个不存储在定时器db(不能迁移)的节点定时器


I have a Glassfish 3.1.2 that runs in a cluster and a EJB 3.1 application. And I need two kind of Scheduled Methods in my application:

  • one kind that runs only once (on a single node) once a day
  • and other kind that runs on all nodes (every 1-2 Minutes) -- They do NOT need to run a syncron way! The requirement is just that this kind run on every node.

I have no clue how to start with this cluster - problem, is this possible with @Schedule (and how) or do I need something else?

解决方案

I faced the exact same issue (need one cluster timer and a per node timer) and came across this question. So, for anyone interested:

If you declare the timer with @Schedule(..., persistent=true), you will get a cluster timer stored in the timer db (which can be migrated)

If you declare the timer with @Schedule(..., persistent=false), you will get a node timer not stored in the timer db (which can't be migrated)

这篇关于如何在一个节点和全部的群集中运行计划方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆