posted 17 years ago
What will happen when you try to compile the following message driven bean? Assume all packages are correctly imported.
1.public class GatewayBean implements MessageDrivenBean, MessageListener {
2. public GatewayBean(){}
3. public void ejbCreate(){}
4. public void onMessage(TextMessage msg){}
5. public void ejbRemove(){}
6. public void setMessageDrivenContext(MessageDrivenContext ctx){}
7.}
1. Compilation error, incorrect declaration on line 3.
2. Compilation error, incorrect declaration on line 4.
3. The code compiles fine.
4. Compilation error, the GatewayBean class must be declared abstract.
5. Compilation error, the GatewayBean class must be declared final.
Answer 2 is correct.
The message-driven bean class must define one onMessage method whose signature must follow these rules:
The method must be declared as public.
The method must not be declared as final or static.
The return type must be void.
The method must have a single argument of type javax.jms.Message.
The throws clause must not define any application exceptions.
I don't understand why this mthod is declared wrong.
I believe it follows all the above rules....what am I missing?