Giter Site home page Giter Site logo

Comments (2)

puneetbehl avatar puneetbehl commented on July 17, 2024

It is not working because you are not providing any implementation for notificationTrigger. See AbstractEventBus.groovy#L128. The afterCommit is correctly triggered but does nothing apart from adding a synchronization.

In the above sample application, it is adding synchronization later in the stage when notify("myEventTag${num}", Instant.now()) is called from the transaction after commit is trigger and notificationTrigger.run() is never executed. I think you can directly call the following instead of registering TransactionSynchronizationAdaptor as:

@Transactional(propagation = Propagation.REQUIRES_NEW)
void doSomething() {
      String random = RandomStringUtils.random(20, true, false)
      log.info('Saving a new SomeDomain: '+ random)
      new SomeDomain(text: random).save()
      notify(Event.from("myEventTag1", Instant.now()), TransactionPhase.AFTER_COMMIT)
}

It works when you call notify in a Promise because TransactionSynchronizationManager.synchronizations.get is null in the new thread and the other branch of notify(Event) method is called here

from grails-async.

mitchjust-finocomp avatar mitchjust-finocomp commented on July 17, 2024

thanks @puneetbehl

from grails-async.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.