If you are sending within the same process (btw this can happen with ANY grouping), the object is sent more or less by reference, and is not serialized / deserialized. therefore when bolt a calls clear, the object seen by bolt b is also cleared.
On Thu, Nov 6, 2014 at 3:12 AM, 이승진 <[email protected]> wrote: > I was already doing like that, sorry I shortend actual source code and > that make it confusing. > > > -----Original Message----- > *From:* "Susheel Kumar Gadalay"<[email protected]> > *To:* <[email protected]>; "이승진"<[email protected]>; > *Cc:* > *Sent:* 2014-11-06 (목) 17:03:09 > *Subject:* Re: issue about emitting ConcurrentHashMap > > You have to emit like this since the object is mutating. > > collector.emit(new Values(ConcurrentHashMap)); > > On 11/6/14, 이승진 <[email protected]> wrote: > > 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. > > > > >
