要在消息流中的任何一点上查看逻辑消息树的结构,请包含 Trace 节点并将一些或全部消息(包括头和所有四个消息树)写至跟踪输出目标。
您可能会发现,在节点更改消息内容前后或在输入节点接收消息时检查并记录消息的内容很有用。例如,如果包含在 LocalEnvironment 中构建目标列表的 Compute 节点,您可能想得到它已经创建为部分审计跟踪的结构的记录,或可能只希望检查 Compute 节点是否正如您期望的那样运行。
假定您已经配置了一个消息流,在 MQInput 节点中的 WebSphere MQ 队列上接收 XML 消息。输入消息包括 MQRFH2 头。下面显示了该消息的内容:
<Trade type='buy' Company='IBM' Price='200.20' Date='2000-01-01' Quantity='1000'/>
您可以包含并配置 Trace 节点来生成输出,显示从此消息创建的一个或多个树:消息体树,Environment 树、LocalEnvironment 树和 Exception 树。如果您选择记录消息体的内容,则会包括 Properties 树和所有头的内容(在本例中,至少包括 MQMD 和 MQRFH2)。设置 Trace 节点属性模式时,指定您要记录的内容。您可以使用大多数相关名来定义此模式(不能使用特定于 Compute 节点的那些名称)。
将模式设置为 $Root 时,为上面所显示消息的消息树生成的跟踪输出将类似于:
Root Properties CreationTime=GMTTIMESTAMP '1999-11-24 13:10:00' (a GMT timestamp field) ... and other fields ... MQMD PutDate=DATE '19991124' (a date field) PutTime=GMTTIME '131000' (a GMTTIME field) ... and other fields ... MQRFH mcd msd='xml' (a character string field) .. and other fields ... XML Trade type='buy' (a character string field) Company='IBM' (a character string field) Price='200' (a character string field) Date='2000-01-01' (a character string field) Quantity='1000' (a character string field)
(0x1000000)Environment = ( (0x1000000)Variables = ( (0x1000000)MyVariable1 = ( (0x2000000) = '3' ) (0x1000000)MyVariable2 = ( (0x2000000) = 'Hello' ) ) )
要跟踪 Environment 树的变量文件夹中的特定变量,可以使用更具体的模式,例如 ${Environment.Variables.MyVariable1}。这将只返回值(例如,只返回值 3)。
(0x1000000)Destination = ( (0x1000000)MQ = ( (0x1000000)DestinationData = ( (0x3000000)queuename = 'MQOUT' ) ) (0x1000000)MQDestinationList = ( (0x1000000)DestinationData = ( (0x3000000)queuename = 'OLDMQOUT' ) ) (0x1000000)RouterList = ( (0x1000000)DestinationData = ( (0x3000000)labelname = 'continue' ) (0x1000000)DestinationData = ( (0x3000000)labelname = 'custdetails' ) (0x1000000)DestinationData = ( (0x3000000)labelname = 'trade' ) ) )
下面显示的另一个示例包含了 WrittenDestination 文件夹。此示例显示了包含在 MQOutput 节点后的 Trace 节点写入的跟踪信息,其中 MQOutput 节点的 out 终端连接到一系列节点,包括 Trace 节点。当连接了 out 终端时,LocalEnvironment 中会增加输出节点已经执行的操作的相关信息。
(0x1000000)Destination = ( (0x1000000)MQ = ( (0x1000000)DestinationData = ( (0x3000000)queuename = 'MQOUT' ) ) (0x1000000)WrittenDestination = ( (0x1000000)MQ = ( (0x1000000)DestinationData = ( (0x3000000)queueName = 'MQOUT' (0x3000000)queueManagerName = 'MQSI_SAMPLE_QM' (0x3000000)replyIdentfier = X'414d51204d5153495f53414d504c455f1f442f3b12600100' (0x3000000)msgId = X'414d51204d5153495f53414d504c455f1f442f3b12600100' (0x3000000)correlId = X'000000000000000000000000000000000000000000000000' ) ) ) )
使用流调试器时,您还可以查看消息流中的消息结构和其他信息。