因此,我向 WebSphere 发送了一条消息,并成功地将其放入队列中。但是,我在将其从另一个队列中取出时遇到了问题。但是当我使用该行向我发送消息时我注意到了这一点:
inputMessage.writeUTF(消息);消息是:
basket/argos/1001?authToken=fgTSdfs&trustToken=gdf43FsfSFefs33&apiKey=ahjd9234imnmdfnwi&sig=abcde&currency=GBP
它存储在一个 xml 文件中,它在消息的前面附加了一个“n”。谁能告诉我为什么?代码如下:
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
// Config
cf.setHostName(hostname);
cf.setPort(portNumber);
cf.setQueueManager(queueManager);
cf.setChannel(channel);
//MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
//MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
//MQQueue queue = (MQQueue) session.createQueue(inputQueue);
//MQQueue queue = (MQQueue)session.
//MQQueueSender sender = (MQQueueSender) session.createSender(queue);
//MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(queue);
MQQueueManager qMgr = new MQQueueManager(queueManager);
System.out.println("Queue manager created");
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |
MQC.MQOO_OUTPUT ;
System.out.println("MQ Options created");
MQQueue mqInputQueue =
qMgr.accessQueue(inputQueue,
openOptions);
System.out.println("Queue created");
MQMessage inputMessage = new MQMessage();
inputMessage.writeUTF(message);
System.out.println("message created and sent");
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults,
// same as
// MQPMO_DEFAULT
// constant
System.out.println("Queue options created");
// put the message on the queue
mqInputQueue.put(inputMessage,pmo);
System.out.println("Message put on queue");
mqInputQueue.close();