[英]JMS: Can be the message null in the onMessage of MessageListener?
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)? 如果我的MessageConsumer正在实现MessageListener (JBoss JMS 1.1 API),那么在Method onMessage(message)中消息可以为null的情况是什么?
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.
所有示例都假定消息不为null。 According to http://docs.oracle.com/javaee/6/tutorial/doc/bnbpo.html :
根据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.
即使是空消息也必须具有消息ID和发送日期。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.