is there any case where the message could be null in the Method onMessage(message), if my MessageConsumer is implementing the MessageListener (JBoss JMS 1.1 API)?
import javax.jms.MapMessage;
import javax.jms.Message;
import javax.jms.MessageListener;
@MessageDriven( ... )
public class MyMessageConsumer implements MessageListener {
@Override
public void onMessage(final Message message) {
// is there any case, where message could be null here?
}
}
The interface alone does not prevent that. All examples assume that the message is not null. According to http://docs.oracle.com/javaee/6/tutorial/doc/bnbpo.html :
The onMessage method is called by the bean’s container when a message
has arrived for the bean to service.
In my opinion that means, that message may not be null. Even an empty message must have a message ID and a date of sending.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.