I am using spring-data-redis to persist and retrieve a redis hash, and a weird WARN log entry keeps arising, whenever I do not wrapp execution in a transaction, via @Transactional annotation:
20-sept-2022 08:30:21.135 [http-nio-5335-exec-2] [trace=, span=, parent=, exportable=] WARN o.s.t.e.TransactionalApplicationListenerMethodAdapter - Processing KeyValueEvent [keyspace=AuthToken, source=DDKAaXi4DdCq3XEDULemz8hCaxA] as a fallback execution on AFTER_ROLLBACK phase
Versions:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.7.3</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
</dependency>
</dependencies>
Redis configuration:
@Configuration
@EnableRedisRepositories(basePackageClasses = {AuthTokenRedisRepository.class})
public class RedisConfiguration {
@Bean
public RedisTemplate<String, Object> redisTemplate(final RedisConnectionFactory connectionFactory) {
final RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(connectionFactory);
// I have tried both enabling and disabling transaction support.
//template.setEnableTransactionSupport(false);
return template;
}
}
This is the repository and the entity (redis hash):
@Repository
public interface AuthTokenRedisRepository extends CrudRepository<AuthTokenRedisRepository.AuthTokenEntry, String> {
List<AuthTokenEntry> findByUserId(@NotNull Integer userId);
@Getter
@Setter
@RedisHash("AuthToken")
class AuthTokenEntry implements Serializable {
@Id
private String authTokenId;
@Indexed
private Integer userId;
private String username;
private String userPublicId;
private Set<String> authorities;
@TimeToLive(unit = MILLISECONDS)
private long timeToLiveMillis;
private long creationDateEpochMillis;
private long expiryDateEpochMillis;
}
}
I would see it logic to start a transaction in a modifying use case, but the only method I am invoking in my scenario is a read one:
@Override
public Optional<AuthToken> retrieve(final AuthTokenId authTokenId) {
return repository.findById(authTokenId.value()).map(this::toDomain);
}
More over, the mention to the transaction phase AFTER_ROLLBACK worries me, as it looks like some modification has been tried but not accomplished.
Any advice?