當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。