#1
|
|||
|
|||
![]()
Hello all. I'm trying to come up with some way to monitor a channel's activity (number of messages received within the last hour), and have thought about various approaches to this. I don't really want to query the Mirth database so have considered if it is possible to use the global map to keep a record of received message IDs, but I am not sure how to expire old values and one keep one hours worth so that I can count them.
What would be your suggestions on the best approach? I have not managed to find examples on the forum. |
#2
|
|||
|
|||
![]()
This seems to do the job:
Code:
// keep 20 seconds worth of message IDs if (globalChannelMap.get('messages20') == null) { globalChannelMap.put('messages20',new Packages.com.google.common.cache.CacheBuilder.newBuilder().expireAfterWrite(20,java.util.concurrent.TimeUnit.SECONDS).build()); } $gc('messages20').cleanUp(); $gc('messages20').put(connectorMessage.getMessageId(),''); logger.info('Number of messages in the last 20 seconds = ' + $gc('messages20').size()); |
#3
|
|||
|
|||
![]()
Well, you could write to a simple database table with col1 = messageid, col2 = datetime. Then you can easily group by minute, hour, day, etc.
There would be a tiny performance hit since you are adding a database write step, but I don't see this to be much. |
![]() |
Tags |
monitoring, throughput |
Thread Tools | |
Display Modes | |
|
|