Sorry I was not clear in giving the big picture. Here is a better problem definition. I do have http requests. All the cases I mentioned is happening together per http request. My code is like this
HttpServer server = vertx.createHttpServer();
Router router = router(vertx);
server.requestHandler(router::accept).listen(4080);
// This handler will be called for every request
router.route("/someurl").handler(routingContext -> {
EventBus eb = vertx.eventBus();
ARoutingContext aRoutingContext = new ARoutingContext(routingContext);
eb.send(Events.A, aRoutingContext<// This object contains data and routing context>);
// Lets say i will need same flow executed again. Just to simulate more complex flows cases
eb.send(Events.A, aRoutingContext<// This object contains data and routing context>);
}
Note: I have multiple instances of all below mentioned verticles so
Lets say verticle v(A) handles event A.
This will now trigger events in this flow
(v(A) to v(B))
{ v(B) to v(1), v(2) ..... v(N) } - This is the forking case
{ v(1), v(2) .... v(N) to v(C) } - This the joining case
The way I have implemented now is v(C) will have the routing context so it will write data and close by doing response.done() when all data for that req is flushed out. I need routing context object in v(C) cos I need to share data between different instances of v(C) and also need a way to track if all data for the request is flushed out or not only then close response object.
One more way of implementing this flow was by using message.reply() mechanism. but in my flow since there are many forks and joins, I will end up getting same output multiple times in the route handler so I opted to passing routing context along the verticles.
Please suggest the best way to achieve this flow per request.
Thanks & Regards
Pratap