• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Performing IO from Session Bean

 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 346
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 215
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Everyone,

Thanks,
Raja
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic