EJB design: Using EJB SSB for file transfer

  1. Using EJB SSB for file transfer (3 messages)

    How would one design a file transfer mechanism using EJB stateless session beans? The requirements are (1) reasonable performance (compared to FTP), (2) it must support file sizes larger than the client or server JVM memory (3) it must support both "put" to the server, and "get" from the server, (4) on the server side, the file data is read/written directly on the server file system - it does not go to a database (which yes, violates EJB specs).

    In our current application our client code makes extensive use of EJBs (using facade beans to the server side business logic and CMPs), and JMS for asyncrounous functions. We now have the need to support file transfer in this application. We already have all the infrstructure for EJB and JMS and we don't want to add any new protocols (e.g. FTP) especially since we already have the secure, authenticated connections for EJB and JMS. JMS does not seem like a good fit from a performance perspective and the async model is not good for this use because the transfer must have some transactional semantics (e.g. some things cannot proceed until the transfer is known to have been completed). It makes the client side much more difficult to code to.

    So the design question is, at a fundamental level, what is the best way to transfer very large amounts of binary data using EJBs? The client -> server mechanism seesm fairly straight forward... the client first gets (or generates) a unique key and then reads chuncks of the file from disk and sends them with the key to a server SSB. The SSB maps the key to a local file name and just appends data to the file on each 'write' call.

    The server -> client transfer seems more problematic. The client calls to 'read' a file and is returned a chunck of data. To get the next chunck, it must call again and tell the SSB where in the file to start reading the next chunk (since the SSB keeps no state on a per-client basis). The SSB has to re-open and seek into the file on every call... seems like this might be slow.

    Any ideas or experience in this area? I looked for any EJB design patterns but have not seen any that fit this need.


    Threaded Messages (3)

  2. Look at this for you need[ Go to top ]

    As far as your requirement is concerned , I think it is not a good idea to use EJB's at all. Why dont you use some pojo and implement it. As you said u need to transfer upload file from client to server and vice versa using also you said the file size is huge. For these kind of operation FTP is best to work with not SSB. Why dont you look at http://www.jscape.com/inetfactory/ this site. I used their api for large file transfers in web applications and it works fine and scalable to. As far as your transactional requirement even if you use ssb u have to code for that coz this is not a database trasaction to use declaraive transaction. So your purpose of SSB is of no use here.
  3. Using EJB SSB for file transfer[ Go to top ]

    You have not found any patterns because (I think..........) the EJB spec expressly prohibits EJBs from reading or writing to the filesystem (no file I/O).
  4. RE: Using EJB SSB for file transfer[ Go to top ]

    Have you found a suitable pattern for ejb file read/write?
    I'm currently looking for the same.
    Ps. I thougt of call a regular java object from an stateless session bean. But, somehow, this seems to be a hack...