本文整理汇总了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);
}