JBI components are slightly heavyweight objects; there's a bit of plumbing required for the component developer to write. To make things easier for the developer, we support POJOs. In addition we provide a PojoSupport and ComponentSupport classes making it easy to write new POJOs or components with very little code.

MessageExchangeListener interface

To be able to receive new message exchanges easily, rather than writing a new thread, just implement this interface. Its analagous to the JMS MessageListener interface. The ServiceMix container will detect the use of this interface and be able to perform immediate dispatch (rather than the default JBI asynchronous dispatch model where a thread is used per JBI component).

Useful helper methods

The PojoSupport and ComponentSupport classes have a number of helper methods making it easier to write concise JBI POJOs and components.

done(MessageExchange)

Will set the status to DONE and send the message into the delivery channel in one easy method call. There is a similar fail(MessageExchange, Fault) method to quicly fail a message exchange too.

init()

Rather like the servlet init helper method, this method allows you to provide some POJO/component specific initialisation, but let the base class deal with the ComponentContext. After the call to init() if the service and endpoint names are configured, the component will activate itself.

getDeliveryChannel() and getContext()

Provides getter methods to the core propertes of the component.

getMessageExchangeFactory()

Lazily creates a default MessageExchangeFactory. Create your own factory instances for specific services / endpoints.

getBody() and setBody()

These methods allow you to get and set the message body as a POJO using whatever marshaling mechanism is being used. e.g. if a JavaSource is used for the body or some XML marshaling tool like XStream or JAXB is used then these helper methods provide access to the underlying POJO.

service and endpoint properties

Bean properties which can be used to configure (or hard wire) the service QName and endpoint name. If these are configured before the init(ComponentContext) is invoked, then the endpoint will automatically activate itself.

  • No labels