Hi..
I tried to read and investigate a little bit and i still have some issues with implementing what i need or something close..
After our last discussion i updated the framework depencdecies and tried to checkout EventBus(Which was Reactor before)..
It worked great for non blocking actions and according to our discussion this won't be the right decision for me.
I tried to use the
RingBufferWorkProcessor as Stephane mentioned and tried to take his example. I couldn't get it worked because it seems that method signtures expect something else. I did the following
// Processor
for (int i = 0; i < 10; i++) {
processor.subscribe(SubscriberFactory.unbounded(new reactor.fn.BiConsumer<String, SubscriptionWithContext<Void>>() {
@Override
public void accept(String left,
SubscriptionWithContext<Void> right) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(left);
}
}));
}
for (int i = 0; i < 1000; i++) {
processor.onNext(i + " next");
}
Well.. This worked as i wanted it to do.. Single thread for every subscriber.. But from here i don't know how to take it to implementation buy using subscription mechanism like in EventBus(Which is so intuitive and easy to use) and still get this processor thread for each subscriber.
In addition there is still something i am not sure i understand.. Using the onNext is the same as using notify? I guess not and i really would like to understand the difference.. I looked on docs and couldn't understand why the processor is so different from the EventBus.
Two things i worry about:
1. The processor send the message not in order(Which is fine by me.. as long as the message will not be too far. For example: if i send 1-100 this will be ok: 2,3,4,1,5,6 But this: 23,24,1,27)
Is there any way to say every message that older than X seconds will be neglect or maybe send in order to avoid this?
2. I worry that i don't fully understand the diffrence between those 2 ways and maybe there is another way that will be better for me.
Small reminder: What i trying to achieve is eventBus that will have diffrent thread for every subscriber, or maybe only for part of the events in my system i will need thread for every event and for other group of event i can use ring buffer event bus.
Thanks a lot for your help
Aviad