Question

I'm writing an inbound resource adapter (connector module) on Glassfish 3.1 and I've noticed in the Java EE SDK samples that an MDB is used to deliver messages from an EIS to Glassfish applications. Is it necessary to use an MDB if the target object is an EJB? Would it be wise to do a JNDI lookup for the target EJB and deliver to it directly, avoiding the MDB altogether?

Thanks!

Was it helpful?

Solution

In the latter case you perform a synchronous operation, whereas the first approach is an asynchronous one. In application to application (A2A) integration scenarios it's almost always a good decision to implement an asynchronous interface. A lot has been written about this, let me just refer to the Java documentation itself, e.g. section 6.3.3:

When designing your application, you need to decide whether to use synchronous or asynchronous integration with its target EISes and existing applications. Both synchronous and asynchronous integration approaches are valid for application integration, and the choice should be based on the integration requirements and use cases. Base your decision on the following guidelines.

  • Quality of services required--The use of a queue or a publish-subscribe system provides higher quality of services, such as message routing and reliable message delivery, than synchronous communications.
  • Application throughput--Asynchronous messaging can lead to better throughput because a queue buffers messages, supports message routing, and guarantees message delivery.
  • Transactional integration--A synchronous communication model is more suitable when an application needs to perform secure and transactional access to one or more EISes synchronously for client request processing. In such cases an application can afford the overhead of tighter coupling with an EIS to ensure higher quality request processing and error handling.
  • Programming model complexity--An asynchronous communication programming model is more complex than the more common synchronous request-response model. While the asynchronous model provides more services, the cost is greater application complexity and more work on the part of developers.

To conclude, maybe it's not necessary, but it may be wise to implement an MDB.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top