本文整理了Java中org.apache.camel.Message.setFault()
方法的一些代码示例,展示了Message.setFault()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.setFault()
方法的具体详情如下:
包路径:org.apache.camel.Message
类名称:Message
方法名:setFault
暂无
代码示例来源:origin: stackoverflow.com
SoapFault fault = new SoapFault("unable to process request", SoapFault.FAULT_CODE_SERVER);
Element detail = fault.getOrCreateDetail();
Document detailPayload = getYourDetailHere();
detail.appendChild(detail.getOwnerDocument().importNode(detailPayload.getDocumentElement(), true));
Message outMessage = exchange.getOut();
outMessage.setHeader(org.apache.cxf.message.Message.RESPONSE_CODE, new Integer(500));
outMessage.setFault(true);
outMessage.setBody(fault);
代码示例来源:origin: apache/servicemix
private void checkResult(String id, Exchange exchange, Person result) {
if (result == null){
exchange.getOut().setFault(true);
exchange.getOut().setBody(new PersonException(String.format(ERR_PERSON_X_NOT_FOUND, id), id));
}else{
exchange.getOut().setBody(result);
}
}
代码示例来源:origin: org.openehealth.ipf.platform-camel/ipf-platform-camel-core
public void process(Exchange exchange) throws Exception {
if (error) {
throw new RuntimeException("failed");
} else {
exchange.getOut().setBody("failed");
exchange.getOut().setFault(true);
}
}
代码示例来源:origin: nz.ac.auckland.morc/morc
@Override
public void process(Exchange exchange) throws Exception {
logger.trace("Setting fault for exchange arriving from endpoint {}",
(exchange.getFromEndpoint() != null ? exchange.getFromEndpoint().getEndpointUri() : "unknown"));
exchange.getIn().setFault(true);
exchange.getIn().setBody(getValue());
new ContentTypeTestResource("application/xml").process(exchange);
}
代码示例来源:origin: OpenNMS/opennms
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
final RpcRequest request = module.unmarshalRequest(exchange.getIn().getBody(String.class));
final CompletableFuture<RpcResponse> future = module.execute(request);
future.whenComplete((res, ex) -> {
try {
final RpcResponse response;
if (ex != null) {
// An exception occurred, store the exception in a new response
LOG.warn("An error occured while executing a call in {}.", module.getId(), ex);
response = module.createResponseWithException(ex);
} else {
// No exception occurred, use the given response
response = res;
}
try {
exchange.getOut().setBody(module.marshalResponse(response), String.class);
postProcess(exchange);
} catch (Throwable t) {
LOG.error("Marshalling a response in RPC module {} failed.", module, t);
exchange.setException(t);
exchange.getOut().setFault(true);
}
} finally {
callback.done(false);
}
});
return false;
}
代码示例来源:origin: org.opennms.core.ipc.rpc/org.opennms.core.ipc.rpc.camel
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
final RpcRequest request = module.unmarshalRequest(exchange.getIn().getBody(String.class));
final CompletableFuture<RpcResponse> future = module.execute(request);
future.whenComplete((res, ex) -> {
try {
final RpcResponse response;
if (ex != null) {
// An exception occurred, store the exception in a new response
LOG.warn("An error occured while executing a call in {}.", module.getId(), ex);
response = module.createResponseWithException(ex);
} else {
// No exception occurred, use the given response
response = res;
}
try {
exchange.getOut().setBody(module.marshalResponse(response), String.class);
postProcess(exchange);
} catch (Throwable t) {
LOG.error("Marshalling a response in RPC module {} failed.", module, t);
exchange.setException(t);
exchange.getOut().setFault(true);
}
} finally {
callback.done(false);
}
});
return false;
}
代码示例来源:origin: org.ojbc.bundles.intermediaries/subscription-notification-service-intermediary-common
outMessage.setFault(true);
代码示例来源:origin: jboss-switchyard/components
@Override
public void handleFault(final Exchange exchange) {
final Object content = exchange.getMessage().getContent();
if (content instanceof Throwable) {
_camelExchange.setException((Throwable) content);
return;
}
try {
Message camelMsg = compose(exchange);
camelMsg.setFault(true);
} catch (Exception e) {
_camelExchange.setException(e);
}
}
代码示例来源:origin: org.apache.servicemix/servicemix-camel
private void processReponse(MessageExchange messageExchange, Exchange exchange) throws MessagingException {
if (messageExchange.getStatus() == ExchangeStatus.ERROR) {
exchange.setException(messageExchange.getError());
} else if (messageExchange.getStatus() == ExchangeStatus.ACTIVE) {
// first copy the exchange headers
binding.copyPropertiesFromJbiToCamel(messageExchange, exchange);
// then copy the out/fault message
if (messageExchange.getFault() != null) {
binding.copyFromJbiToCamel(messageExchange.getMessage("fault"), exchange.getOut());
exchange.getOut().setBody(new FaultException("Fault occured for " + exchange.getPattern() + " exchange",
messageExchange, messageExchange.getFault()));
exchange.getOut().setFault(true);
} else if (messageExchange.getMessage("out") != null) {
binding.copyFromJbiToCamel(messageExchange.getMessage("out"), exchange.getOut());
}
done(messageExchange);
}
}
代码示例来源:origin: org.switchyard.components/switchyard-component-camel-switchyard
@Override
public void handleFault(final Exchange exchange) {
final Object content = exchange.getMessage().getContent();
if (content instanceof Throwable) {
try {
// SWITCHYARD-2906 - Transfer exchange properties/message headers first
mapContext(exchange, ExchangeMapper.getCamelMessage(_camelExchange, ExchangePhase.OUT));
} catch (Exception e) {
SwitchYardCamelComponentLogger.ROOT_LOGGER.failedToMapSwitchYardContextPropertiesToCamel(e);
}
_camelExchange.setException((Throwable) content);
return;
}
try {
Message camelMsg = compose(exchange);
camelMsg.setFault(true);
} catch (Exception e) {
_camelExchange.setException(e);
}
}
代码示例来源:origin: org.apache.camel/camel-jms
log.debug("Transfer fault on OUT message: {}", isFault);
if (isFault) {
exchange.getOut().setFault(true);
内容来源于网络,如有侵权,请联系作者删除!