tac team mailing list archive
-
tac team
-
Mailing list archive
-
Message #00035
[Merge] lp:~danielschnurr/tacenergydemo/oneQueuePerUser into lp:tacenergydemo
Daniel Schnurr has proposed merging lp:~danielschnurr/tacenergydemo/oneQueuePerUser into lp:tacenergydemo.
Requested reviews:
TAC (tac)
Using now one queue instead of multiple destinations.
Refactored JmsNotificationService to decide type which type of Notification is received.
The code implements the functionality but there are some possibilities to improve the design/performance:
To avoid parsing the XML twice we could pass the gPathObject created by the XmlSlurper instead of the xmlString from the receiveNotification method.
I did not implement this in the current version because the AgentStrategyService methods offer the xmlString.
Another possibility would be to source out the methods of the JmsNOtificationService to the XML Databinder service.
--
https://code.launchpad.net/~danielschnurr/tacenergydemo/oneQueuePerUser/+merge/25051
Your team TAC is requested to review the proposed merge of lp:~danielschnurr/tacenergydemo/oneQueuePerUser into lp:tacenergydemo.
=== modified file 'grails-app/conf/BootStrap.groovy'
--- grails-app/conf/BootStrap.groovy 2010-05-02 14:39:30 +0000
+++ grails-app/conf/BootStrap.groovy 2010-05-11 10:53:28 +0000
@@ -18,38 +18,10 @@
class BootStrap {
- def jmsCashContainer
- def jmsDepotContainer
- def jmsOrderStatusContainer
- def jmsForecastContainer
- def jmsProductContainer
- def jmsTradeContainer
- def jmsQuoteContainer
- def jmsOrderbookContainer
- def jmsCompetitionContainer
- def wait_time = 500
-
+ def jmsNotificationContainer
def init = {servletContext ->
- jmsCompetitionContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that competition notifications are received first
- jmsProductContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that product notifications are received first
- jmsCashContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that product notifications are received first
- jmsDepotContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that product notifications are received first
- jmsOrderStatusContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that product notifications are received first
- jmsTradeContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that product notifications are received first
- jmsQuoteContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that product notifications are received first
- jmsOrderbookContainer.start()
- Thread.currentThread().sleep(wait_time) //Sleep for one second in order to ensure that product notifications are received first
- jmsForecastContainer.start()
-
-
+ jmsNotificationContainer.start()
}
def destroy = {
}
=== modified file 'grails-app/conf/spring/resources.groovy'
--- grails-app/conf/spring/resources.groovy 2010-05-02 14:39:30 +0000
+++ grails-app/conf/spring/resources.groovy 2010-05-11 10:53:28 +0000
@@ -40,188 +40,18 @@
}
- // JMS support: queue Listeners and containers for queueInputService
-
- jmsCashListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "cashPositionListener"
- }
-
- jmsCashContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsConnectionFactory
- destinationName = "users.${user}.Cash"
- messageListener = jmsCashListener
- transactionManager = ref("transactionManager")
- autoStartup = false
- }
-
- jmsDepotListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "depotPositionListener"
- }
-
- jmsDepotContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsConnectionFactory
- destinationName = "users.${user}.Depot"
- messageListener = jmsDepotListener
- transactionManager = ref("transactionManager")
- autoStartup = false
- }
-
- jmsOrderStatusListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "orderStatusListener"
- }
-
- jmsOrderStatusContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsConnectionFactory
- destinationName = "users.${user}.Orderstatus"
- messageListener = jmsOrderStatusListener
- transactionManager = ref("transactionManager")
- autoStartup = false
- }
-
- jmsForecastListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "forecastListener"
- }
-
- jmsForecastContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsConnectionFactory
- destinationName = "users.${user}.Forecast"
- messageListener = jmsForecastListener
- transactionManager = ref("transactionManager")
- autoStartup = false
- }
-
-
- // JMS support for topicListener in topicConsumerService
-
- // JMS support: ProductListener and ProductContainer
-
- jmsProductConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) {bean ->
- bean.destroyMethod = "stop"
- connectionFactory = {org.apache.activemq.ActiveMQConnectionFactory cf ->
- brokerURL = brokerDestination
- clientID="${ConfigurationHolder.config.tacenergy.username}.productConnection"
- userName = user
- password = pass
- }
- }
-
- jmsProductListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "productListener"
- }
-
- jmsProductContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsProductConnectionFactory
- destinationName = 'public.Products?consumer.retroactive=true' //ref('productDest')
- messageListener = jmsProductListener
- transactionManager = ref("transactionManager")
- subscriptionDurable = true
- pubSubDomain = true
- autoStartup = false
- }
-
- // JMS support: TradeListener and TradeContainer
-
- jmsTradeConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) {bean ->
- bean.destroyMethod = "stop"
- connectionFactory = {org.apache.activemq.ActiveMQConnectionFactory cf ->
- brokerURL = brokerDestination
- clientID="${ConfigurationHolder.config.tacenergy.username}.tradeConnection"
- userName = user
- password = pass
- }
- }
-
-
- jmsTradeListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "tradeListener"
- }
-
- jmsTradeContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsTradeConnectionFactory
- destinationName = 'public.Trade?consumer.retroactive=true'
- messageListener = jmsTradeListener
- transactionManager = ref("transactionManager")
- subscriptionDurable = true
- pubSubDomain = true
- autoStartup = false
- }
-
- // JMS support: QuoteListener and QuoteContainer
-
- jmsQuoteConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) {bean ->
- bean.destroyMethod = "stop"
- connectionFactory = {org.apache.activemq.ActiveMQConnectionFactory cf ->
- brokerURL = brokerDestination
- clientID="${ConfigurationHolder.config.tacenergy.username}.quoteConnection"
- userName = user
- password = pass
- }
- }
-
-
- jmsQuoteListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "quoteListener"
- }
-
- jmsQuoteContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsQuoteConnectionFactory
- destinationName = 'public.Quote?consumer.retroactive=true'
- messageListener = jmsQuoteListener
- transactionManager = ref("transactionManager")
- subscriptionDurable = true
- pubSubDomain = true
- autoStartup = false
- }
-
- // JMS support: OrderbookListener and OrderbookContainer
-
- jmsOrderbookConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) {bean ->
- bean.destroyMethod = "stop"
- connectionFactory = {org.apache.activemq.ActiveMQConnectionFactory cf ->
- brokerURL = brokerDestination
- clientID="${ConfigurationHolder.config.tacenergy.username}.orderbookConnection"
- userName = user
- password = pass
- }
- }
-
- jmsOrderbookListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "orderbookListener"
- }
-
- jmsOrderbookContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsOrderbookConnectionFactory
- destinationName = 'public.Orderbook?consumer.retroactive=true'
- messageListener = jmsOrderbookListener
- transactionManager = ref("transactionManager")
- subscriptionDurable = true
- pubSubDomain = true
- autoStartup = false
- }
-
- // JMS support: CompetitionListener and CompetitionContainer
- jmsCompetitionConnectionFactory(org.apache.activemq.pool.PooledConnectionFactory) {bean ->
- bean.destroyMethod = "stop"
- connectionFactory = {org.apache.activemq.ActiveMQConnectionFactory cf ->
- brokerURL = brokerDestination
- clientID="${ConfigurationHolder.config.tacenergy.username}.competitionConnection"
- userName = user
- password = pass
- }
- }
-
-
- jmsCompetitionListener(MessageListenerAdapter, ref("jmsNotificationService")) {
- defaultListenerMethod = "competitionListener"
- }
-
- jmsCompetitionContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
- connectionFactory = jmsCompetitionConnectionFactory
- destinationName = 'public.CompetitionAnnounce?consumer.retroactive=true'
- messageListener = jmsCompetitionListener
- transactionManager = ref("transactionManager")
- subscriptionDurable = true
- pubSubDomain = true
- autoStartup = false
- }
+ // JMS support: queue Listeners and containers for JmsNotificationservice
+
+ jmsNotificationListener(MessageListenerAdapter, ref("jmsNotificationService")) {
+ defaultListenerMethod = "receiveNotification"
+ }
+
+ jmsNotificationContainer(org.springframework.jms.listener.DefaultMessageListenerContainer) {
+ connectionFactory = jmsConnectionFactory
+ destinationName = "users.${user}.outputQueue"
+ messageListener = jmsNotificationListener
+ transactionManager = ref("transactionManager")
+ autoStartup = false
+ }
+
}
\ No newline at end of file
=== modified file 'grails-app/services/edu/kit/iism/tacdemo/JmsNotificationService.groovy'
--- grails-app/services/edu/kit/iism/tacdemo/JmsNotificationService.groovy 2010-05-02 14:39:30 +0000
+++ grails-app/services/edu/kit/iism/tacdemo/JmsNotificationService.groovy 2010-05-11 10:53:28 +0000
@@ -24,6 +24,24 @@
def agentStrategyService
def xmlDataBinderService
+ def receiveNotification(String xml) throws NullPointerException {
+ if (!xml) throw new NullPointerException("receiveNotification triggered with null object")
+ def gpathSource = new XmlSlurper().parseText(xml)
+ String notification = gpathSource.name()
+
+ switch (notification) {
+ case "shoutNotification": orderStatusListener(xml); break
+ case "cashPositionNotification": cashPositionListener(xml); break
+ case "depotPositionNotification": depotPositionListener(xml); break
+ case "forecastNotification": forecastListener(xml); break
+ case "tradeLogNotification": tradeListener(xml); break
+ case "quoteLogNotification": quoteListener(xml); break
+ case "orderbookNotification": orderbookListener(xml); break
+ case "productNotification": productListener(xml); break
+ case "competitionNotification": competitionListener(xml); break
+ }
+ }
+
def orderStatusListener(String xml) throws NullPointerException {
if (!xml) throw new NullPointerException("receiveOrderStatus triggered with null object")