org.apache.camel.Message.getAttachmentNames()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(2.8k)|赞(0)|评价(0)|浏览(177)

本文整理了Java中org.apache.camel.Message.getAttachmentNames()方法的一些代码示例,展示了Message.getAttachmentNames()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getAttachmentNames()方法的具体详情如下:
包路径:org.apache.camel.Message
类名称:Message
方法名:getAttachmentNames

Message.getAttachmentNames介绍

暂无

代码示例

代码示例来源:origin: org.apache.servicemix/servicemix-camel

public void copyFromCamelToJbi(Message message, NormalizedMessage normalizedMessage) throws MessagingException {
  if (message != null && message.getBody() != null) {
    Source body = message.getBody(Source.class);
    if (body == null) {
      logger.warn("Unable to convert message body of type {} into an XML Source", message.getBody().getClass());
    } else {
      normalizedMessage.setContent(body);
    }
  }
  
  Subject securitySubject = getSecuritySubject(message);
  if (securitySubject != null) {
    normalizedMessage.setSecuritySubject(securitySubject);
  }
  Exchange exchange = message.getExchange();
  for (Map.Entry<String, Object> entry : message.getHeaders().entrySet()) {
    String key = entry.getKey();
    Object value = entry.getValue();
    if (value != null && !strategies.applyFilterToCamelHeaders(key, value, exchange)) {
      normalizedMessage.setProperty(key, value);
    }
  }
  
  for (String id : message.getAttachmentNames()) {
    normalizedMessage.addAttachment(id, message.getAttachment(id));
  }
}

代码示例来源:origin: org.switchyard.components/switchyard-component-common-camel

Set<String> attachements = sourceMessage.getAttachmentNames();
if (!attachements.isEmpty()) {
  for (Entry<String, DataHandler> entry : sourceMessage.getAttachments().entrySet()) {

代码示例来源:origin: jboss-switchyard/components

Set<String> attachements = sourceMessage.getAttachmentNames();
if (!attachements.isEmpty()) {
  for (Entry<String, DataHandler> entry : sourceMessage.getAttachments().entrySet()) {

代码示例来源:origin: jboss-switchyard/components

for (String attachmentName : camelMessage.getAttachmentNames()) {
  message.addAttachment(attachmentName, new HandlerDataSource(camelMessage.getAttachment(attachmentName)));

代码示例来源:origin: org.switchyard.components/switchyard-component-camel-switchyard

/**
 * Map from a camel exchange to a SwitchYard exchange.
 * @param camelExchange the camel exchange
 * @param syExchange the switchyard exchange
 * @param phase ExchangePhase.IN to target camelExchange.getIn(), ExchangePhase.OUT to 
 * target camelExchange.getIn().
 * @return the 
 */
public static org.switchyard.Message mapCamelToSwitchYard(
    org.apache.camel.Exchange camelExchange,
    org.switchyard.Exchange syExchange,
    ExchangePhase phase) {
  
  // Associate the correct Camel message with the SY exchange
  org.switchyard.Message message = syExchange.createMessage();
  org.apache.camel.Message camelMessage =
      mapCamelPropertiesToSwitchYard(camelExchange, message.getContext(), phase);
  message.setContent(camelMessage.getBody());
  
  for (String attachmentName : camelMessage.getAttachmentNames()) {
    message.addAttachment(attachmentName, new HandlerDataSource(camelMessage.getAttachment(attachmentName)));
  }
  
  return message;
}

相关文章