我正在构建一些 MQ 队列连接,我需要将消息队列从queueReceiver.Receivenowait().
因为queueReceiver.Receivenowait()格式是字节,我需要将它转换为文本消息,以便将消息转换为数组列表。
我已经这样做了:
queueReceiver = queueSession.createReceiver(ringQueue);
要获取 Bytemessage,我需要转换为 JMS 文本消息:
List<String> outputList = new ArrayList<String>();
while (loop) {
TextMessage msgResponse = (TextMessage) bytesMessage;
if (msgResponse.getText() == null) {
loop = false;
} else {
message = msgResponse.getText();
outputList.add(message);
msgResponse.acknowledge();
}
}
我有这个错误代码:
java.lang.ClassCastException: com.ibm.jms.JMSBytesMessage cannot be cast to javax.jms.TextMessage
RISEBY
茅侃侃
相关分类