Skip to content
Advertisement

Why does a variable of type com.ibm.jms.JMSTextMessage print truncated content and ellipses (…)?

I would like to understand why a variable of type com.ibm.jms.JMSTextMessage is printed with truncated content and ellipses (…) when converted to string.

I have this code in a JSR223 Sampler in JMeter:

import com.ibm.msg.client.jms.JmsConnectionFactory
import com.ibm.msg.client.jms.JmsFactoryFactory
import com.ibm.msg.client.wmq.WMQConstants
import javax.jms.Session
import javax.jms.TextMessage

def hostName = "127.0.0.1"
def hostPort = 1414
def channelName = "DEV.APP.SVRCONN"
def queueManagerName = "QM1"
def queueName = "DEV.QUEUE.1"

def ff = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER)
def cf = ff.createConnectionFactory()

cf.setStringProperty(WMQConstants.WMQ_HOST_NAME, hostName)
cf.setIntProperty(WMQConstants.WMQ_PORT, hostPort)
cf.setStringProperty(WMQConstants.WMQ_CHANNEL, channelName)
cf.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT)

def connInboundQueue = cf.createConnection("user", "password")

def sessInboundQueue = connInboundQueue.createSession(false, Session.AUTO_ACKNOWLEDGE)


def payload = "AAA:+.? 'n" +
        "ABC+ABCD:1+ABCDEFG:ZZ+ABCDEF:ZZ+123456:2042+12345678901++ABCD'n" +
        "DEF+ABCD+LH+FVKJUB+20000:2042+Y1234567+UN+D:21B'n" +
        "GHI+1+ABCD:D:11A:AA:ABCD+ABCD12345678901123ABC123456'n" +
        "JKL+745'n" +
        "HHH+TN:IIAA891011213531235BNM422244:::001'n" +
        "CCC+NT+++ABCDEFGHIJKLMNOPQRS'n" +
        "STU+00123456789012:UF+0000000000:GY'n" +
        "VXY+50+MI1234+++MI'n" +
        "AAA+235+ABC'n" +
        "BBB+200:3202062000:301'n" +
        "FFF+90+USA'n" +
        "BBB+232:2101051135:201'n" +
        "CCC+FF+++AaBaBa001:TEST1'n" +
        "DDD+3++G'n" +
        "EEE+329:711013'n" +
        "FFF+178+XXX'n" +
        "FFF+179+YYY'n" +
        "GGG+2+ZZZ'n" +
        "HHH+BXG:ABCDEF'n" +
        "HHH+ABC:12AB3E01234E8UD8'n" +
        "III+P:110:111+100000001'n" +
        "EEE+36:281105'n" +
        "FFF+91+ASD'n" +
        "VVV+50:2'n" +
        "XXX+0011+1'n" +
        "YYY+1+U0123456'n" +
        "ZZZ+1+U1234560002'n"

TextMessage msg = sessInboundQueue.createTextMessage()
msg.setText(payload)

log.info(msg.toString())
log.info(msg.getClass().toString())
log.info(msg.getText())

I would like to understand why log.info(msg.toString()) does not print the whole text content and show ellipses after some point (...)

If I do log.info(msg.getText()), I can see the whole text message.

Here is the print outcome in jmeter’s console:

2021-10-31 22:05:25,491 INFO o.a.j.p.j.s.J.JSR223 Sampler - Producer - Inbound Queue: 
  JMSMessage class: jms_text
  JMSType:          null
  JMSDeliveryMode:  2
  JMSDeliveryDelay: 0
  JMSDeliveryTime:  1635710725481
  JMSExpiration:    0
  JMSPriority:      4
  JMSMessageID:     ID:414d5120514d312020202020202020201f537d6101c31040
  JMSTimestamp:     1635710725481
  JMSCorrelationID: 1757416553
  JMSDestination:   queue:///DEV.QUEUE.1
  JMSReplyTo:       null
  JMSRedelivered:   false
    JMSXAppID: 4.1binApacheJMeter.jar    
    JMSXDeliveryCount: 0
    JMSXUserID: mquser1     
    JMS_IBM_PutApplType: 28
    JMS_IBM_PutDate: 20211031
    JMS_IBM_PutTime: 20052548
AAA:+.? '
ABC+ABCD:1+ABCDEFG:ZZ+ABCDEF:ZZ+123456:2042+12345678901++ABCD'
DEF+ABCD+LH+FVKJUB+20000:20 ...
2021-10-31 22:05:25,491 INFO o.a.j.p.j.s.J.JSR223 Sampler - Producer - Inbound Queue: class com.ibm.jms.JMSTextMessage
2021-10-31 22:05:25,491 INFO o.a.j.p.j.s.J.JSR223 Sampler - Producer - Inbound Queue: AAA:+.? '
ABC+ABCD:1+ABCDEFG:ZZ+ABCDEF:ZZ+123456:2042+12345678901++ABCD'
DEF+ABCD+LH+FVKJUB+20000:2042+Y1234567+UN+D:21B'
GHI+1+ABCD:D:11A:AA:ABCD+ABCD12345678901123ABC123456'
JKL+745'
HHH+TN:IIAA891011213531235BNM422244:::001'
CCC+NT+++ABCDEFGHIJKLMNOPQRS'
STU+00123456789012:UF+0000000000:GY'
VXY+50+MI1234+++MI'
AAA+235+ABC'
BBB+200:3202062000:301'
FFF+90+USA'
BBB+232:2101051135:201'
CCC+FF+++AaBaBa001:TEST1'
DDD+3++G'
EEE+329:711013'
FFF+178+XXX'
FFF+179+YYY'
GGG+2+ZZZ'
HHH+BXG:ABCDEF'
HHH+ABC:12AB3E01234E8UD8'
III+P:110:111+100000001'
EEE+36:281105'
FFF+91+ASD'
VVV+50:2'
XXX+0011+1'
YYY+1+U0123456'
ZZZ+1+U1234560002'

Advertisement

Answer

According to the IBM documentation com.ibm.jms.JMSTextMessage inherits the toString() implementation from com.ibm.jms.JMSMessage and the JavaDoc for that method says:

Gets a String containing a formatted version of the message header.

My guess is that the body is cut off simply because toString() is really just meant to give you the header. However, only IBM would know for sure why it works that way. To be clear, there is no guarantee that toString() will (or should) return the entire body of the message.

If you really want to inspect the body of the text message you should invoke getText(). This method is required to return the body of the text-message according to the JMS JavaDoc as well as IBM’s own JavaDoc. Both state:

Gets the String containing this message’s data. The default value is null.

Advertisement