Hi
Is there somewhere a code-example about the new query bus, query gateway? An example of best practice?
Regards,
Peter
Hi
Is there somewhere a code-example about the new query bus, query gateway? An example of best practice?
Regards,
Peter
Hi Peter,
Assuming you are using Spring in your application, the Axon AutoConfigurer creates a QueryGateway and SimpleQueryBus.
A small example would be:
@RestController
public class MyQueryController {
@Autowired
private QueryGateway queryGateway;
@GetMapping("/query")
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);
}
}
@Component
public class MyQueryHandler {
@QueryHandler
public MyResult handle(MyQuery query) {
return new MyResult();
}
}
Hope this helps, Oscar