LibraryToggle FramesPrintFeedback

Destination choosers implement the org.apache.servicemix.jms.endpoints.DestinationChooser interface. This interface has a single method: chooseDestination().

chooseDestination(), whose signature is shown in Example 7.1, takes the JBI message exchange and a copy of the message. It returns either a JMS Destination object or a string representing the destination name.

[Note]Note

If the destination chooser returns a string, the endpoint will use a destination resolver to convert the string into a JMS destination. See Using a Custom Destination Resolver.


The message parameter can be either of the following type of object:

  • javax.jbi.messaging.NormalizedMessage

  • javax.jbi.messaging.Fault

  • Exception

Example 7.2 shows a simple destination chooser implementation. It checks the message for a property that represents the JMS destination on which the request is to be placed.


You can configure an endpoint to use a custom destination chooser in one of two ways. The recommended way is to configure the destination chooser as a bean and have the endpoint reference the destination chooser's bean. The other way is to explicitly include the destination chooser's configuration as a child of the endpoint.

As shown in Example 7.3, configuring an endpoint's destination chooser using a bean reference is a two step process:

  1. Configure a bean element for your destination chooser.

  2. Add a destinationChooser attribute that references the destination chooser's bean to your endpoint.


Example 7.4 shows an example configuration using the jms:destinationChooser element. This method is less flexible than the recommended method because other endpoints cannot reuse the destination chooser's configuration.


Comments powered by Disqus