Results 1 to 5 of 5

Thread: Spring MDB access

  1. #1
    Join Date
    Apr 2005
    Posts
    17

    Default Spring MDB access

    Hello, I am currently looking into using MDBs for asynchronous processing of large batches of data (and to be honest, I don't know much about MDB's at the moment).

    Currently, I am processing the data synchronously through a Spring-proxied SLSB with a relatively rich interface that is called from a JBoss scheduler. This works really great, but I need to do several of these calls in parallell to speed things up a bit. As far as I can see it, this can be solved by a) Starting multiple threads from the JBoss sceduler or b) Using asynchronous MDB calls.

    It seems to med that using MDBs is preferable, and will work well with clustering.

    However, I find very little information regarding MDB access in the Spring manual. Chapter 17 goes into detail when accessing SLSBs, but only mentions the existence of the AbstractMessageDrivenBean and AbtractJMSMessageDrivenBean.

    Could anyone point me to some information regarding configuration and use of MDBs with Spring proxies?

    Here is some questions I am having as a "MDB newbie":

    -Spring does an incredible job hiding the plumbing for accessing EJB's, but just how far does this go when switching from SLSB to MDB as remoting mechanism?
    -Can Spring make MDB vs SLSB access transparent at the application level?
    -Can I keep the same rich business interface I have for the SLSB?
    -or will I have to reduce my business interface to a single processMessage() method?
    -Does transactionhandling or exception handling differ significantly from proxied SLSBs?

    Thanks a lot,
    Karl Ivar Dahl

  2. #2
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    - Since AbstractMessageDrivenBean uses the same base classes as the SLSB stuff, it does plumbing the same way, except some of the methods are named differently (setMessageDrivenContext vs. setSessionContext)
    - The SLSB and MDB can both use the same business object from the same config file, if that is what you mean.
    - The MDB itself won't have the same interface as the SLSB, since onMessage is the "client". It calls the business object. The MDB will have a onMessage function, so you can either add the logic to call all your business methods in your business object inside the MDB, add a new business object which represents the client code or move that logic into your business object. Its up to you.
    - Since usually you handle transactions and exceptions in your business object proxy, and the MDB and SLSB just delegate to the business object, no. Those shouldn't change.
    Bill

  3. #3
    Join Date
    Apr 2005
    Posts
    17

    Default

    Thanks wpoitras, do you have an example on how the MDB delegates calls to the business object?

    This is how my SLSB does it:
    Code:
    public class AdminServiceBean extends AbstractStatelessServiceBean implements
    		AdminService {
    
    	private AdminService service = null;
    
    	protected void onEjbCreate() throws CreateException {
    		BeanFactory beanFactory = this.getBeanFactory();
    		this.service = (AdminService) beanFactory.getBean("adminService");
    	}
    
    	public AdminStatus getAdminStatus(AccessData access) throws EosException, RemoteException {
    		return service.getAdminStatus(access);
    	}
    ...
    This way, I can have a Spring-proxied POJO that implements my AdminService business interface at the remote client, and the EJB calls are transparent to the client.

    Is it possible to achieve the same result with an MDB? As only onMessage() can be called, will this reduce my business interface to a simple onMessage(), or will Spring wrap a business interface call to the client proxy in a Message and then "decode" the message the MDB receives? I cannot see any help for decoding a message in the AbstractMessageDrivenBean class, so I am a bit confused over what kind of abstraction Spring offers me here.

  4. #4
    Join Date
    Apr 2005
    Posts
    17

    Default

    After googling a bit more, it seems that Lingo may do what I am looking for:

    <snip>
    Lingo is an implementation of Spring Remoting which works with JMS and JCA. This release includes:-

    * synchronous, asynchronous oneway and async request-response method calls using JMS queues and/or topics
    * pure JMS and server side JCA support using Jencks
    * pluggable marshaler such as XStream support for XML payloads
    </snip>

    http://blogs.codehaus.org/archives/0... _and_jca.html

    Does this leave Spring with no support for accessing remote MDB's without Lingo? I'm looking for something similar to SimpleRemoteStatelessSessionProxyFactoryBean.

    -Karl Ivar

  5. #5
    Join Date
    Feb 2005
    Location
    Boston, MA
    Posts
    1,142

    Default

    You are correct. Spring doesn't do JMS remoting like Lingo does. But that's not a problem. Just use Lingo. Spring often doesn't try to reinvent the wheel if its not needed.
    Bill

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •