Axon 3.1:QueryBus/QueryGateway


Is there somewhere a code-example about the new query bus, query gateway? An example of best practice?


Hi Peter,

Assuming you are using Spring in your application, the Axon AutoConfigurer creates a QueryGateway and SimpleQueryBus.

A small example would be:

public class MyQueryController {

private QueryGateway queryGateway;

public ResponseEntity doQuery() throws Exception {
CompletableFuture future = queryGateway.send(new MyQuery(), MyResult.class);
// possibly do some more work
MyResult result = future.get();
return new ResponseEntity<>(result, HttpStatus.CREATED);

public class MyQueryHandler {

public MyResult handle(MyQuery query) {
return new MyResult();

Hope this helps, Oscar