Clarification: @Clustered and EJB timers

66 views
Skip to first unread message

Matthias Jeschke

unread,
Apr 13, 2021, 2:08:31 AM4/13/21
to payara...@googlegroups.com
Hi,

I'm not quite sure how to understand the paragraph about @Clustered and EJB timers:

Persistent EJB Timers (which are the default) will work correctly with clustered singletons since they will only be executed in a single node of the cluster

Does this mean that when I annotate a bean with @Clustered and this bean has a method annotated with @Scheduled, that I get a single cluster-wide bean but the scheduled task is always only executed on a single instance and when this instance goes down no other instance will execute the task?

What I'm trying to do is to have only one instance in a cluster (deployment group) executing a scheduled task, however, any instance should be able to perform it. If one instance executed this task the last time and goes down, then another instance should pick it up and execute it.

From reading the Payara documentation I would assume that this could be done with a (Payara 5) deployment group, but not with a (Payara 4) cluster?

Are there any other suggestions how to do this? I've looked at Quartz in cluster mode, but if possible I would like to stay inside Java EE.

Best regards

Matthias

Lenny Primak

unread,
Apr 13, 2021, 4:43:27 PM4/13/21
to Payara Forum
EJB timers work the same way whether the class is annotated with @Clustered or not.
So, as I understand your case, if the node goes down, another node will execute the EJB timer correctly.
This should work the same whether in (deprecated) clusters or deployment groups.

Matthias Jeschke

unread,
Apr 14, 2021, 1:41:09 AM4/14/21
to Payara Forum
Hi,

I've tested this with Payara 4: the persistent timer is created for one node but not migrated to another when the first one goes down.

I've tested @Clustered, @Singleton and @Scheduled yesterday with a cluster setup (no deployment group) on Payara 5, the timer (owner) was migrated correctly. Today I'll check this again without the @Clustered annotation.

--
You received this message because you are subscribed to the Google Groups "Payara Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to payara-forum...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/payara-forum/5511b7f3-5bcc-45ba-9a6c-146cf2f1c4b7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages