Reputation: 2445
So im sending a message to WebSphere and its successfully putting it on a queue. However I have having an issue getting it off another queue. But what I have noticed it when im sending me message using the line :
inputMessage.writeUTF(message);
with the message being:
basket/argos/1001?authToken=fgTSdfs&trustToken=gdf43FsfSFefs33&apiKey=ahjd9234imnmdfnwi&sig=abcde&currency=GBP
which is store in an xml file, it is appending a "n" to the front of the message. Can anyone tell me why? the code is below:
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();
Upvotes: 0
Views: 777
Reputation: 15263
How are you reading the message after it is received? are using readUTF
method? If you have used writeUTF
while sending a message, then you must use readUTF
method retrieve the message body after receive. The "n" could actually be the length of the XML message as, in UTF string, the first two bytes indicate the length of the string that follows.
Upvotes: 3