-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4fde5f
commit 715ae44
Showing
4 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Grails 3.0 introduces a new Events API based on [Reactor|https://github.com/reactor/reactor]. | ||
|
||
All services and controllers in Grails 3.0 implement the [Events|api:grails.events.Events] trait. | ||
|
||
The @Events@ trait allows the ability to consume and publish events that are handled by Reactor. | ||
|
||
The default Reactor configuration utilises a thread pool backed event bus. You can however configure Reactor within @application.yml@, for example: | ||
|
||
{code} | ||
reactor | ||
dispatchers: | ||
default: myExecutor | ||
myExecutor: | ||
type: threadPoolExecutor | ||
size: 5 | ||
backlog: 2048 | ||
{code} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
There are several ways to consume an event. As mentioned previously services and controllers implement the [Events|api:grails.events.Events] trait. | ||
|
||
The @Events@ trait provides several methods to register event consumers. For example: | ||
|
||
{code} | ||
on("myEvent") { | ||
println "Event fired!" | ||
} | ||
{code} | ||
|
||
Note that if you wish a class (other than a controller or service) to be an event consumer you simply have to implement the @Events@ trait and ensure the class is registered as a Spring bean. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
The @Events@ trait also provides methods for notifying of events. For example: | ||
|
||
{code} | ||
notify "myEvent", "myData" | ||
sendAndReceive "myEvent", "myData", { | ||
println "Got response!" | ||
} | ||
{code} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters