本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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;
}
示例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));
}
示例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;
}
示例11: getPattern
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public ExchangePattern getPattern() {
return ExchangePattern.InOnly;
}
示例12: getPattern
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Override
public ExchangePattern getPattern() {
return ExchangePattern.InOnly;
}
示例13: configureNewExchange
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
private Exchange configureNewExchange(Exchange exchange) {
return new DefaultExchange(exchange.getFromEndpoint(), ExchangePattern.InOnly);
}
示例14: DefaultExchange
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
public DefaultExchange(CamelContext context) {
this(context, ExchangePattern.InOnly);
}
示例15: inOnlyMethod
import org.apache.camel.ExchangePattern; //导入方法依赖的package包/类
@Pattern(ExchangePattern.InOnly)
void inOnlyMethod();