我已将接收到的消息长度设为 1000000,但消息仍被截断完成的代码如下
import java.io.FileInputStream;
import javax.jms.JMSException;
import javax.jms.Session;
import com.ibm.jms.JMSMessage;
import com.ibm.jms.JMSTextMessage;
import com.ibm.mq.jms.JMSC;
import com.ibm.mq.jms.MQQueue;
import com.ibm.mq.jms.MQQueueConnection;
import com.ibm.mq.jms.MQQueueConnectionFactory;
import com.ibm.mq.jms.MQQueueReceiver;
import com.ibm.mq.jms.MQQueueSender;
import com.ibm.mq.jms.MQQueueSession;
public class SimplePTP {
public static void main(String[] args) {
try {
MQQueueConnectionFactory cf = new MQQueueConnectionFactory();
String request= null;
// Config
cf.setHostName("CTMQ9000");
cf.setPort(1414);
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setQueueManager("CTMQTST01");
cf.setChannel("SYSTEM.ADMIN.SVRCONN");
MQQueueConnection connection = (MQQueueConnection) cf.createQueueConnection();
MQQueueSession session = (MQQueueSession) connection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
MQQueue queue = (MQQueue) session.createQueue("CONTPLAT.CPS.DELIVERYPREP.REQUEST.TEST");
MQQueueSender sender = (MQQueueSender) session.createSender(queue);
MQQueue queue1 = (MQQueue) session.createQueue("CONTPLAT.CPS.DELIVERYPREP.RESPONSE.TEST");
MQQueueReceiver receiver = (MQQueueReceiver) session.createReceiver(queue1);
String request ="sdfHelp Me Name name for Photo Studio!I'm opening a portrait studio in a my town and am stuck on what to name it. I will be photographing (Portrait, wedding Photography)) children and families both at the studio and on location.sdffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffsdf"
long uniqueNumber = System.currentTimeMillis() % 1000;
JMSTextMessage message = (JMSTextMessage) session.createTextMessage(request);
// Start the connection
connection.start();
sender.send(message);
System.out.println("Sent message:\\n" + message +"lol");
Thread.sleep(2000);
JMSMessage receivedMessage = (JMSMessage) receiver.receive(10000000);
System.out.println("\\nReceived message:\\n" + receivedMessage);
sender.close();
receiver.close();
session.close();
connection.close();
System.out.println("\\nSUCCESS\\n");
}
catch (JMSException jmsex) {
System.out.println(jmsex);
System.out.println("\\nFAILURE\\n");
}
catch (Exception ex) {
System.out.println(ex);
System.out.println("\\nFAILURE\\n");
}
}
}
如果消息的长度超过某个限制,我不知道有多少,但它会被截断,任何增加或解决方法以显示完整消息。