本文整理汇总了Java中org.apache.camel.Exchange.setProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Exchange.setProperty方法的具体用法?Java Exchange.setProperty怎么用?Java Exchange.setProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.Exchange
的用法示例。
在下文中一共展示了Exchange.setProperty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: aggregate
import org.apache.camel.Exchange; //导入方法依赖的package包/类
@Override
public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
Exchange exchange = super.aggregate(oldExchange, newExchange);
List<Exchange> aggregatedExchanges = exchange.getProperty("CamelGroupedExchange", List.class);
// Complete aggregation if we have "numberOfSystems" (currently 3) different messages (where "system" headers are different)
// https://github.com/apache/camel/blob/master/camel-core/src/main/docs/eips/aggregate-eip.adoc#completing-current-group-decided-from-the-aggregationstrategy
if (numberOfSystems == aggregatedExchanges.stream().map(e -> e.getIn().getHeader("system", String.class)).distinct().count()) {
exchange.setProperty(Exchange.AGGREGATION_COMPLETE_CURRENT_GROUP, true);
}
return exchange;
}
示例2: process
import org.apache.camel.Exchange; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
DiskFileItemFactory factory = new DiskFileItemFactory();
factory.setRepository(new File(System.getProperty("java.io.tmpdir")));
ExchangeFileUpload upload = new ExchangeFileUpload(factory);
java.util.List<FileItem> items = upload.parseExchange(exchange);
if(items.size() >= 1){
exchange.getIn().setBody(items.get(0).getInputStream());
for (int i = 1; i < items.size(); i++) {
exchange.setProperty(items.get(i).getName(), items.get(i).getInputStream());
}
}
}
示例3: before
import org.apache.camel.Exchange; //导入方法依赖的package包/类
public void before(Exchange exchange){
// mdc
requestIdManager.generate(exchange);
// log perf
long start = System.currentTimeMillis();
exchange.setProperty(EXCHANGE_PERF_PROPERTY, start);
}
示例4: generate
import org.apache.camel.Exchange; //导入方法依赖的package包/类
public void generate(Exchange exchange) {
String requestId = generateReqId();
ThreadContext.put(REQUEST_ID, requestId);
exchange.setProperty(REQUEST_ID, requestId);
}
示例5: process
import org.apache.camel.Exchange; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
String messageToSend = generateMessagePayload(exchange.getProperty("messageSize", Integer.class));
int batchSize = exchange.getProperty("transactionBatchSize", Integer.class);
boolean transacted = exchange.getProperty("transacted", Boolean.class);
int messageCount = exchange.getProperty("messageCount", Integer.class);
// Avoid having batch size == 0
if (batchSize == 0) {
batchSize = 1;
exchange.setProperty("transactionBatchSize", batchSize);
}
// Avoid batchSize > total number of message to process
if (batchSize > messageCount) {
exchange.setProperty("transactionBatchSize", messageCount);
batchSize = messageCount;
}
exchange.setProperty("messageCount", messageCount - batchSize);
// Prepare message headers
Map<String, Object> messageHeader = null;
if (exchange.getProperty("JMSXGroupID") != null) {
messageHeader = new HashMap<String, Object>();
messageHeader.put("JMSXGroupID", exchange.getProperty("JMSXGroupID", String.class));
}
// Prepare batch messages
List<BatchMessage<String>> messages = new ArrayList<BatchMessage<String>>();
for (int i = 1; i <= batchSize; i++) {
BatchMessage<String> message = new BatchMessage<String>(messageToSend, messageHeader);
messages.add(message);
}
String destination = exchange.getProperty("destination", String.class);
Long msgTTL = exchange.getProperty("msgTTL", Long.class);
boolean persistent = exchange.getProperty("persistent", Boolean.class);
String sjmsUri = "sjms:" + destination +
"?ttl=" + msgTTL +
"&persistent=" + persistent +
"&transacted=" + transacted;
exchange.setProperty("sjmsUri", sjmsUri);
exchange.getIn().setBody(messages);
}
示例6: process
import org.apache.camel.Exchange; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
Message requestMessage = exchange.getIn();
if (requestMessage.getHeader("messageCount") != null) {
exchange.setProperty("messageCount", requestMessage.getHeader("messageCount", Integer.class));
exchange.setProperty("messageToSend", requestMessage.getHeader("messageCount", Integer.class));
} else {
exchange.setProperty("messageCount", messageCount);
exchange.setProperty("messageToSend", messageCount);
}
if (requestMessage.getHeader("messageSize") != null) {
exchange.setProperty("messageSize", requestMessage.getHeader("messageSize", Integer.class));
} else {
exchange.setProperty("messageSize", messageSize);
}
if (requestMessage.getHeader("transactionBatchSize") != null) {
exchange.setProperty("transactionBatchSize", requestMessage.getHeader("transactionBatchSize", Integer.class));
exchange.setProperty("requestTransactionBatchSize", requestMessage.getHeader("transactionBatchSize", Integer.class));
} else {
exchange.setProperty("transactionBatchSize", transactionBatchSize);
}
if (requestMessage.getHeader("transacted") != null) {
exchange.setProperty("transacted", requestMessage.getHeader("transacted", Boolean.class));
} else {
exchange.setProperty("transacted", transacted);
}
if (requestMessage.getHeader("msgTTL") != null) {
exchange.setProperty("msgTTL", requestMessage.getHeader("msgTTL",Long.class));
} else {
exchange.setProperty("msgTTL", msgTTL);
}
if (requestMessage.getHeader("persistent") != null) {
exchange.setProperty("persistent", requestMessage.getHeader("persistent", Boolean.class));
} else {
exchange.setProperty("persistent", persistent);
}
if (requestMessage.getHeader("msgGroupID") != null)
exchange.setProperty("JMSXGroupID", requestMessage.getHeader("msgGroupID", String.class));
exchange.setProperty("destination", requestMessage.getHeader("destination",String.class));
}
示例7: setFailureHandled
import org.apache.camel.Exchange; //导入方法依赖的package包/类
private static void setFailureHandled(Exchange exchange) {
exchange.setProperty(Exchange.EXCEPTION_CAUGHT, exchange.getException());
exchange.setProperty(Exchange.ERRORHANDLER_HANDLED, Boolean.TRUE);
exchange.setException(null);
}