Package com.github.ddth.pubsub.impl
Class CountingSubscriber<ID,DATA>
- java.lang.Object
-
- com.github.ddth.pubsub.impl.CountingSubscriber<ID,DATA>
-
- All Implemented Interfaces:
ISubscriber<ID,DATA>
public class CountingSubscriber<ID,DATA> extends Object implements ISubscriber<ID,DATA>
Count number of received messages.- Since:
- 0.7.0
- Author:
- Thanh Nguyen
-
-
Constructor Summary
Constructors Constructor Description CountingSubscriber()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Long>getAllCounters()Get all counters aschannel:value.longgetCounter(String channel)Get total number of received messages on a channel.longgetTotalMessages()Get total number of received messages.booleanonMessage(String channel, IMessage<ID,DATA> msg)Called when a message arrives on a channel.voidresetCounter()Reset counter to value zero.
-
-
-
Method Detail
-
resetCounter
public void resetCounter()
Reset counter to value zero.
-
getTotalMessages
public long getTotalMessages()
Get total number of received messages.- Returns:
-
getAllCounters
public Map<String,Long> getAllCounters()
Get all counters aschannel:value.- Returns:
-
getCounter
public long getCounter(String channel)
Get total number of received messages on a channel.- Parameters:
channel-- Returns:
-
-