当前位置: 首页>>代码示例>>Java>>正文


Java DefaultMessage.setBody方法代码示例

本文整理汇总了Java中org.apache.camel.impl.DefaultMessage.setBody方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultMessage.setBody方法的具体用法?Java DefaultMessage.setBody怎么用?Java DefaultMessage.setBody使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.impl.DefaultMessage的用法示例。


在下文中一共展示了DefaultMessage.setBody方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: splitMessage

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
/**
 * The split message method returns something that is iteratable such as a java.util.List.
 *
 * @param header the header of the incoming message with the name user
 * @param body the payload of the incoming message
 * @return a list containing each part splitted
 */
public List<Message> splitMessage(@Header(value = "user") String header, @Body String body) {
    // we can leverage the Parameter Binding Annotations  
    // http://camel.apache.org/parameter-binding-annotations.html
    // to access the message header and body at same time, 
    // then create the message that we want, splitter will
    // take care rest of them.
    // *NOTE* this feature requires Camel version >= 1.6.1
    List<Message> answer = new ArrayList<Message>();
    String[] parts = header.split(",");
    for (String part : parts) {
        DefaultMessage message = new DefaultMessage();
        message.setHeader("user", part);
        message.setBody(body);
        answer.add(message);
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:SplitterPojoTest.java

示例2: mapSwitchYardToCamel

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
/**
 * Maps a SwitchYard exchange to a Camel exchange.  Keep in mind that the camel message created
 * during mapping is *not* associate with the exchange.  You need to call setIn() or setOut() 
 * with the returned reference depending on your use case.
 * @param syExchange switchyard exchange
 * @param camelExchange camel exchange
 * @return mapped camel message
 */
public static DefaultMessage mapSwitchYardToCamel(
        org.switchyard.Exchange syExchange,
        org.apache.camel.Exchange camelExchange) {
    
    DefaultMessage camelMessage = new SwitchYardMessage();
    camelMessage.setBody(syExchange.getMessage().getContent());
    
    mapSwitchYardPropertiesToCamel(syExchange.getContext(), camelExchange, camelMessage);
    
    for (String attachmentName : syExchange.getMessage().getAttachmentMap().keySet()) {
        camelMessage.addAttachment(attachmentName, 
                new DataHandler(syExchange.getMessage().getAttachment(attachmentName)));
    }
    
    return camelMessage;
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:25,代码来源:ExchangeMapper.java

示例3: toCamelMessage

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
/**
 * Converts from a Camel message to a HzMq message. The headers are simply
 * copied unmodified. The body is mapped by type:
 * <ul>
 * <li>If the content type is text/plain, the body is set as a String</li>
 * <li>all others: the body is set as a byte[] (or null)</li>
 * </ul>
 *
 * @param mqMsg the HzMq message to convert
 *
 * @return the new Camel message
 */
@Override
public Message toCamelMessage(HazelcastMQMessage mqMsg) {
  DefaultMessage camelMsg = new DefaultMessage();

  camelMsg.setHeaders((Map) mqMsg.getHeaders().getHeaderMap());

  if (mqMsg.getContentType() != null && mqMsg.getContentType().equals(
      "text/plain")) {
    camelMsg.setBody(mqMsg.getBodyAsString());
  }
  else {
    camelMsg.setBody(mqMsg.getBody());
  }

  return camelMsg;
}
 
开发者ID:mpilone,项目名称:hazelcastmq,代码行数:29,代码来源:DefaultMessageConverter.java

示例4: splitProducts

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
public List<Message> splitProducts(Order order){

        List<Message> messages = new ArrayList<Message>();

        for(Item item : order.getItems()){

            ProductOrder po = new ProductOrder();
            po.setCustomer(order.getCustomer());
            po.setProduct(item.getProduct());
            po.setQuanitity(item.getQuantity());

            DefaultMessage message = new DefaultMessage();
            message.setBody(po);

            //Set the header with the manufacturer
            if (item.getProduct().startsWith("abc")) {
                message.setHeader("manufacturer", "abc");
            } else if(item.getProduct().startsWith("xyz")) {
                message.setHeader("manufacturer", "xyz");
            }

            messages.add(message);

        }

        return messages;
    }
 
开发者ID:jgoodyear,项目名称:fsto,代码行数:28,代码来源:ProductSplitter.java

示例5: createCamelExchange

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
/**
 * Create a camel exchange
 * @return exchange
 */
private Exchange createCamelExchange() {
    DefaultMessage message = new DefaultMessage();
    message.setBody("foobar");
    message.setExchange(new DefaultExchange(new SwitchYardCamelContextImpl(false)));
    return message.getExchange();
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:11,代码来源:ExchangeMapperTests.java

示例6: sendMessage

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
protected void sendMessage(final String uri, final Object obj) {
    Exchange exchange = new DefaultExchange(contextFactory.getContext());

    DefaultMessage message = new DefaultMessage(camelContext);
    message.setBody(obj);
    exchange.setIn(message);

    ProducerTemplate template = contextFactory.getContext().createProducerTemplate();
    template.send(uri, exchange);
}
 
开发者ID:apache,项目名称:syncope,代码行数:11,代码来源:AbstractCamelProvisioningManager.java

示例7: createExchange

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
public Exchange createExchange(Object pojo) {
    DefaultMessage msg = new DefaultMessage();
    msg.setBody(pojo);
    DefaultExchange exchange = new DefaultExchange(this, getExchangePattern());
    exchange.setIn(msg);
    return exchange;
}
 
开发者ID:jboss-integration,项目名称:fuse-bxms-integ,代码行数:8,代码来源:KieEndpoint.java

示例8: createExhangeWithBody

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
private static Exchange createExhangeWithBody(final String payload) {
    final Exchange exchange = new DefaultExchange(CONTEXT);

    final DefaultMessage in = new DefaultMessage(CONTEXT);
    exchange.setIn(in);

    in.setBody(payload);

    return exchange;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:11,代码来源:PayloadConverterTest.java

示例9: process

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
@Override
public void process(Exchange exchange) throws Exception {

    DefaultMessage message = new DefaultMessage();
    message.setBody("current time: " + new Date());

    exchange.setOut(message);

}
 
开发者ID:java-course-ee,项目名称:java-course-ee,代码行数:10,代码来源:InputGenerator.java

示例10: fillFromDataValue

import org.apache.camel.impl.DefaultMessage; //导入方法依赖的package包/类
/**
 * Fill a Message from a DataValue
 *
 * @param value
 *            the value to feed from
 * @param result
 *            the result to feed to
 */
public static void fillFromDataValue(final DataValue value, final DefaultMessage result) {
	result.setBody(value);
	result.setFault(value.getStatusCode().isBad());
}
 
开发者ID:ctron,项目名称:de.dentrassi.camel.milo,代码行数:13,代码来源:Messages.java


注:本文中的org.apache.camel.impl.DefaultMessage.setBody方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。