Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Should I use EJB?  RSS feed

 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi-
I was wondering if anyone could offer some architectural advice. I need to create a service that does the following:

1.take a plain text file provided by a client
2.run some non-java executables on that file
3.return the binary output file to the client (could be anywhere from 2-60 meg)

Would it be appropriate to use a stateless session bean for this purpose? Is it not wise to transfer large, serialized binary files over the RMI protocol used in EJB?

Thanks
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The questions you need to ask yourself is do you need transactional support, easy access to the persistance api, inter-ejb communications, etc

These are services the EJB container gives you at a complexity and performance overhead, so if you're not using those services, a Session bean probably isn't a good choice.

If you do choose to use a session bean that transfer the data in a Data Transfer Object (Value Object) to avoid unnecessary RMI overhead - or use local interfaces.
 
Dudley Dawson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really need transaction management or persistence (I thought that they were only applicable to entity beans anyway)
What i really need is loose coupling and remote access to this service. And it would also have to scale in a way that is transparent to the remote clients.

If you do choose to use a session bean that transfer the data in a Data Transfer Object (Value Object) to avoid unnecessary RMI overhead - or use local interfaces.


Can you elaborate on this? The DTO would still have to be passed back through the call to the EJB, which uses RMI, correct?
 
Daniel Rhoades
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, sorry I was talking about EJB 3.0

In EJB 2.x transaction management can be done with entity beans and sessions for different reasons, but since you're not using persistance I won't go into detail (though session bean transaction management is not limited to entity beans).

You make a remote call to an EJB over RMI and yes what ever you send back gets serialised in the call-back - but a DTO holds a copy of all the data, so subsequent calls to get individual properties just access the DTO in memory on the client rather than being RMI calls, for example:

User user = myBean.registerUser(email);

user.getEmail()
user.getPassword()

Any method calls on the user object have no remote overhead, the data (the serialised user object) is already with the client at that point.

I don't think performance would vary greatly puting 60Mb of data into a DTO and sending via an EJB callback or some other remote object serialisation method.

There are several other ways you could get the data back to the client without serialisation - an IO stream perhaps?
 
shankar sawant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Daniel that 60G of data will not affect the performance if we implement this service as Session bean. But pure RMI implementation if designed well will be better option.

Explore this article "http://martin.nobilitas.com/java/thruput.html"
 
Masoud Kalali
Author
Ranch Hand
Posts: 531
Java Mac OS X Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by service ?
do you need to implement this functionality or it is decided that you implement it inside a container (application server or servlet container)?

I should say that It is not a case for EJB or RMI it is better that you do not envolve with them.

what i suggest is a simple network server that listen on specific tcp port for your clients request.
you can transform your text/binary file easily and there is no burdon of RMI or application server around.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!