Git Product home page Git Product logo

grails-async's Introduction

grails-async's People

Contributors

alvarosanchez avatar bgoetzmann avatar bobbywarner avatar burtbeckwith avatar ctoestreich avatar ddelponte avatar deanfarwell avatar edelaney avatar graemerocher avatar guillermocalvo avatar halfbaked avatar ilopmar avatar jameskleeh avatar jasontypescodes avatar kirill-vlasov avatar ldaley avatar lhotari avatar matrei avatar renovate[bot] avatar rlovtangen avatar sdelamo avatar sheehan avatar smaldini avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

grails-async's Issues

GORM Event not being captured by @Listener

Steps to Reproduce

Run ./gradlew iTin the example repository. Test will fail.

Application is annotated as @ComponentScan

import grails.boot.GrailsApp
import grails.boot.config.GrailsAutoConfiguration
import org.springframework.context.annotation.ComponentScan
import groovy.transform.CompileStatic

@CompileStatic
@ComponentScan
class Application extends GrailsAutoConfiguration {
    static void main(String[] args) {
        GrailsApp.run(Application, args)
    }
}

Class to capture the insertion and deletion:

import org.grails.datastore.mapping.engine.event.PreInsertEvent
import org.grails.datastore.mapping.engine.event.PreUpdateEvent
import grails.events.annotation.gorm.Listener
import groovy.transform.CompileStatic
import org.springframework.stereotype.Component

@Component
@CompileStatic
class UserPasswordEncoderListener  {

    @Listener
    void beforeInsert(PreInsertEvent event) {
        if ( event.entityObject instanceof User ) {
            User u = (event.entityObject as User)
            event.getEntityAccess().setProperty('password', insertEncodePassword(u.password))
        }
    }

    @Listener
    void beforeUpdate(PreUpdateEvent event) {
        if ( event.entityObject instanceof User) {
            User u = (event.entityObject as User)
            if ( u.isDirty('password') ) {
                event.getEntityAccess().setProperty('password', updateEncodePassword(u.password))
            }
        }
    }

    private String insertEncodePassword(String password) {
        'xxxx'
    }

    private String updateEncodePassword(String password) {
        'yyyy'
    }
}

GORM Data service :

import grails.compiler.GrailsCompileStatic
import grails.gorm.services.Service

@GrailsCompileStatic
@Service(User)
abstract class UserService {

    abstract User saveUser(String username, String password)

    User updateUser(String username, String password) {
        User u = User.findByUsername(username)
        if(u != null) {
            u.password = password
            u.save()
        }
        u
    }
}

Failing integration test:

package app

import grails.test.mixin.integration.Integration
import org.springframework.beans.factory.annotation.Autowired
import spock.lang.Specification

@Integration
class UserServiceSpec extends Specification {

    @Autowired UserService userService

    void "test something"() {
        when:
        def u = userService.saveUser('sherlock', 'elementary')

        then:
        !u.hasErrors()

        when:
        sleep(500)
        User.withTransaction {
            u = User.findByUsername('sherlock')
        }

        then:
        u
        u.password == 'xxxx'

        when:
        u = userService.updateUser('sherlock', 'foobar')

        then:
        !u.hasErrors()

        when:
        sleep(500)
        User.withTransaction {
            u = User.findByUsername('sherlock')
        }

        then:
        u
        u.password == 'yyyy'
    }
}

Expected Behaviour

I expected GORM events to be captures by @Listener annotated methods as described in the GORM events section of the async docs.

I looked into the Grails Aysnc example application.

Actual Behaviour

@Listener does not capture any event

Environment Information

  • Operating System: Mac Os
  • Grails Version: 3.3.0.M1
  • JDK Version: 1.8.0_121

Example Application

Async Task Out of Memory Hangs Application without OOME

Task List

  • Steps to reproduce provided
  • Stacktrace: N/A
  • Example that reproduces the problem uploaded to Github: N/A
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Create new Grails Web Application

    • Reduce build.gradle memory usage to a reasonably small value -Xmx512m
  2. Insert an async task into the default controller

Promise promise = task {
   try {
        //Insert High Memory Usage Task
   } catch (Exception e)  {
        log.error("Exceptions does not occur here", e)
   } finally {
        //Code here does not process
   }
}
promise.onError { Exception e ->
    log.error("OOME exceptions should at least occur here, but do not", e)
}
  1. Insert High Memory Usage Task in the above comment
  • I am using a JSONSluper to read a huge JSON file and then try to write it back out to a file.
  • File must be large enough to cause an Out Of Memory Exception (OOME) if run outside of the async task
  1. Run grails run-app in your dev environment or go big and make a production environment and run the war file.

  2. Execute the task in the controller

  3. Wait for OOME, get coffee, watch movie, drink beer, concur that an OOME should occur

Expected Behaviour

An OOME Exception should occur and the task should stop processing

Actual Behaviour

The task runs indefinitely and my laptop gets hot enough to grill a hamburger

Environment Information

  • Operating System: Mac OS (Dev environment) - (Also Tested on CentOS 7 - Prod environment)
  • Grails Version: 5.2.5
  • JDK Version: Open JDK (Build 1.8.0_275-b01)
  • Container Version (If Applicable): Dev environment or Tomcat 9.0.71

Example Application

  • See simple instructions above to reproduce in any Grails application you currently have setup.
  • Github project is unnecessary

Thanks!

3.3.0.M1 Field springTaskExecutor in org.grails.events.bus.spring.EventBusFactoryBean required a single bean, but 4 were found

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

Create a fresh 3.3.0.M1 app
Add compile "org.grails.plugins:grails-spring-websocket:2.3.0"

Expected Behaviour

App starts without exception

Actual Behaviour

***************************
APPLICATION FAILED TO START
***************************

Description:

Field springTaskExecutor in org.grails.events.bus.spring.EventBusFactoryBean required a single bean, but 4 were found:
        - clientInboundChannelExecutor: defined by method 'clientInboundChannelExecutor' in org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration
        - clientOutboundChannelExecutor: defined by method 'clientOutboundChannelExecutor' in org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration
        - brokerChannelExecutor: defined by method 'brokerChannelExecutor' in org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration
        - messageBrokerTaskScheduler: defined by method 'messageBrokerTaskScheduler' in org.springframework.web.socket.config.annotation.DelegatingWebSocketMessageBrokerConfiguration

Action:

Consider marking one of the beans as @Primary, updating the consumer to accept multiple beans, or using @Qualifier to identify the bean that should be consumed


FAILURE: Build failed with an exception.

Environment Information

  • Operating System: Mac latest
  • Grails Version: 3.3.0.M1
  • JDK Version: 1.8u121

Example Application

n/a

Version in grails-plugin.xml in published artifact is wrong

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Download https://repo.grails.org/artifactory/core/org/grails/plugins/events/4.0.0/events-4.0.0.jar
  2. Open /META-INF/grails-plugin.xml
  3. Look at the version attribute of the plugin element

Expected Behaviour

The value of the version attribute should be "4.0.0"

Actual Behaviour

The value of the version attribute is "SNAPSHOT"

Feature Request: Have EventEmitter.sendAndReceive return a Promise

Or return a promiseList. We can then use the get or wait to block if we need the results of the event to proceed for certain business logic.

example use need

class CostService implements EventPublisher {
    Long sumWithTax(List<Long> nums) {
        Long result =nums.sum()
        AtomicLong taxTotal = new AtomicLong(0)

        sendAndReceive("calcTaxes", result){ Long tax ->
            taxTotal.addAndGet(tax)
        }.get() //assuming it returns a promisList

        return result + taxTotal.get()
    }
}

Would it be better to add a new method instead of the sendAndReceive? Maybe call it notifyPromise?

Add support for 'condition' matching on @Subscriber similar to Spring's @EventListener

Spring's @EventListener has a condition attribute that can use an SpEL expression to match:

@EventListener(condition = "#creationEvent.awesome")
public void handleOrderCreatedEvent(CreationEvent<Order> creationEvent) {
}

It would be super handy if @Subscriber could add the same support. This would allow for a better replacement to the pattern matching support that @Selector used to provide with the legacy reactor bus.

Also, we have an enumeration for our eventTypes to make it easier to find and maintain. Having the SpEL expression would allow us to match based on the actual enum value instead of needing to duplicate the string for the eventId (since you can't say value = MyEnum.name() in an annotation).

Subclasses of Event cannot be used in subscriber method signature

Shouldn't be this test the other way around?

Event.isAssignableFrom(parameterTypes[0])

instead of

else if(hasArgument && parameterTypes[0].isAssignableFrom(Event)) {

At the moment I cannot derive form Event and use this subclass directly in subscriber method.

class MyEvent extends Event {
...
}

class Handler {
    @Subcriber("myEvent")
    void handleEvent(MyEvent event) {
    }
}

This does not work.

A workaround is as follows:

class Handler {
    @Subcriber("myEvent")
    void handleEvent(Event event) {
         MyEvent e = (MyEvent) event
         ...
    }
}

WebPromise broken when Interceptor present (Grails 3.3.9)

With Grails 3.3.9 and it's compatible async plugin.

When a grails web Interceptor with a namespace selector is present, a WebPromise causes a server exception due to a null when calling getControllerName().

See the sample project at https://github.com/rrsdev/grails-async-interceptor

Example URLs would be:

If you delete or rename the secured.async.AuthorizationInterceptor class then all URLs work.

Ability to do both Async and Synchronous events in the bus.

Add a buildNotificationCallableSync and a subscribeSync to make it possible to add Synchronous subscriptions listeners without the need for a Gorm AbstractPersitentEvent. This would be especially useful in easily enabling subscribers to participate in Transactions.

  • In the Eventbus in the old platform-plugin for example, there was an option to fork:false that allowed this ability.

java.lang.NoClassDefFoundError: org/grails/encoder/CodecFactory

Steps to Reproduce

  1. ./gradlew pubsub-demo:compileGroovy
> BUG! exception in phase 'canonicalization' in source unit '/Users/sdelamo/Developer/grails/grails-async/examples/pubsub-demo/grails-app/controllers/pubsub/demo/ApplicationController.groovy' java.lang.NoClassDefFoundError: org/grails/encoder/CodecFactory

Environment Information

  • Operating System: MacOS Mojave
  • Grails Version: 4.0.0.BUILD-SNAPSHOT
  • JDK Version: TODO
  • Container Version (If Applicable): TODO

Update travis credentials

Update the credentials in .travis.yml.
The build is failing while trying to upload the snapshot artifacts to artifactory:

Could not PUT 'https://repo.grails.org/grails/libs-snapshots-local/org/grails/grails-async/4.0.0.BUILD-SNAPSHOT/grails-async-4.0.0.BUILD-20181128.185900-1.jar'. Received status code 401 from server: Unauthorized

And while trying to publish the documentation:

remote: Invalid username or password.
fatal: Authentication failed for 'https://[secure]@github.com/grails/grails-async.git/'

Grails apps will not deploy to Glassfish 4+

Steps to Reproduce

  1. Deploy a simple Grails app war file to glassfish 4+
  2. Example war file you may use:
    https://drive.google.com/file/d/1m4_tDOQlzk_7fBh3EMV0vQ1Gx8mztiLn/view?usp=sharing

Expected Behaviour

The war file deploys successfully without error

Actual Behaviour

The war file does not deploy. The following error is logged:

[2018-05-14T15:00:02.054-0500] [glassfish 4.1] [SEVERE] [] [javax.enterprise.system.core] [tid: _ThreadID=45 _ThreadName=admin-listener(4)] [timeMillis: 1526328002054] [levelValue: 1000] [[
  Exception while deploying the app [sec-access-issue-0.1] : The lifecycle method [close] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PreDestroy()] on annotated element [public void org.grails.async.factory.future.CachedThreadPoolPromiseFactory.close() throws java.io.IOException] of type [METHOD]
The lifecycle method [close] must not throw a checked exception. Related annotation information: annotation [@javax.annotation.PreDestroy()] on annotated element [public void org.grails.async.factory.future.CachedThreadPoolPromiseFactory.close() throws java.io.IOException] of type [METHOD]
	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:373)
	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:381)
	at org.glassfish.apf.impl.AnnotationProcessorImpl.processAnnotations(AnnotationProcessorImpl.java:289)
	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:217)
	at org.glassfish.apf.impl.AnnotationProcessorImpl.process(AnnotationProcessorImpl.java:134)

Additional Thoughts

Methods annotated with @PreDestroy should not throw a checked exception.

Taking into account that this is a javax.* annotations and checking the documentation https://docs.oracle.com/javaee/7/api/javax/annotation/PreDestroy.html we can see that methods in the Grails source code not fully following the signature according to the Javadoc, thus we may want to adjust the signatures of the the methods that use @PreDestroy annotation by removing the checked exceptions from them.

Environment Information

  • Operating System: macOS 10.13.4
  • Grails Version: 3.3.5
  • JDK Version: 1.8.0_171
  • Container Version (If Applicable): Glassfish 4.x, Glassfish 5.x

Example Application

Documentation: no links to earlier versions

My issue is documentation related.

There are no links to earlier versions

All links from the grails core doc (docs.grails.org) to the async doc (async.grails.org)
either use the '.../latest/...' path e.g.:
https://async.grails.org/latest/guide/index.html
... or use the root URI https://async.grails.org/ which redirects to the 'latest'

The current latest version is 4.0.2

Assuming that the version number matches the core grails version, where is the doc for a 3.3.x version of grails/async?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Ignored or Blocked

These are blocked by an existing closed PR and will not be recreated unless you click a checkbox below.

Detected dependencies

github-actions
.github/workflows/gradle.yml
  • actions/checkout v4
  • gradle/wrapper-validation-action v2
  • actions/setup-java v4
  • gradle/actions v3
  • actions/checkout v4
  • gradle/wrapper-validation-action v2
  • actions/setup-java v4
  • gradle/actions v3
  • gradle/actions v3
.github/workflows/groovy-joint-workflow.yml
  • actions/setup-java v4
  • actions/cache v4
  • actions/checkout v4
  • gradle/actions v3
  • actions/checkout v4
  • actions/setup-java v4
  • actions/cache v4
  • gradle/actions v3
.github/workflows/release-notes.yml
  • actions/checkout v3
  • release-drafter/release-drafter v5
  • ncipollo/release-action v1
.github/workflows/release.yml
  • actions/checkout v4
  • gradle/wrapper-validation-action v2
  • actions/setup-java v4
  • gradle/actions v3
  • gradle/actions v3
gradle
gradle.properties
settings.gradle
  • com.gradle.enterprise 3.16.2
  • com.gradle.common-custom-user-data-gradle-plugin 1.13
build.gradle
buildSrc/settings.gradle
buildSrc/build.gradle
docs/build.gradle
gradle/api-docs-config.gradle
gradle/buildsrc.libs.versions.toml
  • org.grails:grails-gradle-plugin 6.1.2
  • org.grails.plugins:views-gradle 3.2.1
  • io.github.gradle-nexus:publish-plugin 1.3.0
  • io.github.groovylang.groovydoc:groovydoc-gradle-plugin 1.0.1
  • org.grails:grails-docs 6.1.2
gradle/grails-plugin-config.gradle
gradle/java-config.gradle
gradle/libs.versions.toml
  • net.bytebuddy:byte-buddy 1.14.12
  • org.grails:grails-bootstrap 6.1.2
  • org.grails:grails-core 6.1.2
  • org.grails:grails-plugin-controllers 6.1.2
  • org.grails:grails-datastore-core 8.1.2
  • org.grails:grails-datastore-gorm 8.1.2
  • org.grails:grails-datastore-gorm-test 8.1.2
  • org.grails:grails-web-common 6.1.2
  • org.grails:grails-web-mvc 6.1.2
  • org.grails:grails-web-sitemesh 6.2.1
  • org.codehaus.gpars:gpars 1.2.1
  • org.codehaus.groovy:groovy 3.0.21
  • javax.annotation:javax.annotation-api 1.3.2
  • org.objenesis:objenesis 3.3
  • io.reactivex:rxjava 1.3.8
  • io.reactivex.rxjava2:rxjava 2.2.21
  • opensymphony:sitemesh 2.4.4
  • org.slf4j:slf4j-api 1.7.36
  • org.slf4j:slf4j-nop 1.7.36
  • javax.servlet:javax.servlet-api 4.0.1
  • org.spockframework:spock-core 2.3-groovy-3.0
  • org.springframework:spring-beans 5.3.33
  • org.springframework:spring-core 5.3.33
  • org.springframework:spring-context 5.3.33
  • org.springframework:spring-tx 5.3.33
  • org.springframework:spring-web 5.3.33
gradle/publishing.gradle
grails-async-core/build.gradle
grails-async-gpars/build.gradle
grails-async-rxjava/build.gradle
grails-async-rxjava2/build.gradle
grails-events-compat/build.gradle
grails-events-core/build.gradle
grails-events-gpars/build.gradle
grails-events-rxjava/build.gradle
grails-events-rxjava2/build.gradle
grails-events-spring/build.gradle
grails-events-transform/build.gradle
grails-plugin-async/build.gradle
grails-plugin-events/build.gradle
gradle-wrapper
gradle/wrapper/gradle-wrapper.properties
  • gradle 7.6.4
html
docs/src/main/docs/resources/styles/layout.html
  • clipboard.js 1.7.1

  • Check this box to trigger a request for Renovate to run again on this repository

two plugin communication

two seperate plugin can not notify events

i have two plugin
eg APlugin,BPlugin
then in APlugin notify event

i can not subscribe the event in BPlugin

Events fired from transaction callback are not received

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Attempt to fire an event from within the afterCommit callback of a TransactionSynchronizationAdapter

Expected Behaviour

The event should be received by listeners

Actual Behaviour

The event is not received by listeners

Environment Information

  • Operating System: Ubuntu 20.04
  • Grails Version: 4.0.3
  • JDK Version: (Zulu 8.46.0.19-CA-linux64) (build 1.8.0_252-b14)

Example Application

Notes

This is existing code in a grails 3.2 app migrated to 4.0.3, so firing events like this used to work.

It seems to be associated with the thread which the event is fired from, as wrapping the publish in a promise seems to make it work.

Does it support servlet 3.1?

Spring boot had supported servlet 3.1 since version 1.2, but the document of grails async just says supporting servlet 3.0. I want to confirm whether grails async support servlet 3.1, if not, what's the plan? Thanks!

No thread-bound request found error in controller promise

Thanks for reporting an issue for Grails Async, please review the task list below before submitting the
issue. Your issue report will be closed if the issue is incomplete and the below tasks not completed.

NOTE: If you are unsure about something and the issue is more of a question a better place to ask questions is on Stack Overflow (http://stackoverflow.com/tags/grails) or Slack (http://slack-signup.grails.org). DO NOT use the issue tracker to ask questions.

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

I am trying to upgrade a grails 2.5.4 application to grails 3.3.2. Some of the codes used to work now couldn't work. Basically, the issue is that the async task in the controller is referencing request.params which is not available in the async thread.

I created a 2.5.4 project (demo254) and a 3.3.2 project (demo332) to demonstrate the issue. Both projects have the same controller and view code.

Please refer to the readme in https://github.com/ruiyang/grails-issue-demo.git to reproduce.

Expected Behaviour

I am not sure about the expected behaviour. I just need to know if there is any way I could get this code working to avoid a lot of rewrites.

Actual Behaviour

Exception:
URI /helloWorld
Class . java.lang.IllegalStateException
Message . null
Caused by: No thread-bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet/DispatcherPortlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.

Environment Information

  • Operating System: MacOs
  • Grails Version: 2.5.4 VS 3.3.2
  • JDK Version: 8

Example Application

SendAndReceive does not trigger when subscriber is a method

Task List

  • Steps to reproduce provided
  • Stacktrace (if present) provided
  • Example that reproduces the problem uploaded to Github
  • Full description of the issue provided (see below)

Steps to Reproduce

  1. Subscribe to an event topic with a closure subscriber
  2. Publish to that topic using sendAndReceive with a reply closure
  3. Observe the event is handled by the closure subscriber
  4. Observe the reply closure is called
  5. Subscribe to an event topic with a method subscriber
  6. Publish to that topic using sendAndReceive with a reply closure

Expected Behaviour

Once the subscriber handles the event, trigger the reply closure.

Actual Behaviour

The event is handled, but the reply closure is not called

Environment Information

  • Operating System: Fedora 35
  • Grails Version: 5.1.2
  • JDK Version: 11.0.14
  • Container Version (If Applicable): N/A

Example Application

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.