本文整理匯總了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);
}
示例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());
}
}
示例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;
}
示例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;
}
}
}
示例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;
}
}
示例6: send
import org.axonframework.commandhandling.CommandCallback; //導入依賴的package包/類
public <R> void send(Object command, CommandCallback<R> callback) {
m_commandGateway.send(command,callback);
}
示例7: send
import org.axonframework.commandhandling.CommandCallback; //導入依賴的package包/類
public <R> void send(Object command, CommandCallback<R> callback) {
m_cmdGw.send(command,callback);
}
示例8: HzCommandCallback
import org.axonframework.commandhandling.CommandCallback; //導入依賴的package包/類
/**
* c-tor
*
* @param callback the callback
*/
public HzCommandCallback(CommandCallback<T> callback) {
this(false, callback);
}