I’ve implemented a microservice that saves and retrieves data on redis making usage of jpa crud repository. When I save a message, I’ve a method like this:
@Repository
public interface CacheMtRepository extends JpaRepository<SingleMessageHash, String> {
void saveMt(SingleMessageHash value);
everything works fine, but I’m not able to make use of transactions. If I annotate the method in this manner:
@Lock(LockModeType.PESSIMISTIC_WRITE)
void saveMt(SingleMessageHash value);
and I make a test, it seems that the annotation is not working, so any lock has been applied on the key for that RedisHash. Transactions with jpa repository library are not supported, in case of Redis as db?
Thanks in advance for your support.
I expected to have a lock on the key when 2 different services try to call the saveMt method simultaneously for the same key.
ltosetti is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.