• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

another mock question

 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1 public void onMessage(Message msg)
2 {
3 System.out.println("Message received.");
4 boolean flag = getBooleanProperty("myflag"); //assume flag is always true
5 if(flag)
6 {
7 throw new EJBException("Can't process this message."); //line 10
8 }
9 }


Which of the given options are correct regarding the following onMessage code for a message driven bean with container managed transactions and a transaction attribute of 'Required'?
Select 1 correct option.

a It is invalid because a message driven bean cannot throw an EJBException.

b It may potentially bring down the application server.

c It will work well if line 7 is replaced with: context.setRollbackOnly();

d It is a valid and harmless code that does nothing.
 
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My take on this -
D

Once it runs, Container is going to --
1. rollback the transaction.
2. log the error
3. discard the MDB instance.

Bean can thow EJBEXception, but contianer can not. Am I missing something?

Gemini
[ March 21, 2005: Message edited by: Gemini Moses ]
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Option a, c and d are incorrect.

Is it because this code may produce poison messages, the author is worried that the application server would crash? Thats interesting!
 
Gemini Moses
Ranch Hand
Posts: 245
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Keerthi,

so what I said is wrong? ---

MDB Bean can throw EJBEXception, but contianer can not

Thanks,
Gemini

[ March 21, 2005: Message edited by: Gemini Moses ]
[ March 21, 2005: Message edited by: Gemini Moses ]
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Gemini, I think MDB beans as well as container can throw EJBException.
Keerthi mentioned about poison messages. In CMT beans the message acknowledge is tied to the status. If bean can't commit, that message will keep coming back again n again. But still I don't understand how can it harm application server?
 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

The ApplicationServer comes down because onMessage is being invoked infinetly in this case.

Thanks

Ravi
 
Ranch Hand
Posts: 162
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,
My take is that ..
you can throw eje exception so 1 is wrong.
setRollbackOnly is ok.
Amol.
 
reply
    Bookmark Topic Watch Topic
  • New Topic