Skip to content

Commit

Permalink
fix for GRAILS-12119 - Async Response Rendering fails
Browse files Browse the repository at this point in the history
  • Loading branch information
graemerocher committed Mar 26, 2015
1 parent bf373ff commit 3e7fc2e
Showing 1 changed file with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ package org.grails.plugins.events

import grails.plugins.Plugin
import grails.util.GrailsUtil
import groovy.transform.CompileStatic
import groovy.util.logging.Commons
import org.grails.events.reactor.GrailsReactorConfigurationReader
import org.springframework.beans.factory.config.MethodInvokingFactoryBean
import reactor.Environment
Expand All @@ -31,6 +33,7 @@ import reactor.spring.context.config.ConsumerBeanAutoConfiguration
* @author Graeme Rocher
* @since 3.0
*/
@Commons
class EventBusGrailsPlugin extends Plugin {

def version = GrailsUtil.grailsVersion
Expand All @@ -39,9 +42,7 @@ class EventBusGrailsPlugin extends Plugin {
Closure doWithSpring() {
{->
reactorConfigurationReader(GrailsReactorConfigurationReader, grailsApplication.config, ref("grailsConfigProperties"))
reactorEnv(Environment, ref("reactorConfigurationReader")) { bean ->
bean.destroyMethod = "shutdown"
}
reactorEnv(Environment, ref("reactorConfigurationReader"))

eventBus(MethodInvokingFactoryBean) { bean ->
targetClass = EventBus
Expand All @@ -51,4 +52,20 @@ class EventBusGrailsPlugin extends Plugin {
consumerBeanAutoConfiguration(ConsumerBeanAutoConfiguration)
}
}

@Override
@CompileStatic
void doWithApplicationContext() {
Environment.assign applicationContext.getBean('reactorEnv', Environment)
}

@Override
@CompileStatic
void onShutdown(Map<String, Object> event) {
try {
Environment.terminate()
} catch (Throwable e) {
log.warn("Error shutting down Reactor: ${e.message}", e)
}
}
}

0 comments on commit 3e7fc2e

Please sign in to comment.