cloudbreak
cloudbreak copied to clipboard
CB-17954 Refactor databus-connector module to use streaming-common
trafficstars
See detailed description in the commit message.
some recommendations:
- createWorker method can be moved to
AbstractDatabusRecordProcessor:
public DatabusRecordWorker<C> createWorker(String threadName, BlockingDeque<DatabusRequest> processingQueue) {
return new DatabusRecordWorker<>(threadName, processingQueue, this, getTracer(), getRegionAwareInternalCrnGeneratorFactory());
}
so you can remove worker creation from
- you can get rid of the processRecord/input method as well, only problem is in the processInput of the AbstractStreamRecordProcessor, only calls messageIsNotEmpty() and not checks accountId like the databus one, but maybe you can create an isInputValid(input) method, that only calls messageIsNotEmpty, and on the abstract databus class you can override that and call super.isInputValid && doesAccountIdExist(input) ...also note the log if the input is not valid only talks about the message body is empty which is invalid here, so you can put that log (with the input) into a method as well, thsat can be also can be overwritten by the abstract databus processor
- if processRecord is removed you can get rid of isDatabusProcessingEnabled method and rename it to isProcessingEnabled (so do the same but override that method)
- you can also drop every handleXXXException kind of methods then, databus record worker uses one of it, it can use the handleStreamingException method instead of the databus one (also the DatabusProcessingException class can be extended from StreamProcessingException)
by this we can get rid much more duplications