concept bean component in category esb

appears as: be component, bean component, The be component
Open-Source ESBs in Action: Example Implementations in Mule and ServiceMix

This is an excerpt from Manning's book Open-Source ESBs in Action: Example Implementations in Mule and ServiceMix.

Besides the bean component, there is another way of using POJOs in ServiceMix. In chapter 6 we show you how you can use the JSR181 service engine to expose POJOs in ServiceMix to be consumed by other services. However, with the servicemix-bean service engine, you have easy access to the JBI context, which in the JSR181 service engine is more difficult. So it’s easier to use the JSR181 service engine when you already have functionality that doesn’t need to know anything about JBI, and it’s easier to use the servicemix-bean component when you require access to the JBI environment.

Notice that we use a JMS BC as a typical example of an in-only message exchange and an HTTP BC to explain an in-out message exchange. Both components can also be used with another message exchange pattern, but the common usage is shown in these figures. When an exception occurs in the bean component with an in-only message exchange, this still means that a fault message is sent to the NMR. However, the message flow will stop there because no routing path exists for the NMR to route the fault message to an endpoint. Therefore, the message flow is terminated and the exception is logged.

Figure 8.4. A one-way message flow implementation that uses the Camel component as an error-handling mechanism for the invocation of the bean component

The Camel component provides a default error-handling mechanism that also includes redelivery policies to define such parameters as the maximum number of redeliveries. When a fault message is sent to the Camel component, as shown in figure 8.4, the error handler processes the fault message. The default error handler tries to redeliver the message to the bean component six times. When the message isn’t successfully consumed by the bean component after the sixth retry, the message is sent to the default dead letter channel, which is a log file. But you can also configure your own dead letter channel configuration to send the fault message to a JMS error queue (see listing 8.3).