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.
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?