當前位置: 首頁>>代碼示例>>Java>>正文


Java Exchange.getProperty方法代碼示例

本文整理匯總了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;
}
 
開發者ID:mgyongyosi,項目名稱:camel-cookbook,代碼行數:15,代碼來源:SignalAggregationStrategy.java

示例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);
  }
}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:11,代碼來源:AbstractLogicConsumer.java

示例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);
}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:11,代碼來源:PerformanceLogHelper.java

示例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);
}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:16,代碼來源:PerformanceLogHelper.java

示例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);
}
 
開發者ID:eXcellme,項目名稱:eds,代碼行數:5,代碼來源:RequestIdManager.java

示例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);
}
 
開發者ID:jeanNyil,項目名稱:fis-amq-producer,代碼行數:50,代碼來源:PrepareHttpResponseProcessor.java

示例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);
}
 
開發者ID:jeanNyil,項目名稱:fis-amq-producer,代碼行數:50,代碼來源:JmsTransactionBatchProcessor.java

示例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");
}
 
開發者ID:syndesisio,項目名稱:syndesis,代碼行數:8,代碼來源:AdaptObjectForUpdateProcessor.java


注:本文中的org.apache.camel.Exchange.getProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。