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
dependencies { | |
... | |
compile 'org.apache.activemq:activemq-core:5.7.0' | |
// (this is necessary for namespace support) | |
compile 'org.apache.xbean:xbean-spring:3.12' | |
... | |
} |
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
beans = { | |
... | |
xmlns amq:"http://activemq.apache.org/schema/core" | |
/* Establish the broker */ | |
amq.broker(useJmx: false, persistent: false) { | |
amq.transportConnectors() { | |
amq.transportConnector(uri: "tcp://localhost:61616") | |
} | |
} |
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
dependencies { | |
... | |
compile 'org.springframework.integration:spring-integration-core:2.2.0.RELEASE' | |
compile 'org.springframework.integration:spring-integration-jms:2.2.0.RELEASE' | |
compile 'org.springframework.integration:spring-integration-stream:2.2.0.RELEASE' | |
... | |
} |
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
beans = { | |
... | |
/* Attach the message adapter */ | |
logServiceActivator(LoggingServiceActivator) | |
/* Create the log channel, for internal transport */ | |
integration.channel(id: "logChannel") | |
/* Attach a chain to the log channel, this will delegate the message to the LoggingServiceActivator */ | |
integration.chain("input-channel": "logChannel") { |
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
class LogMessageCommand { | |
String level | |
String threadName | |
String application | |
String message | |
String hostname | |
String ipAddress | |
LocalDateTime messageTime = new LocalDateTime() // this is joda-time | |
} |
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
grails.atmosphere.mappingUri = '/atmosphere/logging' |
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
// Registering an application's logging instance either means creating a new mapping for it. | |
// If a mapping already exists, update its "latest update time" property. | |
private def registerApplicationInstance(String ipAddress, String hostname, String appName) { | |
if (!applications[appName]) { | |
applications[appName] = [] | |
} | |
def existing = findApplicationObject(appName, ipAddress, hostname) | |
if (!existing) { | |
// Register the new application and create a unique mapping for it. | |
applications[appName] << [ipAddress: ipAddress, hostname: hostname, lastUpdateTime: new LocalDateTime()] |
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
<!-- ... resources & jquery snipped for brevity ... --> | |
<atmosphere:resources/> | |
<r:script> | |
$(document).ready(function() { | |
var url = '${createLink(uri:ApplicationHolder.application.config.grails.atmosphere.mappingUri)}'; | |
$.atmosphere.subscribe(url, Logging.router, $.atmosphere.request = {transport:'websocket', fallbackTransport:'streaming'}); | |
... | |
}); | |
</r:script> |
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
<!-- ... some rendered code, divs and shit, removed for brevity ... --> | |
<script> | |
(function() { | |
var url = '${createLink(uri: ApplicationHolder.application.config.grails.atmosphere.mappingUri)}/logchannel/${id}/${ip}/${hostname}'; | |
$.atmosphere.subscribe(url, Logging.router, $.atmosphere.request = {transport:'websocket', fallbackTransport:'streaming'}); | |
... | |
})(); | |
</script> |
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
class LoggingService { | |
/** | |
* These two fields represent the atmosphere "config". | |
*/ | |
static final MAPPING_URI = ApplicationHolder.application.config.grails.atmosphere.mappingUri | |
static atmosphere = [mapping: MAPPING_URI] | |
/** | |
* The {@link LoggingServiceActivator} delegates its messages to this method. | |
* This method, in turn, broadcasts them to the UI via the atmosphere broadcaster. |