從隊列接收消息時的NPE。 (僅當消息存在於隊列中時)。我覺得在反序列化消息時存在一個問題。從Azure服務總線接收消息時的NPE隊列
顯示java.lang.NullPointerException 在com.sun.jersey.api.client.ClientResponse.getResponseDate(ClientResponse.java:738) 在com.microsoft.windowsazure.services.servicebus.implementation.ServiceBusRestProxy.receiveMessage( ServiceBusRestProxy.java:288) 在com.microsoft.windowsazure.services.servicebus.implementation.ServiceBusRestProxy.receiveQueueMessage(ServiceBusRestProxy.java:225) 在com.microsoft.windowsazure.services.servicebus.implementation.ServiceBusExceptionProcessor.receiveQueueMessage(ServiceBusExceptionProcessor。 java:142)
RECEIVE_AND_DELETE選項d輸入消息並拋出NPE。
所有其他操作,如創建隊列,發送消息等工作正常。有這個想法嗎?
代碼收到消息
public void receiveMessage(String queueName) {
try {
ReceiveMessageOptions opts = ReceiveMessageOptions.DEFAULT;
opts.setReceiveMode(ReceiveMode.PEEK_LOCK);
while (true) {
ReceiveQueueMessageResult resultQM
= service.receiveQueueMessage(queueName, opts);
BrokeredMessage message = resultQM.getValue();
if (message != null && message.getMessageId() != null) {
log.println("MessageID: " + message.getMessageId());
// Display the queue message.
log.print("From queue: ");
byte[] b = new byte[200];
String s = null;
int numRead = message.getBody().read(b);
while (-1 != numRead) {
s = new String(b);
s = s.trim();
System.out.print(s);
numRead = message.getBody().read(b);
}
log.println("");
log.println("Custom Property: "
+ message.getProperty("MyProperty"));
// Remove message from queue.
log.println("Deleting this message.");
//service.deleteMessage(message);
} else {
log.println("Finishing up - no more messages.");
break;
// Added to handle no more messages.
// Could instead wait for more messages to be added.
}
}
} catch (Exception e) {
log.print(e);
}
}