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


Java RuntimeExchangeException类代码示例

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


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

示例1: getHeader

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
public Object getHeader(String name) {
    Object answer = null;

    // we will exclude using JMS-prefixed headers here to avoid strangeness with some JMS providers
    // e.g. ActiveMQ returns the String not the Destination type for "JMSReplyTo"!
    // only look in jms message directly if we have not populated headers
    if (jmsMessage != null && !hasPopulatedHeaders() && !name.startsWith("JMS")) {
        try {
            // use binding to do the lookup as it has to consider using encoded keys
            answer = getBinding().getObjectProperty(jmsMessage, name);
        } catch (JMSException e) {
            throw new RuntimeExchangeException("Unable to retrieve header from JMS Message: " + name, getExchange(), e);
        }
    }
    // only look if we have populated headers otherwise there are no headers at all
    // if we do lookup a header starting with JMS then force a lookup
    if (answer == null && (hasPopulatedHeaders() || name.startsWith("JMS"))) {
        answer = super.getHeader(name);
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:SjmsMessage.java

示例2: notify

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
void notify(T event) {
    logger.debug("Consuming CDI event [{}] with {}", event, this);

    Exchange exchange = getEndpoint().createExchange();
    // TODO: would that be possible to propagate the event metadata?
    exchange.getIn().setBody(event);

    // Avoid infinite loop of exchange events
    if (event instanceof AbstractExchangeEvent) {
        exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.TRUE);
    }
    try {
        getProcessor().process(exchange);
    } catch (Exception cause) {
        throw new RuntimeExchangeException("Error while processing CDI event", exchange, cause);
    } finally {
        if (event instanceof AbstractExchangeEvent) {
            exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.FALSE);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:22,代码来源:CdiEventConsumer.java

示例3: notify

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
void notify(T event) {
    logger.debug("Consuming CDI event [{}] with {}", event, this);

    Exchange exchange = getEndpoint().createExchange();
    // TODO: propagate the event metadata
    exchange.getIn().setBody(event);

    // Avoid infinite loop of exchange events
    if (event instanceof AbstractExchangeEvent)
        exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.TRUE);

    try {
        getProcessor().process(exchange);
    } catch (Exception cause) {
        throw new RuntimeExchangeException("Error while processing CDI event", exchange, cause);
    } finally {
        if (event instanceof AbstractExchangeEvent)
            exchange.setProperty(Exchange.NOTIFY_EVENT, Boolean.FALSE);
    }
}
 
开发者ID:astefanutti,项目名称:camel-cdi,代码行数:21,代码来源:CdiEventConsumer.java

示例4: onExchangeDone

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
@Override
public void onExchangeDone(Route route, Exchange exchange) {
    super.onExchangeDone(route, exchange);

    LOG.info("Exchange Done for route " + route.getId() +
            " exchange: " + exchange.getExchangeId() + " in: " + exchange.getIn().getBody(String.class));
    try {
        stopRoute(route);
    } catch (Exception e) {
        throw new RuntimeExchangeException(e.getMessage(), exchange, e);
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:13,代码来源:SingleMessageRoutePolicy.java

示例5: receive

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
public Exchange receive() {
    // must be started
    if (!isRunAllowed() || !isStarted()) {
        throw new RejectedExecutionException(this + " is not started, but in state: " + getStatus().name());
    }

    Exchange exchange = getEndpoint().createExchange();
    try {
        processor.process(exchange);
    } catch (Exception e) {
        throw new RuntimeExchangeException("Error while processing exchange", exchange, e);
    }
    return exchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:15,代码来源:ProcessorPollingConsumer.java

示例6: marshal

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
/**
 * Creates a payload object with the information from the given exchange.
 *
 * @param exchange the exchange, must <b>not</b> be <tt>null</tt>
 * @param includeProperties whether or not to include exchange properties
 * @return the holder object with information copied form the exchange
 */
public static DefaultExchangeHolder marshal(Exchange exchange, boolean includeProperties) {
    ObjectHelper.notNull(exchange, "exchange");

    // we do not support files
    Object body = exchange.getIn().getBody();
    if (body instanceof WrappedFile || body instanceof File) {
        throw new RuntimeExchangeException("Message body of type " + body.getClass().getCanonicalName() + " is not supported by this marshaller.", exchange);
    }

    DefaultExchangeHolder payload = new DefaultExchangeHolder();

    payload.exchangeId = exchange.getExchangeId();
    payload.inBody = checkSerializableBody("in body", exchange, exchange.getIn().getBody());
    payload.safeSetInHeaders(exchange, false);
    if (exchange.hasOut()) {
        payload.outBody = checkSerializableBody("out body", exchange, exchange.getOut().getBody());
        payload.outFaultFlag = exchange.getOut().isFault();
        payload.safeSetOutHeaders(exchange, false);
    } else {
        payload.inFaultFlag = exchange.getIn().isFault();
    }
    if (includeProperties) {
        payload.safeSetProperties(exchange, false);
    }
    payload.exception = exchange.getException();

    return payload;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:DefaultExchangeHolder.java

示例7: testFileNotSupported

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
public void testFileNotSupported() throws Exception {
    Exchange exchange = new DefaultExchange(context);
    exchange.getIn().setBody(new File("src/test/resources/log4j.properties"));

    try {
        DefaultExchangeHolder.marshal(exchange);
        fail("Should have thrown exception");
    } catch (RuntimeExchangeException e) {
        // expected
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:DefaultExchangeHolderTest.java

示例8: testBeanParameterInvalidValueA

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
public void testBeanParameterInvalidValueA() throws Exception {
    getMockEndpoint("mock:result").expectedMessageCount(0);

    try {
        template.sendBody("direct:a", "World");
        fail("Should have thrown exception");
    } catch (CamelExecutionException e) {
        RuntimeExchangeException cause = assertIsInstanceOf(RuntimeExchangeException.class, e.getCause());
        assertTrue(cause.getMessage().contains("echo(java.lang.String,int)"));
        assertTrue(cause.getMessage().contains("[World, null]"));
        assertIsInstanceOf(IllegalArgumentException.class, cause.getCause());
    }

    assertMockEndpointsSatisfied();
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:16,代码来源:BeanParameterNoBeanBindingTest.java

示例9: createMethod

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
/**
 * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
 *
 * @param exchange  the exchange
 * @return the created method
 * @throws URISyntaxException
 */
public static HttpMethods createMethod(Exchange exchange, HttpCommonEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
    // is a query string provided in the endpoint URI or in a header (header overrules endpoint)
    String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
    // We need also check the HTTP_URI header query part
    String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
    // resolve placeholders in uriString
    try {
        uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
    } catch (Exception e) {
        throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
    }
    if (uriString != null) {
        // in case the URI string contains unsafe characters
        uriString = UnsafeUriCharactersEncoder.encodeHttpURI(uriString);
        URI uri = new URI(uriString);
        queryString = uri.getQuery();
    }
    if (queryString == null) {
        queryString = endpoint.getHttpUri().getRawQuery();
    }

    // compute what method to use either GET or POST
    HttpMethods answer;
    HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
    if (m != null) {
        // always use what end-user provides in a header
        answer = m;
    } else if (queryString != null) {
        // if a query string is provided then use GET
        answer = HttpMethods.GET;
    } else {
        // fallback to POST if we have payload, otherwise GET
        answer = hasPayload ? HttpMethods.POST : HttpMethods.GET;
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:45,代码来源:HttpHelper.java

示例10: createMethod

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
/**
 * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
 *
 * @param exchange the exchange
 * @return the created method
 * @throws URISyntaxException 
 */
public static HttpMethods createMethod(Exchange exchange, HttpEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
    // is a query string provided in the endpoint URI or in a header (header
    // overrules endpoint)
    String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
    // We need also check the HTTP_URI header query part
    String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
    // resolve placeholders in uriString
    try {
        uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
    } catch (Exception e) {
        throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
    }
    if (uriString != null) {
        // in case the URI string contains unsafe characters
        uriString = UnsafeUriCharactersEncoder.encodeHttpURI(uriString);
        URI uri = new URI(uriString);
        queryString = uri.getQuery();
    }
    if (queryString == null) {
        queryString = endpoint.getHttpUri().getRawQuery();
    }

    // compute what method to use either GET or POST
    HttpMethods answer;
    HttpMethods m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, HttpMethods.class);
    if (m != null) {
        // always use what end-user provides in a header
        answer = m;
    } else if (queryString != null) {
        // if a query string is provided then use GET
        answer = HttpMethods.GET;
    } else {
        // fallback to POST if we have payload, otherwise GET
        answer = hasPayload ? HttpMethods.POST : HttpMethods.GET;
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:46,代码来源:HttpMethodHelper.java

示例11: createMessageId

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
@Override
protected String createMessageId() {
    if (jmsMessage == null) {
        LOG.trace("No javax.jms.Message set so generating a new message id");
        return super.createMessageId();
    }
    try {
        String id = getDestinationAsString(jmsMessage.getJMSDestination()) + jmsMessage.getJMSMessageID();
        return getSanitizedString(id);
    } catch (JMSException e) {
        throw new RuntimeExchangeException("Unable to retrieve JMSMessageID from JMS Message", getExchange(), e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:JmsMessage.java

示例12: createURL

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
/**
 * Creates the URL to invoke.
 *
 * @param exchange the exchange
 * @param endpoint the endpoint
 * @return the URL to invoke
 */
public static String createURL(Exchange exchange, UndertowEndpoint endpoint) {
    String uri = uri = endpoint.getHttpURI().toASCIIString();

    // resolve placeholders in uri
    try {
        uri = exchange.getContext().resolvePropertyPlaceholders(uri);
    } catch (Exception e) {
        throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uri, exchange, e);
    }

    // append HTTP_PATH to HTTP_URI if it is provided in the header
    String path = exchange.getIn().getHeader(Exchange.HTTP_PATH, String.class);
    // NOW the HTTP_PATH is just related path, we don't need to trim it
    if (path != null) {
        if (path.startsWith("/")) {
            path = path.substring(1);
        }
        if (path.length() > 0) {
            // make sure that there is exactly one "/" between HTTP_URI and
            // HTTP_PATH
            if (!uri.endsWith("/")) {
                uri = uri + "/";
            }
            uri = uri.concat(path);
        }
    }

    // ensure uri is encoded to be valid
    uri = UnsafeUriCharactersEncoder.encodeHttpURI(uri);

    return uri;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:40,代码来源:UndertowHelper.java

示例13: createMethod

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
/**
 * Creates the HttpMethod to use to call the remote server, often either its GET or POST.
 *
 * @param exchange the exchange
 * @return the created method
 * @throws URISyntaxException
 */
public static HttpString createMethod(Exchange exchange, UndertowEndpoint endpoint, boolean hasPayload) throws URISyntaxException {
    // is a query string provided in the endpoint URI or in a header (header
    // overrules endpoint)
    String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
    // We need also check the HTTP_URI header query part
    String uriString = exchange.getIn().getHeader(Exchange.HTTP_URI, String.class);
    // resolve placeholders in uriString
    try {
        uriString = exchange.getContext().resolvePropertyPlaceholders(uriString);
    } catch (Exception e) {
        throw new RuntimeExchangeException("Cannot resolve property placeholders with uri: " + uriString, exchange, e);
    }
    if (uriString != null) {
        URI uri = new URI(uriString);
        queryString = uri.getQuery();
    }
    if (queryString == null) {
        queryString = endpoint.getHttpURI().getRawQuery();
    }

    // compute what method to use either GET or POST
    HttpString answer;
    String m = exchange.getIn().getHeader(Exchange.HTTP_METHOD, String.class);
    if (m != null) {
        // always use what end-user provides in a header
        answer = new HttpString(m);
    } else if (queryString != null) {
        // if a query string is provided then use GET
        answer = Methods.GET;
    } else {
        // fallback to POST if we have payload, otherwise GET
        answer = hasPayload ? Methods.POST : Methods.GET;
    }

    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:44,代码来源:UndertowHelper.java

示例14: getFolderOnPath

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
private Folder getFolderOnPath(Exchange exchange, String path) throws Exception {
    try {
        return (Folder) getSessionFacade().getObjectByPath(path);
    } catch (CmisObjectNotFoundException e) {
        throw new RuntimeExchangeException("Path not found " + path, exchange, e);
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:8,代码来源:CMISProducer.java

示例15: failCreatingFolderAtNonExistingPath

import org.apache.camel.RuntimeExchangeException; //导入依赖的package包/类
@Test
public void failCreatingFolderAtNonExistingPath() throws Exception {
    String existingFolderStructure = "/No/Path/Here";

    Exchange exchange = createExchangeWithInBody(null);
    exchange.getIn().getHeaders().put(PropertyIds.NAME, "folder1");
    exchange.getIn().getHeaders().put(PropertyIds.OBJECT_TYPE_ID, "cmis:folder");
    exchange.getIn().getHeaders().put(CamelCMISConstants.CMIS_FOLDER_PATH, existingFolderStructure);

    template.send(exchange);
    assertTrue(exchange.getException() instanceof RuntimeExchangeException);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:CMISProducerTest.java


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