Hi
I have a method with @ConsumeEvent , that is using a bean from the CDI context ( SecurityIdentity for keycloak ) and inside the consumer method when I get that bean instance I get one with all properties empty, but if I do it in any regular method ( even same bean ) I get the value expected.
@Transactional(dontRollbackOn = {BadRequestException.class, NotFoundException.class} )
@ConsumeEvent("process-bulk-assessment-creation")
@Blocking
public void processApplicationAssessmentCreationAsync(Long bulkId) {
AssessmentBulk bulk = AssessmentBulk.findById(bulkId);
getUsername(" Debug :");
}
private String getUsername(String loginfo) {
SecurityIdentity context = CDI.current().select(SecurityIdentity.class).get();
log.info(loginfo + " Context : " + context);
if (Objects.nonNull(context)) {
String username = context.getPrincipal().getName();
log.info(loginfo + " Username : " + context.getPrincipal() + "--" + username);
if (Objects.nonNull(username)) {
return username;
}
} return "";
}
I assume the problem is that the context is not propagated, but I already have the context-propagation dependency for Quarkus added to my pom.
Is there anything I need to do to force the context propagation ?
Thank you