Does Hazelcast getAtomicLong always generate a unique value?

366 views Asked by At

I want to generate sequence values starting from a certain value in Mongodb.Instead, I've generated sequence values using hazelcast AtomicLong.However, when saving mongodb data, I get a duplicate key error.What would be the reason?

1

There are 1 answers

0
Alparslan Avci On

The value of an AtomicLong can be set by using other direct setting API such as set, or compareAndSet. One of these methods might be called at any point of your code. To generate cluster-wide sequence values, it is better to use IdGenerator or FlakeIdGenerator.