Custom CommanHandler Callback


I’ve implemented a custom CommandCallBack:

import org.axonframework.commandhandling.CommandCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class CustomCommandCallback implements CommandCallback {

public static final AxonCallback INSTANCE = new CustomCommandCallback ();

private static final Logger LOGGER = LoggerFactory.getLogger(CustomeKommandCallback .class);

private AxonCallback() {

public void onSuccess(final Object result) {
LOGGER.debug("Command Success: ", result);


public void onFailure(final Throwable cause) {
LOGGER.error(“Command failed”, cause);


And registered the CustomCommandCallBack with the GatewayProxyFactory:

final GatewayProxyFactory gatewayProxyFactory = new GatewayProxyFactory(commandBus);
return gatewayProxyFactory.createGateway(CommandGateway.class);

The first implementation was without log4j only with System.out.println works fine.

After configuring log4j properly the LoggingCallback has been invoked but my CustomCommanCallback not.

Any Idee?


with the CommandGateway, the callbacks that are registered with the gateway itself (as opposed to those passed in the method invocation) are only invoked when their parameter matches the return value of the command handler.
Unfortunately, because of the way that check is done, it does not call the callbacks when null is returned. That’s probably also what’s happening in your case. This shouldn’t affect the onFailure scenario, though.