Command Handling Return values

I am working in a flex application using spring,hibernate and axon. In
the logon process I want to return some data: the aggregate id, a
authenticate string code and some other data like user state, passwrod
expiring days, etc.

I've decide to use a command handler cause this process changes the
state of the server, but i have problems receiving the response in
flex. I'm receiving a void ProxyObject.

Where am i wrong? Anyone can help me? Can i found any example
returning data to flex client?



public class UsuariCommandHandler {
  private Repository<Usuari> repository;
  private UsuariRepository usuariRepository;

  public UsuariAuthenticatedResult
handleAuthenticateUser(UsuariAuthenticateCommand command) throws
DeskException {

        try {
          Usuari usuari;

            String usuariId = command.getUsuariId();
            if (usuariId == null) {
              usuariId = UUID.randomUUID().toString();

              UsuariEntry account =
              usuari = new Usuari(new
            } else {
              usuari = repository.load(new

             String code = usuari.authorize(command.getToken());

             UsuariAuthenticatedResult result = new
      return result;
    } catch (NoResultException e) {
      throw new UsuariException(e);

  public void setRepository(Repository<Usuari> repository) {
    this.repository = repository;

  public void setUsuariRepository(UsuariRepository userRepository) {
    this.usuariRepository = userRepository;

package commands.system
  import commands.BaseController;

  import model.system.UserAuthenticateEvent;

  import mx.messaging.messages.AcknowledgeMessage;
  import mx.rpc.AsyncToken;

  public class LoginUserController extends BaseController {

    public function LoginUserController() {

    public function execute(event:UserAuthenticateEvent):AsyncToken {
      var command:UsuariAuthenticateCommand = new
      command.ident = event.user.ident;
      command.password = event.user.password;

      return commandReceiver.sendCommand(command);

    public function result(result:*):void {

The address book sample application contains a complete Flex sample. It might be a bit dated, since I did not upgrade any of the flex code for at least e year. But it did work.

regards Jettro

Thanks Jettro,
I'm learning with your Addredbook app, but i've haven't found any case
that can help me.

May be i have to use entityManager like you use in

My apologies. I'm training to undesrtand how work all togheter.

Thanks a lot.

You can check the CommandReceiverImpl class, the method

FutureCallback callback = new FutureCallback();
commandBus.dispatch(new GenericCommandMessage(command), callback);
try {
return callback.get();
} catch (Exception e) {
throw new RuntimeException(e);

Shows the mechanism to use a Future. The most important class here is the FutureCallback.

Hope that helps,

regards Jettro