本文整理了Java中org.apache.camel.Message.getHeader()
方法的一些代码示例,展示了Message.getHeader()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getHeader()
方法的具体详情如下:
包路径:org.apache.camel.Message
类名称:Message
方法名:getHeader
暂无
代码示例来源:origin: org.apache.camel/camel-example-loan-broker
public void process(Exchange exchange) throws Exception {
String bankName = exchange.getIn().getHeader(Constants.PROPERTY_BANK, String.class);
String ssn = exchange.getIn().getHeader(Constants.PROPERTY_SSN, String.class);
Double rate = exchange.getIn().getHeader(Constants.PROPERTY_RATE, Double.class);
String answer = "The best rate is [ssn:" + ssn + " bank:" + bankName + " rate:" + rate + "]";
exchange.getOut().setBody(answer);
}
代码示例来源:origin: camelinaction/camelinaction2
public void process(Exchange exchange) throws Exception {
System.out.println("Production received order: "
+ exchange.getIn().getHeader("CamelFileName"));
}
});
代码示例来源:origin: OpenNMS/opennms
@Override
public void postProcess(Exchange exchange) {
// Copy the value of the correlation id header from the in to the out
exchange.getOut().setHeader(AmazonSQSRPCConstants.AWS_SQS_CORRELATION_ID_HEADER,
exchange.getIn().getHeader(AmazonSQSRPCConstants.AWS_SQS_CORRELATION_ID_HEADER));
}
}
代码示例来源:origin: org.apache.camel/camel-infinispan
private void setResult(Message message, Object result) {
String resultHeader = message.getHeader(InfinispanConstants.RESULT_HEADER, configuration::getResultHeader, String.class);
if (resultHeader != null) {
message.setHeader(resultHeader, result);
} else {
message.setBody(result);
}
}
}
代码示例来源:origin: org.ojbc.bundles.prototypes.shared/Bundle_Integration_Test_Common
public void appendMessage(Exchange e) throws Exception {
Message m = e.getIn();
String s = m.getHeader("s", String.class);
String body = m.getBody(String.class);
m.setBody(body + "\n" + s);
}
代码示例来源:origin: org.apache.camel/camel-gae
protected void writeRequestHeaders(GHttpEndpoint endpoint, Exchange exchange, HTTPRequest request) {
HeaderFilterStrategy strategy = endpoint.getHeaderFilterStrategy();
for (String headerName : exchange.getIn().getHeaders().keySet()) {
String headerValue = exchange.getIn().getHeader(headerName, String.class);
if (strategy != null && !strategy.applyFilterToCamelHeaders(headerName, headerValue, exchange)) {
request.addHeader(new HTTPHeader(headerName, headerValue));
}
}
}
代码示例来源:origin: org.apache.camel/camel-example-cxf
public void process(Exchange exchange) throws Exception {
String operationName = exchange.getIn().getHeader(CxfConstants.OPERATION_NAME, String.class);
Method method = findMethod(operationName, exchange.getIn().getBody(Object[].class));
try {
Object response = method.invoke(instance, exchange.getIn().getBody(Object[].class));
exchange.getOut().setBody(response);
} catch (InvocationTargetException e) {
throw (Exception)e.getCause();
}
}
代码示例来源:origin: camelinaction/camelinaction2
public void process(Exchange exchange) throws Exception {
System.out.println("Accounting received order: "
+ exchange.getIn().getHeader("CamelFileName"));
}
});
代码示例来源:origin: org.apache.camel/camel-ignite
@SuppressWarnings("unchecked")
private void doSize(Message in, Message out) {
Object peekMode = in.getHeader(IgniteConstants.IGNITE_CACHE_PEEK_MODE, endpoint.getCachePeekMode());
Integer result = null;
if (peekMode instanceof Collection) {
result = cache.size(((Collection<Object>) peekMode).toArray(new CachePeekMode[0]));
} else if (peekMode instanceof CachePeekMode) {
result = cache.size((CachePeekMode) peekMode);
}
out.setBody(result);
}
代码示例来源:origin: org.ojbc.bundles.shared/ojb-fedquery-common
@SuppressWarnings("unchecked")
public void updateExchange(Exchange groupedExchange)
{
List<Exchange> exchangeList = groupedExchange.getProperty(Exchange.GROUPED_EXCHANGE, List.class);
if (exchangeList.size() == 1)
{
Exchange orignalBookingExchange = exchangeList.get(0);
String federatedQueryGUID = (String) orignalBookingExchange.getIn().getHeader("federatedQueryRequestGUID");
groupedExchange.getIn().setBody(orignalBookingExchange.getIn().getHeader("requestMessageBody"));
groupedExchange.getIn().setHeader("federatedQueryRequestGUID", federatedQueryGUID);
}
}
代码示例来源:origin: org.opennms.core.ipc.rpc/org.opennms.core.ipc.rpc.aws-sqs-impl
@Override
public void postProcess(Exchange exchange) {
// Copy the value of the correlation id header from the in to the out
exchange.getOut().setHeader(AmazonSQSRPCConstants.AWS_SQS_CORRELATION_ID_HEADER,
exchange.getIn().getHeader(AmazonSQSRPCConstants.AWS_SQS_CORRELATION_ID_HEADER));
}
}
代码示例来源:origin: Simba-cheng/ApacheCamelDemo
@Override
public void process(Exchange exchange) throws Exception {
String inputMessage = exchange.getIn().getBody(String.class);
LOGGER.info("inputMessage : " + inputMessage);
String operationName = exchange.getIn().getHeader(CxfConstants.OPERATION_NAME, String.class);
Method method = findMethod(operationName, exchange.getIn().getBody(Object[].class));
Object response = method.invoke(instance, exchange.getIn().getBody(Object[].class));
exchange.getOut().setBody(response);
}
代码示例来源:origin: org.apache.camel/camel-dropbox
public static String getLocalPath(DropboxConfiguration configuration, Exchange exchange) {
return ObjectHelper.isNotEmpty(
exchange.getIn().getHeader(DropboxConstants.HEADER_LOCAL_PATH))
? exchange.getIn().getHeader(DropboxConstants.HEADER_LOCAL_PATH, String.class)
: configuration.getLocalPath();
}
代码示例来源:origin: org.apache.camel/camel-web3j
@InvokeOnHeader(Web3jConstants.DB_PUT_HEX)
void dbPutHex(Message message) throws IOException {
String databaseName = message.getHeader(Web3jConstants.DATABASE_NAME, configuration::getDatabaseName, String.class);
String keyName = message.getHeader(Web3jConstants.KEY_NAME, configuration::getKeyName, String.class);
Request<?, DbPutHex> request = web3j.dbPutHex(databaseName, keyName, message.getBody(String.class));
setRequestId(message, request);
DbPutHex response = request.send();
boolean hasError = checkForError(message, response);
if (!hasError) {
message.setBody(response.valueStored());
}
}
代码示例来源:origin: org.apache.camel/camel-jcache
@Override
void execute(Cache<Object, Object> cache, Exchange exchange) {
exchange.getIn().setBody(
cache.getAndReplace(
exchange.getIn().getHeader(JCacheConstants.KEY),
exchange.getIn().getBody())
);
}
},
代码示例来源:origin: org.fusesource.bai/bai-core
protected String getBreadCrumbId(Exchange source) {
String bid = source.getIn().getHeader(Exchange.BREADCRUMB_ID, String.class);
if (bid == null && source.hasOut()) {
bid = source.getOut().getHeader(Exchange.BREADCRUMB_ID, String.class);
}
return bid;
}
代码示例来源:origin: org.apache.camel/camel-digitalocean
private void restoreDroplet(Exchange exchange) throws Exception {
if (ObjectHelper.isEmpty(exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID))) {
throw new IllegalArgumentException(DigitalOceanHeaders.IMAGE_ID + " must be specified");
}
Action action = getEndpoint().getDigitalOceanClient().restoreDroplet(dropletId, exchange.getIn().getHeader(DigitalOceanHeaders.IMAGE_ID, Integer.class));
LOG.trace("DropletAction Restore [{}] ", action);
exchange.getOut().setBody(action);
}
代码示例来源:origin: stackoverflow.com
// Note: Content Type - might need treatment!
public class AttachmentAttacher{
public void process(Exchange exchange){
Message in = exchange.getIn();
byte[] file = in.getBody(byte[].class);
String fileId = in.getHeader("CamelFileName",String.class);
in.addAttachment(fileId, new DataHandler(file,"plain/text"));
}
}
代码示例来源:origin: org.apache.camel/camel-web3j
@InvokeOnHeader(Web3jConstants.ETH_SIGN)
void ethSign(Message message) throws IOException {
String address = message.getHeader(Web3jConstants.ADDRESS, configuration::getAddress, String.class);
String sha3HashOfDataToSign = message.getHeader(Web3jConstants.SHA3_HASH_OF_DATA_TO_SIGN, configuration::getSha3HashOfDataToSign, String.class);
Request<?, EthSign> request = web3j.ethSign(address, sha3HashOfDataToSign);
setRequestId(message, request);
EthSign response = request.send();
boolean hasError = checkForError(message, response);
if (!hasError) {
message.setBody(response.getSignature());
}
}
代码示例来源:origin: org.apache.camel/camel-jcache
@Override
void execute(Cache<Object, Object> cache, Exchange exchange) {
exchange.getIn().setBody(
cache.getAndPut(
exchange.getIn().getHeader(JCacheConstants.KEY),
exchange.getIn().getBody())
);
}
},
内容来源于网络,如有侵权,请联系作者删除!