001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.camel; 018 019import java.util.Map; 020import java.util.concurrent.CompletableFuture; 021import java.util.concurrent.ExecutorService; 022import java.util.concurrent.Future; 023import java.util.concurrent.TimeUnit; 024import java.util.concurrent.TimeoutException; 025 026import org.apache.camel.spi.Synchronization; 027 028/** 029 * Template for working with Camel and sending {@link Message} instances in an 030 * {@link Exchange} to an {@link Endpoint}. 031 * <br/> 032 * <p/><b>Important:</b> Read the javadoc of each method carefully to ensure the behavior of the method is understood. 033 * Some methods is for <tt>InOnly</tt>, others for <tt>InOut</tt> MEP. And some methods throws 034 * {@link org.apache.camel.CamelExecutionException} while others stores any thrown exception on the returned 035 * {@link Exchange}. 036 * <br/> 037 * <p/>The {@link ProducerTemplate} is <b>thread safe</b>. 038 * <br/> 039 * <p/>All the methods which sends a message may throw {@link FailedToCreateProducerException} in 040 * case the {@link Producer} could not be created. Or a {@link NoSuchEndpointException} if the endpoint could 041 * not be resolved. There may be other related exceptions being thrown which occurs <i>before</i> the {@link Producer} 042 * has started sending the message. 043 * <br/> 044 * <p/>All the sendBody or requestBody methods will return the content according to this strategy: 045 * <ul> 046 * <li>throws {@link org.apache.camel.CamelExecutionException} if processing failed <i>during</i> routing 047 * with the caused exception wrapped</li> 048 * <li>The <tt>fault.body</tt> if there is a fault message set and its not <tt>null</tt></li> 049 * <li>Either <tt>IN</tt> or <tt>OUT</tt> body according to the message exchange pattern. If the pattern is 050 * Out capable then the <tt>OUT</tt> body is returned, otherwise <tt>IN</tt>. 051 * </ul> 052 * <br/> 053 * <p/>Before using the template it must be started. 054 * And when you are done using the template, make sure to {@link #stop()} the template. 055 * <br/> 056 * <p/><b>Important note on usage:</b> See this 057 * <a href="http://camel.apache.org/why-does-camel-use-too-many-threads-with-producertemplate.html">FAQ entry</a> 058 * before using. 059 * 060 * @see FluentProducerTemplate 061 * @see ConsumerTemplate 062 */ 063public interface ProducerTemplate extends Service { 064 065 /** 066 * Get the {@link CamelContext} 067 * 068 * @return camelContext the Camel context 069 */ 070 CamelContext getCamelContext(); 071 072 // Configuration methods 073 // ----------------------------------------------------------------------- 074 075 /** 076 * Gets the maximum cache size used in the backing cache pools. 077 * 078 * @return the maximum cache size 079 */ 080 int getMaximumCacheSize(); 081 082 /** 083 * Sets a custom maximum cache size to use in the backing cache pools. 084 * 085 * @param maximumCacheSize the custom maximum cache size 086 */ 087 void setMaximumCacheSize(int maximumCacheSize); 088 089 /** 090 * Gets an approximated size of the current cached resources in the backing cache pools. 091 * 092 * @return the size of current cached resources 093 */ 094 int getCurrentCacheSize(); 095 096 /** 097 * Reports if async* methods will dispath processing from the calling thread (false) or through executor (true). 098 * In both cases asynchronous engine will be used, so this non-threaded can be useful for high-speed 099 * non-blocking processing. 100 * @return if async* methods will dipatch processing with the executor 101 */ 102 boolean isThreadedAsyncMode(); 103 104 /** 105 * Reports if async* methods will dispath processing from the calling thread (false) or through executor (true). 106 * In both cases asynchronous engine will be used, so this non-threaded can be useful for high-speed 107 * non-blocking processing. 108 * @param useExecutor if async* methods will dipatch processing with the executor 109 */ 110 void setThreadedAsyncMode(boolean useExecutor); 111 112 /** 113 * Get the default endpoint to use if none is specified 114 * 115 * @return the default endpoint instance 116 */ 117 Endpoint getDefaultEndpoint(); 118 119 /** 120 * Sets the default endpoint to use if none is specified 121 * 122 * @param defaultEndpoint the default endpoint instance 123 */ 124 void setDefaultEndpoint(Endpoint defaultEndpoint); 125 126 /** 127 * Sets the default endpoint uri to use if none is specified 128 * 129 * @param endpointUri the default endpoint uri 130 */ 131 void setDefaultEndpointUri(String endpointUri); 132 133 /** 134 * Sets whether the {@link org.apache.camel.spi.EventNotifier} should be 135 * used by this {@link ProducerTemplate} to send events about the {@link Exchange} 136 * being sent. 137 * <p/> 138 * By default this is enabled. 139 * 140 * @param enabled <tt>true</tt> to enable, <tt>false</tt> to disable. 141 */ 142 void setEventNotifierEnabled(boolean enabled); 143 144 /** 145 * Whether the {@link org.apache.camel.spi.EventNotifier} should be 146 * used by this {@link ProducerTemplate} to send events about the {@link Exchange} 147 * being sent. 148 * 149 * @return <tt>true</tt> if enabled, <tt>false</tt> otherwise 150 */ 151 boolean isEventNotifierEnabled(); 152 153 /** 154 * Cleanup the cache (purging stale entries) 155 */ 156 void cleanUp(); 157 158 // Synchronous methods 159 // ----------------------------------------------------------------------- 160 161 /** 162 * Sends the exchange to the default endpoint 163 * <br/><br/> 164 * <b>Notice:</b> that if the processing of the exchange failed with an Exception 165 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 166 * {@link org.apache.camel.Exchange#getException()}. 167 * 168 * @param exchange the exchange to send 169 * @return the returned exchange 170 */ 171 Exchange send(Exchange exchange); 172 173 /** 174 * Sends an exchange to the default endpoint using a supplied processor 175 * <br/><br/> 176 * <b>Notice:</b> that if the processing of the exchange failed with an Exception 177 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 178 * {@link org.apache.camel.Exchange#getException()}. 179 * 180 * @param processor the transformer used to populate the new exchange 181 * {@link Processor} to populate the exchange 182 * @return the returned exchange 183 */ 184 Exchange send(Processor processor); 185 186 /** 187 * Sends the body to the default endpoint 188 * <br/><br/> 189 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 190 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 191 * the caused exception wrapped. 192 * 193 * @param body the payload to send 194 * @throws CamelExecutionException if the processing of the exchange failed 195 */ 196 void sendBody(Object body) throws CamelExecutionException; 197 198 /** 199 * Sends the body to the default endpoint with a specified header and header value 200 * <br/><br/> 201 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 202 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 203 * the caused exception wrapped. 204 * 205 * @param body the payload to send 206 * @param header the header name 207 * @param headerValue the header value 208 * @throws CamelExecutionException if the processing of the exchange failed 209 */ 210 void sendBodyAndHeader(Object body, String header, Object headerValue) throws CamelExecutionException; 211 212 /** 213 * Sends the body to the default endpoint with a specified property and property value 214 * <br/><br/> 215 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 216 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 217 * the caused exception wrapped. 218 * 219 * @param body the payload to send 220 * @param property the property name 221 * @param propertyValue the property value 222 * @throws CamelExecutionException if the processing of the exchange failed 223 */ 224 void sendBodyAndProperty(Object body, String property, Object propertyValue) throws CamelExecutionException; 225 226 /** 227 * Sends the body to the default endpoint with the specified headers and header values 228 * <br/><br/> 229 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 230 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 231 * the caused exception wrapped. 232 * 233 * @param body the payload to send 234 * @param headers the headers 235 * @throws CamelExecutionException if the processing of the exchange failed 236 */ 237 void sendBodyAndHeaders(Object body, Map<String, Object> headers) throws CamelExecutionException; 238 239 // Allow sending to arbitrary endpoints 240 // ----------------------------------------------------------------------- 241 242 /** 243 * Sends the exchange to the given endpoint 244 * <br/><br/> 245 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 246 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 247 * {@link org.apache.camel.Exchange#getException()}. 248 * 249 * @param endpointUri the endpoint URI to send the exchange to 250 * @param exchange the exchange to send 251 * @return the returned exchange 252 * @throws CamelExecutionException if the processing of the exchange failed 253 */ 254 Exchange send(String endpointUri, Exchange exchange); 255 256 /** 257 * Sends an exchange to an endpoint using a supplied processor 258 * <br/><br/> 259 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 260 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 261 * {@link org.apache.camel.Exchange#getException()}. 262 * 263 * @param endpointUri the endpoint URI to send the exchange to 264 * @param processor the transformer used to populate the new exchange 265 * {@link Processor} to populate the exchange 266 * @return the returned exchange 267 * @throws CamelExecutionException if the processing of the exchange failed 268 */ 269 Exchange send(String endpointUri, Processor processor); 270 271 /** 272 * Sends an exchange to an endpoint using a supplied processor 273 * <br/><br/> 274 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 275 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 276 * {@link org.apache.camel.Exchange#getException()}. 277 * 278 * @param endpointUri the endpoint URI to send the exchange to 279 * @param pattern the message {@link ExchangePattern} such as 280 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 281 * @param processor the transformer used to populate the new exchange 282 * {@link Processor} to populate the exchange 283 * @return the returned exchange 284 */ 285 Exchange send(String endpointUri, ExchangePattern pattern, Processor processor); 286 287 /** 288 * Sends the exchange to the given endpoint 289 * <br/><br/> 290 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 291 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 292 * {@link org.apache.camel.Exchange#getException()}. 293 * 294 * @param endpoint the endpoint to send the exchange to 295 * @param exchange the exchange to send 296 * @return the returned exchange 297 */ 298 Exchange send(Endpoint endpoint, Exchange exchange); 299 300 /** 301 * Sends an exchange to an endpoint using a supplied processor 302 * <br/><br/> 303 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 304 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 305 * {@link org.apache.camel.Exchange#getException()}. 306 * 307 * @param endpoint the endpoint to send the exchange to 308 * @param processor the transformer used to populate the new exchange 309 * {@link Processor} to populate the exchange 310 * @return the returned exchange 311 */ 312 Exchange send(Endpoint endpoint, Processor processor); 313 314 /** 315 * Sends an exchange to an endpoint using a supplied processor 316 * <br/><br/> 317 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 318 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 319 * {@link org.apache.camel.Exchange#getException()}. 320 * 321 * @param endpoint the endpoint to send the exchange to 322 * @param pattern the message {@link ExchangePattern} such as 323 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 324 * @param processor the transformer used to populate the new exchange 325 * {@link Processor} to populate the exchange 326 * @return the returned exchange 327 */ 328 Exchange send(Endpoint endpoint, ExchangePattern pattern, Processor processor); 329 330 331 /** 332 * Sends an exchange to an endpoint using a supplied processor 333 * <br/><br/> 334 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 335 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 336 * {@link org.apache.camel.Exchange#getException()}. 337 * 338 * @param endpoint the endpoint to send the exchange to 339 * @param pattern the message {@link ExchangePattern} such as 340 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 341 * @param processor the transformer used to populate the new exchange 342 * @param resultProcessor a processor to process the exchange when the send is complete. 343 * {@link Processor} to populate the exchange 344 * @return the returned exchange 345 */ 346 Exchange send(Endpoint endpoint, ExchangePattern pattern, Processor processor, Processor resultProcessor); 347 348 /** 349 * Send the body to an endpoint 350 * <br/><br/> 351 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 352 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 353 * the caused exception wrapped. 354 * 355 * @param endpoint the endpoint to send the exchange to 356 * @param body the payload 357 * @throws CamelExecutionException if the processing of the exchange failed 358 */ 359 void sendBody(Endpoint endpoint, Object body) throws CamelExecutionException; 360 361 /** 362 * Send the body to an endpoint 363 * <br/><br/> 364 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 365 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 366 * the caused exception wrapped. 367 * 368 * @param endpointUri the endpoint URI to send the exchange to 369 * @param body the payload 370 * @throws CamelExecutionException if the processing of the exchange failed 371 */ 372 void sendBody(String endpointUri, Object body) throws CamelExecutionException; 373 374 /** 375 * Send the body to an endpoint with the given {@link ExchangePattern} 376 * returning any result output body 377 * <br/><br/> 378 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 379 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 380 * the caused exception wrapped. 381 * 382 * @param endpoint the endpoint to send the exchange to 383 * @param body the payload 384 * @param pattern the message {@link ExchangePattern} such as 385 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 386 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 387 * @throws CamelExecutionException if the processing of the exchange failed 388 */ 389 Object sendBody(Endpoint endpoint, ExchangePattern pattern, Object body) throws CamelExecutionException; 390 391 /** 392 * Send the body to an endpoint returning any result output body 393 * <br/><br/> 394 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 395 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 396 * the caused exception wrapped. 397 * 398 * @param endpointUri the endpoint URI to send the exchange to 399 * @param pattern the message {@link ExchangePattern} such as 400 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 401 * @param body the payload 402 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 403 * @throws CamelExecutionException if the processing of the exchange failed 404 */ 405 Object sendBody(String endpointUri, ExchangePattern pattern, Object body) throws CamelExecutionException; 406 407 /** 408 * Sends the body to an endpoint with a specified header and header value 409 * <br/><br/> 410 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 411 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 412 * the caused exception wrapped. 413 * 414 * @param endpointUri the endpoint URI to send to 415 * @param body the payload to send 416 * @param header the header name 417 * @param headerValue the header value 418 * @throws CamelExecutionException if the processing of the exchange failed 419 */ 420 void sendBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) throws CamelExecutionException; 421 422 /** 423 * Sends the body to an endpoint with a specified header and header value 424 * <br/><br/> 425 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 426 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 427 * the caused exception wrapped. 428 * 429 * @param endpoint the Endpoint to send to 430 * @param body the payload to send 431 * @param header the header name 432 * @param headerValue the header value 433 * @throws CamelExecutionException if the processing of the exchange failed 434 */ 435 void sendBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue) throws CamelExecutionException; 436 437 /** 438 * Sends the body to an endpoint with a specified header and header value 439 * <br/><br/> 440 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 441 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 442 * the caused exception wrapped. 443 * 444 * @param endpoint the Endpoint to send to 445 * @param pattern the message {@link ExchangePattern} such as 446 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 447 * @param body the payload to send 448 * @param header the header name 449 * @param headerValue the header value 450 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 451 * @throws CamelExecutionException if the processing of the exchange failed 452 */ 453 Object sendBodyAndHeader(Endpoint endpoint, ExchangePattern pattern, Object body, 454 String header, Object headerValue) throws CamelExecutionException; 455 456 /** 457 * Sends the body to an endpoint with a specified header and header value 458 * <br/><br/> 459 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 460 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 461 * the caused exception wrapped. 462 * 463 * @param endpoint the Endpoint URI to send to 464 * @param pattern the message {@link ExchangePattern} such as 465 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 466 * @param body the payload to send 467 * @param header the header name 468 * @param headerValue the header value 469 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 470 * @throws CamelExecutionException if the processing of the exchange failed 471 */ 472 Object sendBodyAndHeader(String endpoint, ExchangePattern pattern, Object body, 473 String header, Object headerValue) throws CamelExecutionException; 474 475 /** 476 * Sends the body to an endpoint with a specified property and property value 477 * <br/><br/> 478 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 479 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 480 * the caused exception wrapped. 481 * 482 * @param endpointUri the endpoint URI to send to 483 * @param body the payload to send 484 * @param property the property name 485 * @param propertyValue the property value 486 * @throws CamelExecutionException if the processing of the exchange failed 487 */ 488 void sendBodyAndProperty(String endpointUri, Object body, String property, Object propertyValue) throws CamelExecutionException; 489 490 /** 491 * Sends the body to an endpoint with a specified property and property value 492 * <br/><br/> 493 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 494 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 495 * the caused exception wrapped. 496 * 497 * @param endpoint the Endpoint to send to 498 * @param body the payload to send 499 * @param property the property name 500 * @param propertyValue the property value 501 * @throws CamelExecutionException if the processing of the exchange failed 502 */ 503 void sendBodyAndProperty(Endpoint endpoint, Object body, String property, Object propertyValue) throws CamelExecutionException; 504 505 /** 506 * Sends the body to an endpoint with a specified property and property value 507 * <br/><br/> 508 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 509 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 510 * the caused exception wrapped. 511 * 512 * @param endpoint the Endpoint to send to 513 * @param pattern the message {@link ExchangePattern} such as 514 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 515 * @param body the payload to send 516 * @param property the property name 517 * @param propertyValue the property value 518 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 519 * @throws CamelExecutionException if the processing of the exchange failed 520 */ 521 Object sendBodyAndProperty(Endpoint endpoint, ExchangePattern pattern, Object body, 522 String property, Object propertyValue) throws CamelExecutionException; 523 524 /** 525 * Sends the body to an endpoint with a specified property and property value 526 * <br/><br/> 527 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 528 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 529 * the caused exception wrapped. 530 * 531 * @param endpoint the Endpoint URI to send to 532 * @param pattern the message {@link ExchangePattern} such as 533 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 534 * @param body the payload to send 535 * @param property the property name 536 * @param propertyValue the property value 537 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 538 * @throws CamelExecutionException if the processing of the exchange failed 539 */ 540 Object sendBodyAndProperty(String endpoint, ExchangePattern pattern, Object body, 541 String property, Object propertyValue) throws CamelExecutionException; 542 543 /** 544 * Sends the body to an endpoint with the specified headers and header values 545 * <br/><br/> 546 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 547 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 548 * the caused exception wrapped. 549 * 550 * @param endpointUri the endpoint URI to send to 551 * @param body the payload to send 552 * @param headers headers 553 * @throws CamelExecutionException if the processing of the exchange failed 554 */ 555 void sendBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws CamelExecutionException; 556 557 /** 558 * Sends the body to an endpoint with the specified headers and header values 559 * <br/><br/> 560 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 561 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 562 * the caused exception wrapped. 563 * 564 * @param endpoint the endpoint URI to send to 565 * @param body the payload to send 566 * @param headers headers 567 * @throws CamelExecutionException if the processing of the exchange failed 568 */ 569 void sendBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers) throws CamelExecutionException; 570 571 /** 572 * Sends the body to an endpoint with the specified headers and header values 573 * <br/><br/> 574 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 575 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 576 * the caused exception wrapped. 577 * 578 * @param endpointUri the endpoint URI to send to 579 * @param pattern the message {@link ExchangePattern} such as 580 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 581 * @param body the payload to send 582 * @param headers headers 583 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 584 * @throws CamelExecutionException if the processing of the exchange failed 585 */ 586 Object sendBodyAndHeaders(String endpointUri, ExchangePattern pattern, Object body, 587 Map<String, Object> headers) throws CamelExecutionException; 588 589 /** 590 * Sends the body to an endpoint with the specified headers and header values 591 * <br/><br/> 592 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 593 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 594 * the caused exception wrapped. 595 * 596 * @param endpoint the endpoint URI to send to 597 * @param pattern the message {@link ExchangePattern} such as 598 * {@link ExchangePattern#InOnly} or {@link ExchangePattern#InOut} 599 * @param body the payload to send 600 * @param headers headers 601 * @return the result if {@link ExchangePattern} is OUT capable, otherwise <tt>null</tt> 602 * @throws CamelExecutionException if the processing of the exchange failed 603 */ 604 Object sendBodyAndHeaders(Endpoint endpoint, ExchangePattern pattern, Object body, 605 Map<String, Object> headers) throws CamelExecutionException; 606 607 608 // Methods using an InOut ExchangePattern 609 // ----------------------------------------------------------------------- 610 611 /** 612 * Sends an exchange to an endpoint using a supplied processor 613 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 614 * <br/><br/> 615 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 616 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 617 * {@link org.apache.camel.Exchange#getException()}. 618 * 619 * @param endpoint the Endpoint to send to 620 * @param processor the processor which will populate the exchange before sending 621 * @return the result (see class javadoc) 622 */ 623 Exchange request(Endpoint endpoint, Processor processor); 624 625 /** 626 * Sends an exchange to an endpoint using a supplied processor 627 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 628 * <br/><br/> 629 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 630 * it is <b>not</b> thrown from this method, but you can access it from the returned exchange using 631 * {@link org.apache.camel.Exchange#getException()}. 632 * 633 * @param endpointUri the endpoint URI to send to 634 * @param processor the processor which will populate the exchange before sending 635 * @return the result (see class javadoc) 636 */ 637 Exchange request(String endpointUri, Processor processor); 638 639 /** 640 * Sends the body to the default endpoint and returns the result content 641 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 642 * <br/><br/> 643 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 644 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 645 * the caused exception wrapped. 646 * 647 * @param body the payload to send 648 * @return the result (see class javadoc) 649 * @throws CamelExecutionException if the processing of the exchange failed 650 */ 651 Object requestBody(Object body) throws CamelExecutionException; 652 653 /** 654 * Sends the body to the default endpoint and returns the result content 655 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 656 * <br/><br/> 657 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 658 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 659 * the caused exception wrapped. 660 * 661 * @param body the payload to send 662 * @param type the expected response type 663 * @return the result (see class javadoc) 664 * @throws CamelExecutionException if the processing of the exchange failed 665 */ 666 <T> T requestBody(Object body, Class<T> type) throws CamelExecutionException; 667 668 /** 669 * Send the body to an endpoint returning any result output body. 670 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 671 * <br/><br/> 672 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 673 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 674 * the caused exception wrapped. 675 * 676 * @param endpoint the Endpoint to send to 677 * @param body the payload 678 * @return the result (see class javadoc) 679 * @throws CamelExecutionException if the processing of the exchange failed 680 */ 681 Object requestBody(Endpoint endpoint, Object body) throws CamelExecutionException; 682 683 /** 684 * Send the body to an endpoint returning any result output body. 685 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 686 * <br/><br/> 687 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 688 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 689 * the caused exception wrapped. 690 * 691 * @param endpoint the Endpoint to send to 692 * @param body the payload 693 * @param type the expected response type 694 * @return the result (see class javadoc) 695 * @throws CamelExecutionException if the processing of the exchange failed 696 */ 697 <T> T requestBody(Endpoint endpoint, Object body, Class<T> type) throws CamelExecutionException; 698 699 /** 700 * Send the body to an endpoint returning any result output body. 701 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 702 * <br/><br/> 703 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 704 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 705 * the caused exception wrapped. 706 * 707 * @param endpointUri the endpoint URI to send to 708 * @param body the payload 709 * @return the result (see class javadoc) 710 * @throws CamelExecutionException if the processing of the exchange failed 711 */ 712 Object requestBody(String endpointUri, Object body) throws CamelExecutionException; 713 714 /** 715 * Send the body to an endpoint returning any result output body. 716 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 717 * <br/><br/> 718 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 719 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 720 * the caused exception wrapped. 721 * 722 * @param endpointUri the endpoint URI to send to 723 * @param body the payload 724 * @param type the expected response type 725 * @return the result (see class javadoc) 726 * @throws CamelExecutionException if the processing of the exchange failed 727 */ 728 <T> T requestBody(String endpointUri, Object body, Class<T> type) throws CamelExecutionException; 729 730 /** 731 * Sends the body to the default endpoint and returns the result content 732 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 733 * <br/><br/> 734 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 735 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 736 * the caused exception wrapped. 737 * 738 * @param body the payload 739 * @param header the header name 740 * @param headerValue the header value 741 * @return the result (see class javadoc) 742 * @throws CamelExecutionException if the processing of the exchange failed 743 */ 744 Object requestBodyAndHeader(Object body, String header, Object headerValue) throws CamelExecutionException; 745 746 /** 747 * Send the body to an endpoint returning any result output body. 748 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 749 * <br/><br/> 750 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 751 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 752 * the caused exception wrapped. 753 * 754 * @param endpoint the Endpoint to send to 755 * @param body the payload 756 * @param header the header name 757 * @param headerValue the header value 758 * @return the result (see class javadoc) 759 * @throws CamelExecutionException if the processing of the exchange failed 760 */ 761 Object requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue) throws CamelExecutionException; 762 763 /** 764 * Send the body to an endpoint returning any result output body. 765 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 766 * <br/><br/> 767 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 768 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 769 * the caused exception wrapped. 770 * 771 * @param endpoint the Endpoint to send to 772 * @param body the payload 773 * @param header the header name 774 * @param headerValue the header value 775 * @param type the expected response type 776 * @return the result (see class javadoc) 777 * @throws CamelExecutionException if the processing of the exchange failed 778 */ 779 <T> T requestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type) throws CamelExecutionException; 780 781 /** 782 * Send the body to an endpoint returning any result output body. 783 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 784 * <br/><br/> 785 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 786 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 787 * the caused exception wrapped. 788 * 789 * @param endpointUri the endpoint URI to send to 790 * @param body the payload 791 * @param header the header name 792 * @param headerValue the header value 793 * @return the result (see class javadoc) 794 * @throws CamelExecutionException if the processing of the exchange failed 795 */ 796 Object requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue) throws CamelExecutionException; 797 798 /** 799 * Send the body to an endpoint returning any result output body. 800 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 801 * <br/><br/> 802 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 803 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 804 * the caused exception wrapped. 805 * 806 * @param endpointUri the endpoint URI to send to 807 * @param body the payload 808 * @param header the header name 809 * @param headerValue the header value 810 * @param type the expected response type 811 * @return the result (see class javadoc) 812 * @throws CamelExecutionException if the processing of the exchange failed 813 */ 814 <T> T requestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type) throws CamelExecutionException; 815 816 /** 817 * Sends the body to an endpoint with the specified headers and header values. 818 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 819 * <br/><br/> 820 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 821 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 822 * the caused exception wrapped. 823 * 824 * @param endpointUri the endpoint URI to send to 825 * @param body the payload to send 826 * @param headers headers 827 * @return the result (see class javadoc) 828 * @throws CamelExecutionException if the processing of the exchange failed 829 */ 830 Object requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers) throws CamelExecutionException; 831 832 /** 833 * Sends the body to an endpoint with the specified headers and header values. 834 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 835 * <br/><br/> 836 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 837 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 838 * the caused exception wrapped. 839 * 840 * @param endpointUri the endpoint URI to send to 841 * @param body the payload to send 842 * @param headers headers 843 * @param type the expected response type 844 * @return the result (see class javadoc) 845 * @throws CamelExecutionException if the processing of the exchange failed 846 */ 847 <T> T requestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers, Class<T> type) throws CamelExecutionException; 848 849 /** 850 * Sends the body to an endpoint with the specified headers and header values. 851 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 852 * <br/><br/> 853 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 854 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 855 * the caused exception wrapped. 856 * 857 * @param endpoint the endpoint URI to send to 858 * @param body the payload to send 859 * @param headers headers 860 * @return the result (see class javadoc) 861 * @throws CamelExecutionException if the processing of the exchange failed 862 */ 863 Object requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers) throws CamelExecutionException; 864 865 /** 866 * Sends the body to the default endpoint and returns the result content 867 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 868 * <br/><br/> 869 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 870 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 871 * the caused exception wrapped. 872 * 873 * @param body the payload to send 874 * @param headers headers 875 * @return the result (see class javadoc) 876 * @throws CamelExecutionException if the processing of the exchange failed 877 */ 878 Object requestBodyAndHeaders(Object body, Map<String, Object> headers) throws CamelExecutionException; 879 880 /** 881 * Sends the body to an endpoint with the specified headers and header values. 882 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 883 * <br/><br/> 884 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 885 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 886 * the caused exception wrapped. 887 * 888 * @param endpoint the endpoint URI to send to 889 * @param body the payload to send 890 * @param headers headers 891 * @param type the expected response type 892 * @return the result (see class javadoc) 893 * @throws CamelExecutionException if the processing of the exchange failed 894 */ 895 <T> T requestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type) throws CamelExecutionException; 896 897 898 // Asynchronous methods 899 // ----------------------------------------------------------------------- 900 901 /** 902 * Sets a custom executor service to use for async messaging. 903 * 904 * @param executorService the executor service. 905 */ 906 void setExecutorService(ExecutorService executorService); 907 908 /** 909 * Sends an asynchronous exchange to the given endpoint. 910 * 911 * @param endpointUri the endpoint URI to send the exchange to 912 * @param exchange the exchange to send 913 * @return a handle to be used to get the response in the future 914 */ 915 CompletableFuture<Exchange> asyncSend(String endpointUri, Exchange exchange); 916 917 /** 918 * Sends an asynchronous exchange to the given endpoint. 919 * 920 * @param endpointUri the endpoint URI to send the exchange to 921 * @param processor the transformer used to populate the new exchange 922 * @return a handle to be used to get the response in the future 923 */ 924 CompletableFuture<Exchange> asyncSend(String endpointUri, Processor processor); 925 926 /** 927 * Sends an asynchronous body to the given endpoint. 928 * Uses an {@link ExchangePattern#InOnly} message exchange pattern. 929 * 930 * @param endpointUri the endpoint URI to send the exchange to 931 * @param body the body to send 932 * @return a handle to be used to get the response in the future 933 */ 934 CompletableFuture<Object> asyncSendBody(String endpointUri, Object body); 935 936 /** 937 * Sends an asynchronous body to the given endpoint. 938 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 939 * 940 * @param endpointUri the endpoint URI to send the exchange to 941 * @param body the body to send 942 * @return a handle to be used to get the response in the future 943 */ 944 CompletableFuture<Object> asyncRequestBody(String endpointUri, Object body); 945 946 /** 947 * Sends an asynchronous body to the given endpoint. 948 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 949 * 950 * @param endpointUri the endpoint URI to send the exchange to 951 * @param body the body to send 952 * @param header the header name 953 * @param headerValue the header value 954 * @return a handle to be used to get the response in the future 955 */ 956 CompletableFuture<Object> asyncRequestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue); 957 958 /** 959 * Sends an asynchronous body to the given endpoint. 960 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 961 * 962 * @param endpointUri the endpoint URI to send the exchange to 963 * @param body the body to send 964 * @param headers headers 965 * @return a handle to be used to get the response in the future 966 */ 967 CompletableFuture<Object> asyncRequestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers); 968 969 /** 970 * Sends an asynchronous body to the given endpoint. 971 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 972 * 973 * @param endpointUri the endpoint URI to send the exchange to 974 * @param body the body to send 975 * @param type the expected response type 976 * @return a handle to be used to get the response in the future 977 */ 978 <T> CompletableFuture<T> asyncRequestBody(String endpointUri, Object body, Class<T> type); 979 980 /** 981 * Sends an asynchronous body to the given endpoint. 982 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 983 * 984 * @param endpointUri the endpoint URI to send the exchange to 985 * @param body the body to send 986 * @param header the header name 987 * @param headerValue the header value 988 * @param type the expected response type 989 * @return a handle to be used to get the response in the future 990 */ 991 <T> CompletableFuture<T> asyncRequestBodyAndHeader(String endpointUri, Object body, String header, Object headerValue, Class<T> type); 992 993 /** 994 * Sends an asynchronous body to the given endpoint. 995 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 996 * 997 * @param endpointUri the endpoint URI to send the exchange to 998 * @param body the body to send 999 * @param headers headers 1000 * @param type the expected response type 1001 * @return a handle to be used to get the response in the future 1002 */ 1003 <T> CompletableFuture<T> asyncRequestBodyAndHeaders(String endpointUri, Object body, Map<String, Object> headers, Class<T> type); 1004 1005 /** 1006 * Sends an asynchronous exchange to the given endpoint. 1007 * 1008 * @param endpoint the endpoint to send the exchange to 1009 * @param exchange the exchange to send 1010 * @return a handle to be used to get the response in the future 1011 */ 1012 CompletableFuture<Exchange> asyncSend(Endpoint endpoint, Exchange exchange); 1013 1014 /** 1015 * Sends an asynchronous exchange to the given endpoint. 1016 * 1017 * @param endpoint the endpoint to send the exchange to 1018 * @param processor the transformer used to populate the new exchange 1019 * @return a handle to be used to get the response in the future 1020 */ 1021 CompletableFuture<Exchange> asyncSend(Endpoint endpoint, Processor processor); 1022 1023 /** 1024 * Sends an asynchronous body to the given endpoint. 1025 * Uses an {@link ExchangePattern#InOnly} message exchange pattern. 1026 * 1027 * @param endpoint the endpoint to send the exchange to 1028 * @param body the body to send 1029 * @return a handle to be used to get the response in the future 1030 */ 1031 CompletableFuture<Object> asyncSendBody(Endpoint endpoint, Object body); 1032 1033 /** 1034 * Sends an asynchronous body to the given endpoint. 1035 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1036 * 1037 * @param endpoint the endpoint to send the exchange to 1038 * @param body the body to send 1039 * @return a handle to be used to get the response in the future 1040 */ 1041 CompletableFuture<Object> asyncRequestBody(Endpoint endpoint, Object body); 1042 1043 /** 1044 * Sends an asynchronous body to the given endpoint. 1045 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1046 * 1047 * @param endpoint the endpoint to send the exchange to 1048 * @param body the body to send 1049 * @param header the header name 1050 * @param headerValue the header value 1051 * @return a handle to be used to get the response in the future 1052 */ 1053 CompletableFuture<Object> asyncRequestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue); 1054 1055 /** 1056 * Sends an asynchronous body to the given endpoint. 1057 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1058 * 1059 * @param endpoint the endpoint to send the exchange to 1060 * @param body the body to send 1061 * @param headers headers 1062 * @return a handle to be used to get the response in the future 1063 */ 1064 CompletableFuture<Object> asyncRequestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers); 1065 1066 /** 1067 * Sends an asynchronous body to the given endpoint. 1068 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1069 * 1070 * @param endpoint the endpoint to send the exchange to 1071 * @param body the body to send 1072 * @param type the expected response type 1073 * @return a handle to be used to get the response in the future 1074 */ 1075 <T> CompletableFuture<T> asyncRequestBody(Endpoint endpoint, Object body, Class<T> type); 1076 1077 /** 1078 * Sends an asynchronous body to the given endpoint. 1079 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1080 * 1081 * @param endpoint the endpoint to send the exchange to 1082 * @param body the body to send 1083 * @param header the header name 1084 * @param headerValue the header value 1085 * @param type the expected response type 1086 * @return a handle to be used to get the response in the future 1087 */ 1088 <T> CompletableFuture<T> asyncRequestBodyAndHeader(Endpoint endpoint, Object body, String header, Object headerValue, Class<T> type); 1089 1090 /** 1091 * Sends an asynchronous body to the given endpoint. 1092 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1093 * 1094 * @param endpoint the endpoint to send the exchange to 1095 * @param body the body to send 1096 * @param headers headers 1097 * @param type the expected response type 1098 * @return a handle to be used to get the response in the future 1099 */ 1100 <T> CompletableFuture<T> asyncRequestBodyAndHeaders(Endpoint endpoint, Object body, Map<String, Object> headers, Class<T> type); 1101 1102 /** 1103 * Gets the response body from the future handle, will wait until the response is ready. 1104 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 1105 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 1106 * the caused exception wrapped. 1107 * 1108 * @param future the handle to get the response 1109 * @param type the expected response type 1110 * @return the result (see class javadoc) 1111 * @throws CamelExecutionException if the processing of the exchange failed 1112 */ 1113 <T> T extractFutureBody(Future<?> future, Class<T> type) throws CamelExecutionException; 1114 1115 /** 1116 * Gets the response body from the future handle, will wait at most the given time for the response to be ready. 1117 * <p/><b>Notice:</b> that if the processing of the exchange failed with an Exception 1118 * it is thrown from this method as a {@link org.apache.camel.CamelExecutionException} with 1119 * the caused exception wrapped. 1120 * 1121 * @param future the handle to get the response 1122 * @param timeout the maximum time to wait 1123 * @param unit the time unit of the timeout argument 1124 * @param type the expected response type 1125 * @return the result (see class javadoc) 1126 * @throws java.util.concurrent.TimeoutException if the wait timed out 1127 * @throws CamelExecutionException if the processing of the exchange failed 1128 */ 1129 <T> T extractFutureBody(Future<?> future, long timeout, TimeUnit unit, Class<T> type) throws TimeoutException, CamelExecutionException; 1130 1131 // Asynchronous methods with callback 1132 // ----------------------------------------------------------------------- 1133 1134 /** 1135 * Sends an asynchronous exchange to the given endpoint. 1136 * 1137 * @param endpointUri the endpoint URI to send the exchange to 1138 * @param exchange the exchange to send 1139 * @param onCompletion callback invoked when exchange has been completed 1140 * @return a handle to be used to get the response in the future 1141 */ 1142 CompletableFuture<Exchange> asyncCallback(String endpointUri, Exchange exchange, Synchronization onCompletion); 1143 1144 /** 1145 * Sends an asynchronous exchange to the given endpoint. 1146 * 1147 * @param endpoint the endpoint to send the exchange to 1148 * @param exchange the exchange to send 1149 * @param onCompletion callback invoked when exchange has been completed 1150 * @return a handle to be used to get the response in the future 1151 */ 1152 CompletableFuture<Exchange> asyncCallback(Endpoint endpoint, Exchange exchange, Synchronization onCompletion); 1153 1154 /** 1155 * Sends an asynchronous exchange to the given endpoint using a supplied processor. 1156 * 1157 * @param endpointUri the endpoint URI to send the exchange to 1158 * @param processor the transformer used to populate the new exchange 1159 * {@link Processor} to populate the exchange 1160 * @param onCompletion callback invoked when exchange has been completed 1161 * @return a handle to be used to get the response in the future 1162 */ 1163 CompletableFuture<Exchange> asyncCallback(String endpointUri, Processor processor, Synchronization onCompletion); 1164 1165 /** 1166 * Sends an asynchronous exchange to the given endpoint using a supplied processor. 1167 * 1168 * @param endpoint the endpoint to send the exchange to 1169 * @param processor the transformer used to populate the new exchange 1170 * {@link Processor} to populate the exchange 1171 * @param onCompletion callback invoked when exchange has been completed 1172 * @return a handle to be used to get the response in the future 1173 */ 1174 CompletableFuture<Exchange> asyncCallback(Endpoint endpoint, Processor processor, Synchronization onCompletion); 1175 1176 /** 1177 * Sends an asynchronous body to the given endpoint. 1178 * Uses an {@link ExchangePattern#InOnly} message exchange pattern. 1179 * 1180 * @param endpointUri the endpoint URI to send the exchange to 1181 * @param body the body to send 1182 * @param onCompletion callback invoked when exchange has been completed 1183 * @return a handle to be used to get the response in the future 1184 */ 1185 CompletableFuture<Object> asyncCallbackSendBody(String endpointUri, Object body, Synchronization onCompletion); 1186 1187 /** 1188 * Sends an asynchronous body to the given endpoint. 1189 * Uses an {@link ExchangePattern#InOnly} message exchange pattern. 1190 * 1191 * @param endpoint the endpoint to send the exchange to 1192 * @param body the body to send 1193 * @param onCompletion callback invoked when exchange has been completed 1194 * @return a handle to be used to get the response in the future 1195 */ 1196 CompletableFuture<Object> asyncCallbackSendBody(Endpoint endpoint, Object body, Synchronization onCompletion); 1197 1198 /** 1199 * Sends an asynchronous body to the given endpoint. 1200 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1201 * 1202 * @param endpointUri the endpoint URI to send the exchange to 1203 * @param body the body to send 1204 * @param onCompletion callback invoked when exchange has been completed 1205 * @return a handle to be used to get the response in the future 1206 */ 1207 CompletableFuture<Object> asyncCallbackRequestBody(String endpointUri, Object body, Synchronization onCompletion); 1208 1209 /** 1210 * Sends an asynchronous body to the given endpoint. 1211 * Uses an {@link ExchangePattern#InOut} message exchange pattern. 1212 * 1213 * @param endpoint the endpoint to send the exchange to 1214 * @param body the body to send 1215 * @param onCompletion callback invoked when exchange has been completed 1216 * @return a handle to be used to get the response in the future 1217 */ 1218 CompletableFuture<Object> asyncCallbackRequestBody(Endpoint endpoint, Object body, Synchronization onCompletion); 1219 1220}