-
Notifications
You must be signed in to change notification settings - Fork 8
Event sourcing and rx-jersey #4
Comments
Hi! Unfortunately I didn't have chance to try event sourcing in wild, I just know the concept. Also in case number If it's any helpful :) |
I was trying to use interfaces as configuration to hook jersey and rx java. Endpoints are defined as follows (via java interface) : public interface Endpoints {
@POST
@Path("/foo")
String foo(String message);
@POST
@Path("/bar")
String foo(MyModel model);
} Some service would subscribe to Since jersey doesn't like interfaces as resources, I registered custom model processor to inject special inflector (see handleBy method). Does it look like the right approach ? |
I think you might want look at using some message broker for delivering messages? Because rx-jersey is working with single responses even if returned value is But I think I'm still missing what you want to achieve ¯\_(ツ)_/¯ |
I'm not sure I have a live example of it. But let's say from Jersey I'd like to obtain something like Maybe combine Jersey "stream" with Kakfa ( Does it make sense ? |
Okay, I think I understood, In case of using RxJersey I suppose you can make RxInterceptor and feed your stream from it (as you suggested in the beginning via |
Hello,
I would like to ask your opinion (and ideas) about the following usecase. Not sure if rx-jersey library is supposed to directly address it, but would be nice to know view of the author (and reader).
Both RX (observable pattern) and event sourcing are becoming popular solutions for today's implementation of services. We would like to leverage rxjava as internal event bus where messages are being published and observed. In this scenario, Jersey becomes just an endpoint which transforms HTTP payload into stream of events (and vice versa).
classical jersey approach
Using RX subject (eventbus)
Our issue becomes correctly mapping request and response events which may span multiple threads (ie having request scope for each event). There are a couple of solutions but none of them is ideal, unfortunately:
correlationId
on each event. The drawback is that it has to be manually copied for each event (eg.new ResponseEvent(request.correlationId())
). Which is not nice in business logic.Message<T>
with payload (which internally storescorrelationId
and request context). The problem here is that users subscribe toMessage
and not business levelEvent
(Subject<Message>
instead ofSubject<Event>
)groupBy
) thread-local information will be lost.Please let me know if there are better alternatives.
Thanks in advance.
The text was updated successfully, but these errors were encountered: