当前位置: 首页>>代码示例>>Java>>正文


Java CommandCallback类代码示例

本文整理汇总了Java中org.axonframework.commandhandling.CommandCallback的典型用法代码示例。如果您正苦于以下问题:Java CommandCallback类的具体用法?Java CommandCallback怎么用?Java CommandCallback使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CommandCallback类属于org.axonframework.commandhandling包,在下文中一共展示了CommandCallback类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: doGet

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
 */
  
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    String itemId=request.getParameter("id");
    Integer quantity=Integer.parseInt(request.getParameter("quantity"));
    AddItemCommand addItemCommand=new AddItemCommand(itemId);
    addItemCommand.setQuantity(quantity);
    
    logger.debug("quantity:" + quantity);
    logger.debug("id:" + itemId);
    //asynchronous call - callback registered
    CommandCallback commandCallback = new CommandCallback<Object>() {
        @Override
        public void onSuccess(Object result) {
        	logger.debug("Expected this command to fail");
        }

        @Override
        public void onFailure(Throwable cause) {
        	logger.debug("command exception", cause.getMessage());
        }
    };
    commandGateway.send(addItemCommand, commandCallback);
}
 
开发者ID:feliciatucci,项目名称:cqrs-sample,代码行数:29,代码来源:ShoppingCartServlet.java

示例2: onHzCommandReply

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void onHzCommandReply(final HzCommandReply reply) {
    m_logger.debug("Got HzCommandReply from <{}>",reply.getNodeName());

    CommandCallback cbk = m_agent.getCallback(reply.getCommandId());

    if(cbk != null) {
        if(reply.isSuccess()) {
            cbk.onSuccess(reply.getReturnValue());
        } else {
            cbk.onFailure(reply.getError());
        }
    } else {
        m_logger.warn("No callback registered for <{}>",reply.getCommandId());
    }
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:18,代码来源:HzCommandBusConnector.java

示例3: CommandProcessor

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
public CommandProcessor(AxonMessageSerializer serializer, CommandBus localCommandBus,
                        CommandCallback<Object, Object> commandCallback,
                        ConsumerService consumerService, String name, int threads) {
    this.serializer = serializer;
    this.localCommandBus = localCommandBus;
    this.commandCallback = commandCallback;
    this.consumerService = consumerService;
    this.name = name;
    this.threads = threads;
}
 
开发者ID:flux-capacitor-io,项目名称:flux-capacitor-client,代码行数:11,代码来源:CommandProcessor.java

示例4: send

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public <R> void send(String routingKey, CommandMessage<?> command, CommandCallback<R> callback) throws Exception {
    String destination = getCommandDestination(routingKey, command);
    m_logger.debug("Send command <{}> to <{}>",command.getIdentifier(),destination);

    if(StringUtils.isNotBlank(destination)) {
        try {
            m_hzInstance.getQueue(destination)
                .put(new HzCommand(m_agent.getNodeName(), command, true));

            if(callback != null) {
                m_agent.registerCallback(command,new HzCommandCallback(callback));
            } else {
                m_agent.registerCallback(command,new HzCommandCallback(
                    true,
                    new CommandCallback<Object>() {
                        @Override
                        public void onSuccess(Object result) {
                            m_logger.debug("onSuccess : <{}>",result);
                        }

                        @Override
                        public void onFailure(Throwable cause) {
                            m_logger.warn("onFailure", cause);
                        }
                    }
                ));
            }
        } catch(Exception e) {
            m_agent.removeCallback(command);
            m_logger.warn("Exception,e");
            throw e;
        }
    }
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:37,代码来源:HzCommandBusConnector.java

示例5: send

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <R> void send(String routingKey, CommandMessage<?> command, CommandCallback<R> callback) throws Exception {
    try {
        // put a key as placeholder
        m_hzInstance.getMap(HzConstants.REG_AGGREGATES).put(
            routingKey,
            m_hzInstance.getName());

        Future<HzCommandReply> fr = m_executor.submitToKeyOwner(
            new HzCommandTask(new HzCommand(m_nodeName,command,true)),
            routingKey);

        HzCommandReply reply = fr.get();

        if(callback != null) {
            if(reply.isSuccess()) {
                LOGGER.debug("HzCommandReply.CommandId {}",reply.getCommandId());
                LOGGER.debug("HzCommandReply.NodeName  {}",reply.getNodeName());
                callback.onSuccess((R)reply.getReturnValue());
            } else {
                LOGGER.debug("HzCommandReply.CommandId {}",reply.getCommandId());
                LOGGER.debug("HzCommandReply.NodeName  {}",reply.getNodeName());
                callback.onFailure(reply.getError());
            }
        }
    } catch(Exception e) {
        m_logger.warn("Exception",e);
        throw e;
    }
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:32,代码来源:HzCommandBusConnector.java

示例6: send

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
public <R> void send(Object command, CommandCallback<R> callback) {
    m_commandGateway.send(command,callback);
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:4,代码来源:AxonService.java

示例7: send

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
public <R> void send(Object command, CommandCallback<R> callback) {
    m_cmdGw.send(command,callback);
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:4,代码来源:AxonService.java

示例8: HzCommandCallback

import org.axonframework.commandhandling.CommandCallback; //导入依赖的package包/类
/**
 * c-tor
 *
 * @param callback the callback
 */
public HzCommandCallback(CommandCallback<T> callback) {
    this(false, callback);
}
 
开发者ID:lburgazzoli,项目名称:lb-axon,代码行数:9,代码来源:HzCommandCallback.java


注:本文中的org.axonframework.commandhandling.CommandCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。