Transaction plugin

Enjoy support for @Transactional out of the box in your preferred development framework

The JobRunr Spring Boot Starter and Micronaut integration come with an @Transactional plugin that makes sure your jobs join the transaction created by the framework.

@Inject
private UserRepository userRepositoy;
@Inject
private JobScheduler jobScheduler;

@Transactional
public void createUserAndSendWelcomeEmail(User user) {
    userRepositoy.save(user);
    jobScheduler.<UserService>enqueue(x -> x.sendWelcomeEmail(user.id));
}

Thanks to the @Transactional support, the whole method - including the job scheduling - is transactional.

How does it work?

  • the JobRunr Spring Boot Starter and Micronaut Integration check whether they can participate in a transaction created by that framework.
  • if one is present, it is used and the whole method is transactional.
  • if not, JobRunr creates it’s own transaction to make sure the job is saved to the database.

This off-course only works for the SQL StorageProviders.