Thanks Romain for the hints!
I have done this now in quick and dirty way like this:
@Startup @Singleton
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@Lock(LockType.READ)
public class SchedulerWorkerManagerSchedule {
@Inject
SchedulerWorkerManager schedulerWorkerManager;
@Schedule(second = "*/20", minute = "*", hour = "*", info = "Every
20 seconds") @Lock(LockType.WRITE)
public void manageSchedulerWorkers() {
schedulerWorkerManager.manageSchedulerWorkers();
}
}
In WorkerManager implementations removed all the EJB stuff and, voila,
it works!
br
reinis
On 22.07.2013 10:33, Romain Manni-Bucau wrote:
hehe, that's a point of view ;)
you have another alternative: use xml to configure your @Schedule only on
the activated EJB. Not perfect since you'll configure it "twice" (once for
the timer, once for the CDI bean) but it works.
*Romain Manni-Bucau*
*Twitter: @rmannibucau <https://twitter.com/rmannibucau>*
*Blog: **http://rmannibucau.wordpress.com/*<http://rmannibucau.wordpress.com/>
*LinkedIn: **http://fr.linkedin.com/in/rmannibucau*
*Github: https://github.com/rmannibucau*
2013/7/22 Reinis Vicups <[email protected]>
Ok that is what I was afraid about.
And, Romain, it is not normal - it is due to still missing alignment
between cdi and ejb :D
For those of you reading this question some times later: the "hack" I will
make is to have only one EJB (facade) and in that EJB inject @Default or
@Alternative implementation based on beans.xml config.
br
reinis
On 22.07.2013 10:07, Romain Manni-Bucau wrote:
Hi,
@Schedule is an EJB feature not a CDI one so @Alternative is not used here
(so it sounds normal for me).
*Romain Manni-Bucau*
*Twitter: @rmannibucau
<https://twitter.com/**rmannibucau<https://twitter.com/rmannibucau>
*
*Blog:
**http://rmannibucau.**wordpress.com/*<http://rmannibucau.wordpress.com/*>
<http://**rmannibucau.wordpress.com/ <http://rmannibucau.wordpress.com/>>
*LinkedIn:
**http://fr.linkedin.com/in/**rmannibucau*<http://fr.linkedin.com/in/rmannibucau*>
*Github: https://github.com/**rmannibucau*<https://github.com/rmannibucau*>
2013/7/22 Reinis Vicups <[email protected]>
Hi,
I have two implementations of some SchedulerWorkerManager:
//ALTERNATIVE!
@Startup @Singleton @TransactionAttribute(****
TransactionAttributeType.NOT_*
*SUPPORTED) @Lock(LockType.READ) @Alternative
public class AzureSchedulerWorkerManager implements
SchedulerWorkerManager
{
@Override
@Schedule(second = "*/20", minute = "*", hour = "*", info = "Every
20
seconds")
@Lock(LockType.WRITE)
public void manageSchedulerWorkers() {}
}
AND
//DEFAULT!
@Startup @Singleton @TransactionAttribute(****
TransactionAttributeType.NOT_*
*SUPPORTED) @Lock(LockType.READ) @Default
public class BasicSchedulerWorkerManager implements
SchedulerWorkerManager
{
@Override
@Schedule(second = "*/5", minute = "*", hour = "*", info = "Every 5
seconds")
@Lock(LockType.WRITE)
public void manageSchedulerWorkers() {}
}
I just noticed that despite AzureSchedulerWorkerManager is annotated as
being @Alternative it is still "ticking".
Thank you, guys, for hints on how to configure them both properly.
br
reinis