java - Disruptor: setting EventHandler order -


i newbie disruptor , using disruptor passing between threads in pipeline-like structure.i can run set of handlers below hadleeventswith or using after().

disruptor.handleeventswith(eventhandler1)                 .then(eventhandler2)                 .then(eventhandler3); 

but,i want able add new eventhandlers pipeline without changing code here.to this, adding integer value each event handler.then,i taking values , relevant handlers create ordered list of handlers. then, give ordering disruptor doing is

disruptor.handleeventswith(handlerorderlist.get(0)); (int i=1; i<handlerorderlist.size();i++) {      disruptor.after(handlerorderlist.get(i1)).then(handlerorderlist.get(i));  } 

is there better way of doing this?

something might more readable:

    eventhandler<yourtypehere>[] handlers = getorderedhandlersasarray();     disruptor.handleeventswith(handlers); 

update: right. in above case, handlers process events in parallel. process events sequentially, might try following :

    eventhandlergroup<t> eventhandlergroup = null;     (t handler : handlers) {         if (eventhandlergroup == null) {             eventhandlergroup = disruptor.handleeventswith(handler);         } else {             eventhandlergroup.then(handler);         }     } 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -