JavaCommandClient

The CommandClient for Java callers: the same calls, the in-process client's or a peer's over HTTP alike, without coroutines or Kotlin types. Each call is blocking (send, sendAndWait, stream) or asynchronous (sendAsync, sendAndWaitAsync); see JavaFlows for which thread runs them. Each takes a CommandRequest, or a command and the id of the aggregate it goes to (none for a creation), its type derived from the command's class.

JavaCommandClient commands = JavaCommandClient.of(commandClient).of(caller);
CommandResult result = commands.sendAndWait(new SubmitOrder(items));
commands.sendAndWait(CommandRequest.builder(new PayOrder(amount)).id(orderId).wait(WaitPlan.COMMITTED).build());

A rejection is a me.ahoo.wow.api.client.CommandRejectedException, a technical failure a me.ahoo.wow.api.problem.WowProblemException, both unchecked; an asynchronous call's future completes with them.

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

This client sending as caller (CommandClient.of).

Link copied to clipboard
fun <C : Any> send(request: CommandRequest<C>): CommandResult

Sends request and answers once it is accepted (CommandClient.send).

fun send(command: Any, id: String? = null): CommandResult

Sends command to the aggregate id names and answers once it is accepted.

Link copied to clipboard

Sends request and answers with the result its wait plan ends with (CommandClient.wait).

fun sendAndWait(command: Any, id: String? = null): CommandResult

Sends command to the aggregate id names and answers with the result the default wait plan ends with.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The results of request's wait, one per hop (CommandClient.stream), sent as the stream is made; close it (try-with-resources) to stop reading early.