本文整理汇总了Java中org.apache.camel.Exchange.getProperty方法的典型用法代码示例。如果您正苦于以下问题:Java Exchange.getProperty方法的具体用法?Java Exchange.getProperty怎么用?Java Exchange.getProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.camel.Exchange
的用法示例。
在下文中一共展示了Exchange.getProperty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 {
try {
String requestId = exchange.getProperty(RequestIdManager.REQUEST_ID, String.class);
ThreadContext.put(RequestIdManager.REQUEST_ID, requestId);
doProcess(exchange);
} finally {
ThreadContext.remove(RequestIdManager.REQUEST_ID);
}
}
示例3: success
import org.apache.camel.Exchange; //导入方法依赖的package包/类
public void success(Exchange exchange){
Object obj = exchange.getProperty(EXCHANGE_PERF_PROPERTY);
long cost = -1;
if(obj != null){
cost = System.currentTimeMillis() - (long) obj;
exchange.removeProperty(EXCHANGE_PERF_PROPERTY);
}
logger.debug("success|{}|{}|{}",cost,exchange.getIn().getHeaders(),exchange.getIn().getBody());
requestIdManager.clean(exchange);
}
示例4: error
import org.apache.camel.Exchange; //导入方法依赖的package包/类
public void error(Exchange exchange){
Object obj = exchange.getProperty(EXCHANGE_PERF_PROPERTY);
long cost = -1;
if(obj != null){
cost = System.currentTimeMillis() - (long) obj;
exchange.removeProperty(EXCHANGE_PERF_PROPERTY);
}
String ex = "";
if(exchange.getException() != null){
ex = exchange.getException().getMessage();
exchange.removeProperty(EXCHANGE_PERF_PROPERTY);
}
logger.debug("error{}|{}|{}|{}",ex,cost,exchange.getIn().getHeaders(),exchange.getIn().getBody());
requestIdManager.clean(exchange);
}
示例5: currentRequestId
import org.apache.camel.Exchange; //导入方法依赖的package包/类
public static String currentRequestId(Exchange exchange) {
return exchange == null ? ThreadContext.get(REQUEST_ID)
: exchange.getProperty(REQUEST_ID, String.class);
}
示例6: process
import org.apache.camel.Exchange; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {
int messageCount = exchange.getProperty("messageToSend", Integer.class);
int transactionBatchSize = new Integer(exchange.getContext().resolvePropertyPlaceholders("{{default.transaction.batch.size}}"));
if (exchange.getProperty("requestTransactionBatchSize") != null)
transactionBatchSize = exchange.getProperty("requestTransactionBatchSize", Integer.class);
boolean transacted = new Boolean(exchange.getContext().resolvePropertyPlaceholders("{{default.transacted}}"));
if (exchange.getProperty("transacted") != null)
transacted = exchange.getProperty("transacted", Boolean.class);
int messageSize = new Integer(exchange.getContext().resolvePropertyPlaceholders("{{default.message.size}}"));
long msgTTL = new Long(exchange.getContext().resolvePropertyPlaceholders("{{default.message.ttl}}"));
if (exchange.getProperty("msgTTL") != null) {
msgTTL = exchange.getProperty("msgTTL", Long.class);
}
String deliveryMode = "PERSISTENT";
if (exchange.getProperty("persistent") != null) {
if (exchange.getProperty("persistent",String.class).equalsIgnoreCase("false"))
deliveryMode = "NON_PERSISTENT";
}
String jmsxGroupID = null;
if (exchange.getProperty("messageSize") != null) {
messageSize = exchange.getProperty("messageSize", Integer.class);
}
if (exchange.getProperty("JMSXGroupID") != null) {
jmsxGroupID = exchange.getProperty("JMSXGroupID", String.class);
}
String amqServiceName = exchange.getContext().resolvePropertyPlaceholders("{{activemq.service.name}}");
String message =
messageCount + " JMS Messages published to " +
"[" + exchange.getProperty("destination", String.class) + "] " +
"in " + exchange.getProperty("duration") + " :\n" +
"- AMQ Service Name in OpenShift: " + amqServiceName + " \n" +
"- Message size: " + messageSize + " bytes\n" +
"- Delivery mode: " + deliveryMode + "\n" +
"- Message TTL (JMSExpiration): " + msgTTL + " ms\n";
if (jmsxGroupID != null)
message += "- Message group (JMSXGroupID) : " + jmsxGroupID + "\n";
message += "- Transaction batch size: " + transactionBatchSize + "\n" +
"- Transaction activated: " + transacted + "\n";
exchange.getIn().setBody(message);
}
示例7: 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);
}
示例8: determineIdProperty
import org.apache.camel.Exchange; //导入方法依赖的package包/类
private String determineIdProperty(final Exchange exchange) throws URISyntaxException {
final String uri = exchange.getProperty(Exchange.TO_ENDPOINT, String.class);
final Map<String, Object> endpointParameters = URISupport.parseParameters(URI.create(uri));
return (String) endpointParameters.getOrDefault(SalesforceEndpointConfig.SOBJECT_EXT_ID_NAME, "Id");
}