本文介紹了為什么com.ibm.jms.JMSTextMessage類型的變量打印截斷的內容和省略號(.)?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我想了解為什么輸出com.ibm.jms.JMSTextMessage類型的變量時帶有截斷的內容和省略號(.)轉換為字符串時。
我在JMeter的JSR223采樣器中有此代碼:
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:+.? '
" +
"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'
"
TextMessage msg = sessInboundQueue.createTextMessage()
msg.setText(payload)
log.info(msg.toString())
log.info(msg.getClass().toString())
log.info(msg.getText())
我想了解一下為什么log.info(msg.toString())
不打印整個文本內容,而在一些point (...)
后面顯示省略號
如果我這樣做log.info(msg.getText())
,我可以看到整個文本消息。
以下是jeter控制臺中的打印結果:
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.1inApacheJMeter.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'
推薦答案
根據IBM documentationcom.ibm.jms.JMSTextMessage
從com.ibm.jms.JMSMessage
繼承toString()
實現,the JavaDoc for that method表示:
獲取包含郵件頭的格式化版本的字符串。
我的猜測是,主體被截斷只是因為toString()
實際上只是為了給您提供標題。然而,只有IBM才會確切地知道它為什么會這樣工作。需要說明的是,不能保證toString()
將(或應該)返回整個郵件正文。
如果您確實希望檢查文本消息的正文,則應該調用getText()
。根據the JMS JavaDoc和IBM’s own JavaDoc返回文本消息正文需要使用此方法。兩種狀態:
獲取包含此消息數據的字符串。默認值為NULL。
這篇關于為什么com.ibm.jms.JMSTextMessage類型的變量打印截斷的內容和省略號(.)?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,