I'm implementing a websocket messaging client with netty and java8. Each message has a transactionId, correlate to its response.
I need to implement a send API. So I have a few options.
- send(message, Callback);
- CompletableFuture send(message);
Either way, I'm thinking to have a transaction map(hashmap), which contains transactionId to Callback or CompletableFuture mapping. My question is which one is a better practice? Or something else? Is it OK to put CompletableFuture into Map?
Any good design to solve a similar problem?
Aucun commentaire:
Enregistrer un commentaire