A client send a message to a queue.The MDB calls the MessageDrivenContext.getCallerPrincipal() upon receiving the message.what will be the return value of this method execution? 1. It will return the principal object associated with the client sending the message 2.It will return the value of security role defied for the method. 3. It will throw a runtime Exception 4. It will return a null value.
Whats the correct ans..please explain I answered 1. But whizlabs says its 3.
As far as MDB are concerned, there's no client. An MDB does not know who really sent the message first, so all client related methods cannot be used. Please refer to 15.4.3 The MessageDrivenContext interface in the specification. Also, this method never returns null, so you can also discard number 4.
Invoking the getCallerPrincipal and isCallerInRole methods is disallowed in the message-driven bean methods because the Container does not have a client security context. The Container must throw and log the java.lang.IllegalStateException if either of these methods is invoked.
Please refer to Specification 15.5.1
what if we put solar panels on top of the semi truck trailer? That could power this tiny ad: