I use concurrent hash map for calculating simple statistics
Assume it should be emitted from A and delivered into B.
 
in bolt A, I call 
collector.emit(ConcurrentHashMap);
ConcurrentHashMap.clear();
 
in boltB, I call
ConcurrentHashMap statsMap = (ConcurrentHashMap) tuple.getValue(0);
 
But even if there are some contents in that map in bolt A, bolt B receives 
empty map.
 
I thought this is because since netty works in asynchronous way, that map is 
cleared before actually emitted to bolt B.
 
After changing bolt A to like below, bolt B started getting map correctly.
collector.emit(ConcurrentHashMap);
Thread.sleep(1);
ConcurrentHashMap.clear();
 
but I think it's not a best way handling this. 
Is there any way to wait for collector to complete emitting?
 
any sugguestion will be a big help for me
 
thanks in advance.

Reply via email to