java - How to throw RuntimeException deliberately? -
java - How to throw RuntimeException deliberately? -
suppose topology simple :
spout --> bolt --> bolt b --> bolt c
and bolt c stores info in datastore.
now advisable throw runtimeexception whenever there exception in storing info ? :
try { datastoremanager.insert(mydata); } grab (exception e) { throw new runtimeexception(e); }
or should throw failedexception , allow topology retry tuple ?
what should practice ?
i didn't see harm in deliberately throwing runtimeexception here because when happens , current worker thread dies , since ack not received topology , tuple re-tried on other worker, resulting in same overall output throwing failedexception except enhanced load on topology.
consider extending runtimeexception
public dataexception extends runtimeexception { } seek { datastoremanager.insert(mydata); } grab (exception e) { throw new dataexception(e); }
now classes above in phone call hierarchy can take grab specific exception or allow propagate up.
since unchecked may want add together sufficient documentation in java doc allow callers expect runtimeexception
java exception apache-storm
Comments
Post a Comment