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


Java DefaultMessage类代码示例

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


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

示例1: testTheCopyOfHeaders

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void testTheCopyOfHeaders() {
  Message msg = new DefaultMessage();
  msg.setHeader("CamelRedelivered", false);
  msg.setHeader("CamelRedeliveryCounter", 0);
  msg.setHeader("JMSCorrelationID", "");
  msg.setHeader("JMSDestination", "queue://dev.msy.queue.log.fwd");
  msg.setHeader("JMSReplyTo", null);

  DeliveryOptions options = CamelHelper.getDeliveryOptions(msg, true);

  assertThat(options.getHeaders().get("CamelRedelivered")).isEqualToIgnoringCase("false");
  assertThat(options.getHeaders().get("CamelRedeliveryCounter")).isEqualToIgnoringCase("0");
  assertThat(options.getHeaders().get("JMSCorrelationID")).isEqualToIgnoringCase("");
  assertThat(options.getHeaders().get("JMSDestination")).isEqualToIgnoringCase("queue://dev.msy.queue.log.fwd");
  assertThat(options.getHeaders().get("JMSReplyTo")).isNull();

}
 
开发者ID:vert-x3,项目名称:vertx-camel-bridge,代码行数:19,代码来源:CamelHelperTest.java

示例2: 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

示例3: testIteratorWithMessage

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
public void testIteratorWithMessage() {
    Message msg = new DefaultMessage();
    msg.setBody("a,b,c");

    Iterator<?> it = ObjectHelper.createIterator(msg);
    assertEquals("a", it.next());
    assertEquals("b", it.next());
    assertEquals("c", it.next());
    assertFalse(it.hasNext());
    try {
        it.next();
        fail("Should have thrown exception");
    } catch (NoSuchElementException nsee) {
        // expected
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:ObjectHelperTest.java

示例4: toCamelMessage

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Override
public Message toCamelMessage(HttpServerExchange httpExchange, Exchange exchange) throws Exception {
    Message result = new DefaultMessage();

    populateCamelHeaders(httpExchange, result.getHeaders(), exchange);

    //extract body if the method is allowed to have one
    //body is extracted as byte[] then auto TypeConverter kicks in
    if (Methods.POST.equals(httpExchange.getRequestMethod()) || Methods.PUT.equals(httpExchange.getRequestMethod())) {
        result.setBody(readFromChannel(httpExchange.getRequestChannel()));
    } else {
        result.setBody(null);
    }

    return result;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:DefaultUndertowHttpBinding.java

示例5: getNextElement

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
private Message getNextElement() {
    if (zipInputStream == null) {
        return null;
    }
    
    try {
        ZipEntry current = getNextEntry();

        if (current != null) {
            LOGGER.debug("read zipEntry {}", current.getName());
            Message answer = new DefaultMessage();
            answer.getHeaders().putAll(inputMessage.getHeaders());
            answer.setHeader("zipFileName", current.getName());
            answer.setHeader(Exchange.FILE_NAME, current.getName());
            answer.setBody(new ZipInputStreamWrapper(zipInputStream));
            return answer;
        } else {
            LOGGER.trace("close zipInputStream");
            return null;
        }
    } catch (IOException exception) {
        //Just wrap the IOException as CamelRuntimeException
        throw new RuntimeCamelException(exception);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:26,代码来源:ZipIterator.java

示例6: testSearch

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void testSearch() throws Exception {
    String dn = "some dn";
    String filter = "filter";
    Integer scope = SearchControls.SUBTREE_SCOPE;

    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();

    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.DN, dn);
    body.put(SpringLdapProducer.FILTER, filter);

    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.SEARCH);
    when(ldapEndpoint.scopeValue()).thenReturn(scope);

    processBody(exchange, in, body);
    verify(ldapTemplate).search(eq(dn), eq(filter), eq(scope),
            any(AttributesMapper.class));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:SpringLdapProducerTest.java

示例7: testBind

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void testBind() throws Exception {
    String dn = "some dn";
    BasicAttributes attributes = new BasicAttributes();

    Exchange exchange = new DefaultExchange(context);
    Message in = new DefaultMessage();

    Map<String, Object> body = new HashMap<String, Object>();
    body.put(SpringLdapProducer.DN, dn);
    body.put(SpringLdapProducer.ATTRIBUTES, attributes);

    when(ldapEndpoint.getOperation()).thenReturn(LdapOperation.BIND);

    processBody(exchange, in, body);
    verify(ldapTemplate).bind(eq(dn), isNull(), eq(attributes));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:18,代码来源:SpringLdapProducerTest.java

示例8: createCamelMessage

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
public Message createCamelMessage(ServerSession remote, ServerMessage cometdMessage, Object data) {
    if (cometdMessage != null) {
        data = cometdMessage.getData();
    }

    Message message = new DefaultMessage();
    message.setBody(data);
    Map headers = getHeadersFromMessage(cometdMessage);
    if (headers != null) {
        message.setHeaders(headers);
    }
    message.setHeader(COMETD_CLIENT_ID_HEADER_NAME, remote.getId());

    if (cometdMessage != null && cometdMessage.get(COMETD_SUBSCRIPTION_HEADER_NAME) != null) {
        message.setHeader(COMETD_SUBSCRIPTION_HEADER_NAME, cometdMessage.get(COMETD_SUBSCRIPTION_HEADER_NAME));
    }
    
    if (enableSessionHeader) {
        addSessionAttributesToMessageHeaders(remote, message);
    }

    return message;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:24,代码来源:CometdBinding.java

示例9: createRouteBuilder

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
private RouteBuilder createRouteBuilder() {
    return new RouteBuilder() {
        public void configure() {
            CometdComponent component = (CometdComponent) context.getComponent("cometds");
            component.setSslPassword(pwd);
            component.setSslKeyPassword(pwd);
            File file = new File("./src/test/resources/jsse/localhost.ks");
            URI keyStoreUrl = file.toURI();
            component.setSslKeystore(keyStoreUrl.getPath());

            from(URI, URIS).setExchangePattern(ExchangePattern.InOut).process(new Processor() {
                public void process(Exchange exchange) throws Exception {
                    Message out = new DefaultMessage();
                    out.setBody("reply: " + exchange.getIn().getBody());
                    exchange.setOut(out);
                }
            });
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:CometdProducerConsumerInOutInteractiveMain.java

示例10: errSegmentsAreInjected

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void errSegmentsAreInjected() throws Exception {
	Exchange exchange = new DefaultExchange(camelContext);
	Message ackMessage = new DefaultMessage();
	ORU_R01 oruMessage = (ORU_R01) hapiContext.getGenericParser().parse(hl7Input);
	
	List<HL7Exception> validationErrors = new ArrayList<HL7Exception>();
	validationErrors.add(new ProfileNotFollowedException(VALIDATION_ERROR_TEXT));
	
	ACK ack = (ACK) oruMessage.generateACK(AcknowledgmentCode.AR, new ProfileNotFollowedException("desc"));
	ackMessage.setBody(ack);
	exchange.setIn(ackMessage);
	ackMessage.setHeader(ProfileValidationProcessor.VALIDATION_ERRORS_HEADER, validationErrors);
	ackMessage.setHeader(ProfileValidationProcessor.DEVICE_ID_LIST_HEADER, deviceIds);
	
	validationErrorAckProcessor.process(exchange);
	
	Terser terser = new Terser(ack);
	assertEquals(VALIDATION_ERROR_TEXT, terser.get("/ERR(0)-7"));
	assertEquals(MOCK_DEVICE, terser.get("/ERR(1)-7"));
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:22,代码来源:ValidationErrorAckProcessorTest.java

示例11: timeWithoutZoneIsChanged

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void timeWithoutZoneIsChanged() throws Exception {
	Exchange exchange = new DefaultExchange(camelContext);
	Message message = new DefaultMessage();
	
	ORU_R01 oruMessage = (ORU_R01) hapiContext.getGenericParser().parse(hl7InputNoTimeZone);
	message.setBody(oruMessage);
	exchange.setIn(message);
	
	DTM messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(-99, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	timeAdjustmentProcessor.process(exchange);
	messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(200, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	DTM obrDtm = oruMessage.getPATIENT_RESULT(0).getORDER_OBSERVATION(0).getOBR().getObr7_ObservationDateTime();
	
	assertEquals(200, obrDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:26,代码来源:TimeAdjustmentProcessorTest.java

示例12: timeWithZoneIsNotChanged

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void timeWithZoneIsNotChanged() throws Exception {
	Exchange exchange = new DefaultExchange(camelContext);
	Message message = new DefaultMessage();
	
	ORU_R01 oruMessage = (ORU_R01) hapiContext.getGenericParser().parse(hl7InputWithTimeZone);
	message.setBody(oruMessage);
	exchange.setIn(message);
	
	DTM messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(200, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	timeAdjustmentProcessor.process(exchange);
	messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(200, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:21,代码来源:TimeAdjustmentProcessorTest.java

示例13: timeWithUtcZoneIsNotChanged

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void timeWithUtcZoneIsNotChanged() throws Exception {
	Exchange exchange = new DefaultExchange(camelContext);
	Message message = new DefaultMessage();
	
	ORU_R01 oruMessage = (ORU_R01) hapiContext.getGenericParser().parse(hl7InputWithUtcTimeZone);
	message.setBody(oruMessage);
	exchange.setIn(message);
	
	DTM messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(0, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
	
	timeAdjustmentProcessor.process(exchange);
	messageDtm = oruMessage.getMSH().getDateTimeOfMessage();
	
	assertEquals(0, messageDtm.getGMTOffset());
	assertEquals(MOCK_HOURS, messageDtm.getHour());
}
 
开发者ID:sll-mdilab,项目名称:t5-doc,代码行数:21,代码来源:TimeAdjustmentProcessorTest.java

示例14: 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

示例15: createNeutronNetwork

import org.apache.camel.impl.DefaultMessage; //导入依赖的package包/类
@Test
public void createNeutronNetwork() throws Exception {
    CamelContext camelContext = Mockito.mock(CamelContext.class);
    when(camelContext.getHeadersMapFactory()).thenReturn(new DefaultHeadersMapFactory());

    Message msg = new DefaultMessage(camelContext);
    Exchange exchange = Mockito.mock(Exchange.class);
    when(exchange.getIn()).thenReturn(msg);

    msg.setHeader(OpenstackConstants.OPERATION, OpenstackConstants.CREATE);
    msg.setHeader(OpenstackConstants.NAME, dummyNetwork.getName());
    msg.setHeader(NeutronConstants.NETWORK_TYPE, dummyNetwork.getNetworkType());
    msg.setHeader(NeutronConstants.TENANT_ID, dummyNetwork.getTenantId());

    NeutronEndpoint endpoint = Mockito.mock(NeutronEndpoint.class);
    Producer producer = new NetworkProducer(endpoint, client);
    producer.process(exchange);

    ArgumentCaptor<Network> captor = ArgumentCaptor.forClass(Network.class);
    verify(networkService).create(captor.capture());

    assertEqualsNetwork(dummyNetwork, captor.getValue());
    assertNotNull(msg.getBody(Network.class).getId());
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:25,代码来源:OpenstackIntegrationTest.java


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