Notification in Scheduler and Multitenant context

Having Jmix app

  • multi tenancy
  • quartz scheduler
  • view having a button that start quartz dummy job

Test 1

  • login as user : Company|mario
  • start a Quartz Job by button press
  • app create a notification in a JobListener @Component.
    = in the notification area I cannot see the notification display.

Test 2

  • login as user : admin
  • start a Quartz Job by button press
  • app create a notification in a JobListener @Component.
    = in the notification area I can see the notification display.

How to allow notification to display ?

note : I saw from db that notification recipient is not containing the name of the user but “admin”
this is the reason why as admin I can see notification.

So I need to change the notification recipient putting the right user.

Do I miss something ?
Is there an example ?

Hi

It seems like UIEventPublisher::publishEventForUsers or it’s internally used SystemAuthenticator::runWithUser may help you. Have you tried to create notifications from user contexts? Can you attach reproducable project sample?

1 Like

Thanks for the suggestion
using current user I can get notification in the right way

‘’’
private void notifyTest() {
UserDetails user = currentAuthentication.getUser();
notificationManager.createNotification()
.withSubject(“Test”)
.withRecipients(user)
.toChannelsByNames(“in-app”)
.withContentType(ContentType.HTML)
.withBody("Test " + “/n”)
.send();
}
‘’’