EventBus consume event with several RingBufferWorkProcessor

75 views
Skip to first unread message

Aviad Hadida

unread,
Jun 16, 2015, 3:46:18 AM6/16/15
to reactor-...@googlegroups.com
Hi.
I am writing real time forex system for large banks.

I am trying to achieve something to handle event for blocking actions.. Maybe it can be done with stream but the problem i can get the decoupling that i am getting with event bus.
I am not sure how to use the Stream/ Reactive stream with several event..

So i tried this one:

1. This Processor is basically handle only one event type for different subscribers.. So he will be used for one event. For example: i will have Processor that will be for only for EUR/USD? I will need single processor for all prices? Or do you mean i will have one processor for moudle, for example one processor for all prices. and on this stream i will filter what i need and send to the place that will handle that?

2. Is there a chance this will be good practice? - I will use event bus and wrap eventbus.on with something like that:

private <T> void subscribeToEvent(Selector<String> selector, Consumer<Event<T>> handler, int numberOfProcessors) {
Processor<Event<T>, Event<T>> p = RingBufferWorkProcessor.create("test", 32);
Stream<Event<T>> stream = Streams.wrap(p);
for (int i = 0; i < numberOfProcessors; i++) {
stream.consume(handler);
}

eventBus.on(selector, new Consumer<Event<T>>() {

@Override
public void accept(Event<T> t) {
p.onNext(t);
}
});
}

In this case i will subscribe to event and ask that X processor will be the handlers. This is a general idea that i would like to use it.. But if i can't so maybe it won't be good for me.
In my case i need the event bus because every user subscribe with his user id and a few other things so i am surely need the dynamic for this kind of actions. 

In general.. If i use blocking actions maybe we can't use the event bus


Thanks a lot
Aviad
Reply all
Reply to author
Forward
0 new messages