Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

multithreaded and transactional EJB System - a greenhorn's question  RSS feed

 
Rodrigo Bossini
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

I'm just starting to study EJB, by reading the Enterprise JavaBeans 3.0 book.

Actually, I'm doing this because in the near future I plan to use this technology in my company.

Today, we have an application that accesses N FTP servers and downloads files for the N corresponding local directories. It does uploads as well. Each of the FTP servers belongs to one specific client of our company. Therefore, the app must be multithreaded. And it is. It manages multiple threads, one for each of the ftp servers it has to access. We are using the Apache FTP API for the FTP operations.

So here's my question:


- If I were to develop this application using EJB, one of the benefits it would provide me with is the multithreaded management?

Say, the code from the run methods from the threads of my application today would be passed to the EJB, which would run and manage one thread for each of the FTP configurations that I pass on to it?


Another thing:

- I'd like it to be a transactional system. All of the downloads and uploads are registered in a database. And right after it has abeen registered, the downloaded file is deleted from the FTP server from which it was downloaded. I'd like the file to only be deleted if it had really been downloaded and registered in the database. I believe it is a transactional behavior, right?
Today, if some exception occurs, it might happen that the file was downloaded and registered in the database, but never deleted from the FTP server. Would EJB grant me this too?

And another thing:

In a few weeks I'll need to develop a system that is specialized in sending and downloading emails. Like this FTP service I mentioned above, it will have to be a multhreaded system as well. Would it be recommendable to develop such a system by using EJB technology?

Thank you.

 
Francesco Marchioni
author
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session EJB manages cuncurrency by allowing n instances to run in parallel. Each time you need to execute an EJB method an instance from the pool is retrieved (if available) and thus made available.

I'd like it to be a transactional system. All of the downloads and uploads are registered in a database. And right after it has abeen registered, the downloaded file is deleted from the FTP server from which it was downloaded. I'd like the file to only be deleted if it had really been downloaded and registered in the database. I believe it is a transactional behavior, right?

File systems are not transactional, so you'd need to write a Resource Manager which allows to roll back files in case of exception/rollback. So in short, you don't get this out of the box with EJB.
I'd suggest to have a look at this project:
http://commons.apache.org/transaction/file/index.html
regards
Francesco
MyJBossSite
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!