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