ConsumeEvent and CDI context propagation

83 views
Skip to first unread message

Jonathan Vila López

unread,
Apr 30, 2021, 9:21:35 AM4/30/21
to vert.x
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

Thomas SEGISMONT

unread,
Apr 30, 2021, 9:53:58 AM4/30/21
to vert.x
Hi Jonathan,

I think you have sent your message to the wrong ML, this is the Vert.x user group :-)

--
You received this message because you are subscribed to the Google Groups "vert.x" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vertx+un...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/vertx/a0efc132-840f-4dc4-a2fb-632d96b30753n%40googlegroups.com.

Jonathan Vila Lopez

unread,
Apr 30, 2021, 1:27:17 PM4/30/21
to ve...@googlegroups.com
Hi Thomas

Which would be the list to send this question ? As I was using the EventBus and ConsumeEvent from the vertx package I thought it was related with it.

Regards

Dan O'Reilly

unread,
Apr 30, 2021, 5:19:20 PM4/30/21
to vert.x
You should ask about this on whatever support channels Quarkus provides.

Thomas SEGISMONT

unread,
May 3, 2021, 3:40:15 AM5/3/21
to vert.x
Hi Jonathan,

Dan is right.

According to https://quarkus.io/support/ you should send the question to StackOverflow. But I guess you could find some help on Zulip too.

Cheers,
Thomas

Reply all
Reply to author
Forward
0 new messages