接收消息isActiveMQTextMessage {commandId = 5,responseRequired = true,messageId = ID:WINMU250046-FMG-60272-1552990958996-1:1:1:1:1,originalDestination = null,originalTransactionId = null,producerId = ID:WINMU250046 -FMG-60272-1552990958996-1:1:1:1,目标= topic:// testt1234,transactionId =空,到期时间= 0,时间戳= 1552990959592,到达= 0,brokerInTime = 1552990959597,brokerOutTime = 1552990959600,correlationId =空,replyTo = null,持久性= true,类型= null,优先级= 4,groupID = null,groupSequence = 0,targetConsumerId = null,压缩= false,userID = null,content = org.apache.activemq.util.ByteSequence@11586f7b ,marshalledProperties = null,dataStructure = null,redeliveryCounter = 0,大小= 0,属性= null,readOnlyProperties = true,readOnlyBody = true,droppable = false,jmsXGroupFirstForConsumer = false,文本=测试发布者}
答案 0 :(得分:0)
通常,您在JMS API中拥有所需的一切:
TextMessage textMessage = (TextMessage) message;
String yourText = textMessage.getText();
但是,如果要在字符串级别提取文本,则只需使用String.lastIndexOf()
和String.substring()
方法:
String yourText = msg.substring(msg.lastIndexOf("text = ") + 7, msg.length() - 1);
希望我能帮上忙。