There is a problem with timer ID generation (class
org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator) in a clustered environment.
Everything is fine as long as I use for persistence purposes a database per
server in cluster. But if I use a shared database for the whole cluster (which
I find more likely to happen in a production environment), I will have
duplicate IDs generated by this class (and hence will get SQLExceptions when
trying to create a timer).
Hence, I have created a class that produces a "unique" ID for any server in the
cluster and now everything is as it should be.
It may not be the best idea of implementation, but is a fast and simple
solution that produces the expected behaviour.
Therefore I propose the following replacement for
org.jboss.ejb.txtimer.BigIntegerTimerIdGenerator class:
package org.jboss.ejb.txtimer;
|
| import java.math.BigInteger;
| import java.net.InetAddress;
|
| public class BigIntegerTimerIdGenerator implements TimerIdGenerator {
|
| private static BigInteger nextTimerId = BigInteger.valueOf(0);
| private static String offset = "";
| static {
| try {
| offset =
InetAddress.getLocalHost().getHostAddress().replaceAll("\\.", "");
| } catch (Exception ignored) {}
| }
|
| public synchronized String nextTimerId() {
| nextTimerId = nextTimerId.add(BigInteger.valueOf(1));
| return offset + nextTimerId.toString();
| }
| }
View the original post :
http://www.jboss.org/index.html?module=bb&op=viewtopic&p=3870973#3870973
Reply to the post :
http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=3870973
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
JBoss-Development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-development