You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Using Exchange Pattern Annotations

When working with Bean Integration or Spring Remoting you invoke methods which typicaylly by default are InOut for request/reply. That is there is an In message and an Out for the result. Typically invoking this operation will be synchronous, the caller will block until the server returns a result.

Its often required to support the InOnly message exchange pattern for asynchronous or one way operations. These are often called 'fire and forget' like sending a JMS message but not waiting for any response.

From 1.5 onwards Camel supports annotations for specifying the message exchange pattern on regular Java methods, classes or interfaces.

Typically the default InOut is what most folks want but you can customize to use InOnly using an annotation.

public interface Foo {
  Object someInOutMethod(String input);
  String anotherInOutMethod(Cheese input);
  
  @InOnly
  void someInOnlyMethod(Document input);
}

The above code shows three methods on an interface; the first two use the default InOut mechanism but the someInOnlyMethod uses the InOnly annotation to specify it as being a oneway method call.

  • No labels