本文整理了Java中org.apache.camel.Message.getAttachment()
方法的一些代码示例,展示了Message.getAttachment()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getAttachment()
方法的具体详情如下:
包路径:org.apache.camel.Message
类名称:Message
方法名:getAttachment
暂无
代码示例来源:origin: org.apache.camel/camel-mail
private Message extractAttachment(Message inMessage, String attachmentName) throws Exception {
final Message outMessage = new DefaultMessage(inMessage.getExchange().getContext());
outMessage.setHeader(HEADER_NAME, attachmentName);
Object attachment = inMessage.getAttachment(attachmentName).getContent();
if (attachment instanceof InputStream) {
outMessage.setBody(readMimePart((InputStream) attachment));
return outMessage;
} else if (attachment instanceof String || attachment instanceof byte[]) {
outMessage.setBody(attachment);
return outMessage;
} else {
return null;
}
}
代码示例来源: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-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;
}
代码示例来源:origin: jboss-switchyard/components
message.addAttachment(attachmentName, new HandlerDataSource(camelMessage.getAttachment(attachmentName)));
内容来源于网络,如有侵权,请联系作者删除!