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


Java ExchangePattern.InOnly方法代码示例

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


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

示例1: assertMessageReceivedWithPattern

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
protected void assertMessageReceivedWithPattern(String sendUri, ExchangePattern expectedPattern) throws InterruptedException {
    ExchangePattern sendPattern;
    switch (expectedPattern) {
    case InOut:
        sendPattern = ExchangePattern.InOnly;
        break;
    case InOnly:
    case RobustInOnly:
        sendPattern = ExchangePattern.InOut;
        break;
    default:
        sendPattern = ExchangePattern.InOnly;
    }

    MockEndpoint resultEndpoint = getMockEndpoint("mock:result");
    String expectedBody = "InOnlyMessage";
    resultEndpoint.expectedBodiesReceived(expectedBody);
    resultEndpoint.expectedHeaderReceived("foo", "bar");

    template.sendBodyAndHeader(sendUri, sendPattern, expectedBody, "foo", "bar");
    resultEndpoint.assertIsSatisfied();
    ExchangePattern actualPattern = resultEndpoint.getExchanges().get(0).getPattern();
    assertEquals("received exchange pattern", actualPattern, expectedPattern);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:SetExchangePatternTest.java

示例2: prepareExchange

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
private org.apache.camel.Exchange prepareExchange(Exchange cxfExchange, Method method,
        Object[] paramArray, Object response) {
    ExchangePattern ep = ExchangePattern.InOut;
    if (method.getReturnType() == Void.class) {
        ep = ExchangePattern.InOnly;
    } 
    final org.apache.camel.Exchange camelExchange = endpoint.createExchange(ep);
    if (response != null) {
        camelExchange.getOut().setBody(response);
    }
    CxfRsBinding binding = endpoint.getBinding();
    binding.populateExchangeFromCxfRsRequest(cxfExchange, camelExchange, method, paramArray);
    
    // REVISIT: It can be done inside a binding but a propagateContext would need to be passed along as
    // the CXF in message property. Question: where should this property name be set up ? 
    if (endpoint.isPropagateContexts()) {
        camelExchange.setProperty(UriInfo.class.getName(), new UriInfoImpl(cxfExchange.getInMessage()));
        camelExchange.setProperty(Request.class.getName(), new RequestImpl(cxfExchange.getInMessage()));
        camelExchange.setProperty(HttpHeaders.class.getName(), new HttpHeadersImpl(cxfExchange.getInMessage()));
        camelExchange.setProperty(SecurityContext.class.getName(), new SecurityContextImpl(cxfExchange.getInMessage()));
    }
    
    return camelExchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:25,代码来源:CxfRsInvoker.java

示例3: dispatchSync

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public Exchange dispatchSync(RouteboxEndpoint endpoint, Exchange exchange) throws Exception {
    URI dispatchUri;
    Exchange reply;
    
    if (LOG.isDebugEnabled()) {
        LOG.debug("Dispatching exchange {} to endpoint {}", exchange, endpoint.getEndpointUri());
    }
    
    dispatchUri = selectDispatchUri(endpoint, exchange);
    
    if (exchange.getPattern() == ExchangePattern.InOnly) {
        reply = producer.send(dispatchUri.toASCIIString(), exchange);
    } else {
        reply = issueRequest(endpoint, ExchangePattern.InOut, exchange.getIn().getBody(), exchange.getIn().getHeaders());
    }

    return reply;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:RouteboxDispatcher.java

示例4: dispatchAsync

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public Exchange dispatchAsync(RouteboxEndpoint endpoint, Exchange exchange) throws Exception {
    URI dispatchUri;
    Exchange reply;

    if (LOG.isDebugEnabled()) {
        LOG.debug("Dispatching exchange {} to endpoint {}", exchange, endpoint.getEndpointUri());
    }
    
    dispatchUri = selectDispatchUri(endpoint, exchange);
    
    if (exchange.getPattern() == ExchangePattern.InOnly) {
        producer.asyncSend(dispatchUri.toASCIIString(), exchange);
        reply = exchange;
    } else {
        Future<Exchange> future = producer.asyncCallback(dispatchUri.toASCIIString(), exchange, new SynchronizationAdapter());
        reply = future.get(endpoint.getConfig().getConnectionTimeout(), TimeUnit.MILLISECONDS);
    }
    
    return reply;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:RouteboxDispatcher.java

示例5: getFailureProcessor

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public Processor getFailureProcessor() {
    if (failureProcessor == null) {
        // wrap in our special safe fallback error handler if sending to dead letter channel fails
        Processor child = new SendProcessor(deadLetter, ExchangePattern.InOnly);
        // force MEP to be InOnly so when sending to DLQ we would not expect a reply if the MEP was InOut
        failureProcessor = new FatalFallbackErrorHandler(child, true);
    }
    return failureProcessor;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:DeadLetterChannelBuilder.java

示例6: doInvokeProxy

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Override
public Object doInvokeProxy(Object proxy, Method method, Object[] args) throws Throwable {
    int argsLength = (args == null) ? 0 : args.length;
    if (argsLength != 1) {
        throw new RuntimeCamelException(String.format("Error creating proxy for %s.%s Number of arguments must be 1 but is %d", 
                                                      method.getDeclaringClass().getName(),
                                                      method.getName(), argsLength));
    }
    final ExchangePattern pattern = method.getReturnType() != Void.TYPE ? ExchangePattern.InOut : ExchangePattern.InOnly;
    return invokeWithBody(method, args[0], pattern);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:PojoMessageInvocationHandler.java

示例7: commitOutputMessage

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
private void commitOutputMessage() throws IOException {
    ExchangePattern pattern;
    if (isOneWay) {
        pattern = ExchangePattern.InOnly;
    } else {
        pattern = ExchangePattern.InOut;
    }
    LOG.debug("send the message to endpoint {}", this.targetCamelEndpointUri);
    final org.apache.camel.Exchange exchange = this.producer.createExchange(pattern);

    exchange.setProperty(Exchange.TO_ENDPOINT, this.targetCamelEndpointUri);
    CachedOutputStream outputStream = (CachedOutputStream) outMessage.getContent(OutputStream.class);
    // Send out the request message here, copy the protocolHeader back
    CxfHeaderHelper.propagateCxfToCamel(this.headerFilterStrategy, outMessage, exchange.getIn().getHeaders(), exchange);

    // TODO support different encoding
    exchange.getIn().setBody(outputStream.getInputStream());
    LOG.debug("template sending request: ", exchange.getIn());
    
    if (outMessage.getExchange().isSynchronous()) {
        syncInvoke(exchange);
    } else {
        // submit the request to the work queue
        asyncInvokeFromWorkQueue(exchange);
    }

}
 
开发者ID:HydAu,项目名称:Camel,代码行数:28,代码来源:CamelOutputStream.java

示例8: createExchange

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public Exchange createExchange(Protocol.Message message, Object request) {
    ExchangePattern pattern = ExchangePattern.InOut;
    if (message.getResponse().equals(Schema.Type.NULL)) {
        pattern = ExchangePattern.InOnly;
    }
    Exchange exchange = createExchange(pattern);
    exchange.getIn().setBody(request);
    exchange.getIn().setHeader(AvroConstants.AVRO_MESSAGE_NAME, message.getName());
    return exchange;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:AvroEndpoint.java

示例9: getResponseMessage

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Test
public void getResponseMessage() {
    Exchange inOnlyExchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOnly);
    Exchange inOutExchange = new DefaultExchange(new DefaultCamelContext(), ExchangePattern.InOut);
    
    assertSame(inOnlyExchange.getIn(), command.getResponseMessage(inOnlyExchange));
    assertSame(inOutExchange.getOut(), command.getResponseMessage(inOutExchange));
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:AbstractSmppCommandTest.java

示例10: send

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public boolean send(Message<?> message) throws Exception {
    boolean result = false;

    ExchangePattern pattern;
    if (isExpectReply()) {
        pattern = ExchangePattern.InOut;
    } else {
        pattern = ExchangePattern.InOnly;
    }

    Exchange inExchange = new DefaultExchange(getCamelContext(), pattern);
    SpringIntegrationBinding.storeToCamelMessage(message, inExchange.getIn());
    Exchange outExchange = getCamelTemplate().send(getCamelEndpointUri(), inExchange);
    org.apache.camel.Message camelMsg = outExchange.hasOut() ? outExchange.getOut() : outExchange.getIn();
    if (camelMsg.isFault()) {
        result = true;
    }

    Message<?> response;
    if (isExpectReply()) {
        //Check the message header for the return address
        response = SpringIntegrationBinding.storeToSpringIntegrationMessage(outExchange.getOut());
        if (replyChannel == null) {
            MessageChannel messageReplyChannel = (MessageChannel) message.getHeaders().get(MessageHeaders.REPLY_CHANNEL);
            if (messageReplyChannel != null) {
                result = messageReplyChannel.send(response);
            } else {
                throw new MessageDeliveryException(response, "Cannot resolve ReplyChannel from message: " + message);
            }
        } else {
            result = replyChannel.send(response);
        }
    }

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

示例11: getPattern

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public ExchangePattern getPattern() {
    return ExchangePattern.InOnly;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:WireTapDefinition.java

示例12: getPattern

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Override
public ExchangePattern getPattern() {
    return ExchangePattern.InOnly;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:5,代码来源:InOnlyDefinition.java

示例13: configureNewExchange

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
private Exchange configureNewExchange(Exchange exchange) {
    return new DefaultExchange(exchange.getFromEndpoint(), ExchangePattern.InOnly);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:WireTapProcessor.java

示例14: DefaultExchange

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public DefaultExchange(CamelContext context) {
    this(context, ExchangePattern.InOnly);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:DefaultExchange.java

示例15: inOnlyMethod

import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Pattern(ExchangePattern.InOnly)
void inOnlyMethod();
 
开发者ID:HydAu,项目名称:Camel,代码行数:3,代码来源:BeanInfoTest.java


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