• Post Reply Bookmark Topic Watch Topic
  • New Topic

Performing IO from Session Bean

 
Rajasekar Elango
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

We had to read data from files from our ejb session beans to implement our business logic.

But I heard performing IO operations from ejb is not adviceable.

Can anyone let me know the shortcomings (that we have to be aware) of doing io from session bean and also is there any alternate solution for this.?

Thanks,
Raja
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem with the shortcomings of performing IO from EJB is that there is nothing you can do to solve them - since the container manages the bean. There are routes round this, specifically JCA. You will need a JCA Adapter to give you access to the file systems in a way which is safe for EJB.
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the shortcomings of session beans for I/O operations may be -

1. timeout factor - after which the bean is reclaimed by the container.
2. for stateless session beans, the state is not preserved between diff. method calls. So the handle to I/O operations can't be maintained across diff. method calls i.e. can't be maintained as class variables. This I/O operations will have to be opened and closed in same method.
3. In stateless session bean- subsequent call to same method can be processed by any instance of session bean that is available in instance pool.

I am not quite sure about the alternative -
One way to solve above 3 points may be to use BMP beans create method for I/O operations instead of some sql insert statements. As BMP beans maintain state and the same instance serves a client request.
 
D. Rose
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have similar situation.
Can we use JMS to solve this?
I may post message when I need to read file. Listner could then read the file and send me back as message.
Has anybody actually tried out some solution for i/o problem?
Using JCA just for file read seems to be too much of work.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first issue I can see with that approach is since JMS is asynchronous you might be waiting a looong time for the "here's the file contents" message. JMS is asynchronous therefore how your app uses IO would need to be too.
 
Rajasekar Elango
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Everyone,

Thanks,
Raja
 
Robert Hayes
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, I've tried JMS for flatfile and XML transmission and it works fine. It is asynchronous, but why exactly would a message take a "looong time" to get to its consumer under normal conditions?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!