I have given the received message length as 1000000 but still message gets truncated completed code is below
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");
}
}
}
If the length of the message exceeds some limit i don't know how much , but its getting truncated , any way to increase or workaround to display complete message.
As Germann pointed out the parameter that you pass to receive method is not the message size, it is actually the wait time in milli seconds. Meaning how long the call must wait for a message to arrive. For example if you have set the wait time as 1000, then the receive call will wait for 1 second for message to arrive. If a message arrives before 1 second, the call will return immediately and give the message to application. If a message does not arrive even after a second, then the call will return with a timeout and no message is given to application. In MQ terms you will see a 2033 reason code.
How are you determining that the message is truncated? Are you getting a MQRC_TRUNCATED_MESSAGE_FAILED exception? This exception will be thrown if the application supplied buffer is not enough to fill the incoming message. MQ JMS is not expected to throw a MQRC_TRUNCATED_MESSAGE_FAILED exception as it internally handles the buffer size required and returns message to application.
I am guessing that the issue could be because you are printing a JMSMessage whereas the sent message is a JMSTextMessage. JMSMessage.ToString may not be printing the whole message.