MQMD - 消息描述符

MQMD 结构包含在发送和接收应用程序之间传输消息时伴随应用程序数据的控制信息。 此结构是 MQGET , MQPUT 和 MQPUT1 调用上的输入/输出参数。

可用性

所有 IBM® MQ 系统,以及连接到这些系统的 IBM MQ MQI clients

版本

MQMD 的当前版本为 MQMD_VERSION_2。 要在多个环境之间可移植的应用程序必须确保在所有相关环境中支持所需的 MQMD 版本。 仅在结构的最新版本中存在的字段在随后的描述中标识为此类字段。

为受支持的编程语言提供的头 COPY 和 INCLUDE 文件包含环境支持的最新版本的 MQMD ,但 Version 字段的初始值设置为 MQMD_VERSION_1。 要使用 version-1 结构中不存在的字段,应用程序必须将 Version 字段设置为所需版本的版本号。

名称为 MQMD1的 version-1 结构的声明可用。

字符集和编码

MQMD 中的数据必须采用本地队列管理器的字符集和编码; 这些数据由 CodedCharSetId 队列管理器属性和 MQENC_NATIVE 提供。 但是,如果应用程序作为 IBM MQ MQI client运行,那么结构必须采用客户机的字符集和编码。

如果发送和接收队列管理器使用不同的字符集或编码,那么将自动转换 MQMD 中的数据。 应用程序不需要转换 MQMD。

使用不同版本的 MQMD

version-2 MQMD 等同于使用 version-1 MQMD 并以 MQMDE 结构作为消息数据的前缀。 但是,如果 MQMDE 结构中的所有字段都具有其缺省值,那么可以省略 MQMDE。 使用 version-1 MQMD 和 MQMDE ,如下所述:
  • 在 MQPUT 和 MQPUT1 调用上,如果应用程序提供了 version-1 MQMD ,那么应用程序可以选择使用 MQMDE 作为消息数据的前缀,将 MQMD 中的 Format 字段设置为 MQFMT_MD_EXTENSION 以指示存在 MQMDE。 如果应用程序未提供 MQMDE ,那么队列管理器将为 MQMDE 中的字段采用缺省值。
    注: version-2 MQMD 中存在但 version-1 MQMD 不存在的几个字段是 MQPUT 和 MQPUT1 调用上的输入/输出字段。 但是,队列管理器不会在 MQPUT 和 MQPUT1 调用的输出上返回 MQMDE 中等效字段中的任何值; 如果应用程序需要这些输出值,那么它必须使用 version-2 MQMD。
  • 在 MQGET 调用上,如果应用程序提供 version-1 MQMD ,那么队列管理器会将使用 MQMDE 返回的消息作为前缀,但仅当 MQMDE 中的一个或多个字段具有非缺省值时。 MQMD 中的 Format 字段将具有值 MQFMT_MD_EXTENSION ,以指示存在 MQMDE。
队列管理器用于 MQMDE 中的字段的缺省值与这些字段的初始值相同,如 表 2中所示。

当消息位于传输队列上时, MQMD 中的某些字段将设置为特定值; 请参阅 MQXQH-Transmission-queue header 以获取详细信息。

消息上下文

MQMD 中的某些字段包含消息上下文。 有两种类型的消息上下文: 身份上下文源上下文。 具体方式通常为:
  • 身份上下文与 最初 放置消息的应用程序相关
  • 源上下文与 最近 放入消息的应用程序相关。
这两个应用程序可以是同一个应用程序,但也可以是不同的应用程序 (例如,当消息从一个应用程序转发到另一个应用程序时)。

虽然身份和源上下文通常具有描述的含义,但 MQMD 中两种类型的上下文字段的内容都取决于放入消息时指定的 MQPMO_ * _CONTEXT 选项。 因此,身份上下文不一定与最初放置消息的应用程序相关,而源上下文不一定与最近放置消息的应用程序相关; 这取决于应用程序套件的设计。

消息通道代理程序 (MCA) 从不改变消息上下文。 从远程队列管理器接收消息的 MCA 在 MQPUT 或 MQPUT1 调用上使用上下文选项 MQPMO_SET_ALL_CONTEXT。 这允许接收 MCA 保留与来自发送 MCA 的消息一起传递的消息上下文。 但是,结果是源上下文与发送和接收消息的任何 MCA 都不相关。 源上下文是指放置消息的较早应用程序。 如果所有中间应用程序都已传递消息上下文,那么源上下文将引用源应用程序本身。

在描述中,上下文字段被描述为如同先前所描述的那样使用。 有关消息上下文的更多信息,请参阅 消息上下文

字段

注: 在下表中,字段按用法 (而不是按字母顺序) 进行分组。 子主题遵循相同的顺序。
表 1. MQMD 的 MQMD 中的字段
字段名称和描述 常量的名称 常量的初始值 (如果有)
StrucId (结构标识) MQMD_STRUC_ID 'MD'
版本 (结构版本号) MQMD_VERSION_1 1
报告 (报告消息的选项) MQRO_NONE 0
MsgType (消息类型) MQMT_DATAGRAM 8
MQMD-到期字段 (消息生存期) MQEI_UNLIMITED -1
MQMD-反馈字段 (反馈或原因码) MQFB_NONE 0
编码 (消息数据的数字编码) MQENC_NATIVE 取决于环境
CodedCharSetId(报文数据的字符集标识符) MQCCSI_Q_MGR 0
格式 (消息数据的格式名称) MQFMT_NONE 空白
优先级 (消息优先级) MQPRI_PRIORITY_AS_Q_DEF -1
持久性 (消息持久性) MQPER_PERSISTENCE_AS_Q_DEF 2
MQMD- MsgId 字段 (消息标识) MQMI_NONE Null
CorrelId (相关标识) MQCI_NONE Null
BackoutCount (回退计数器) None 0
ReplyToQ(回复队列名称) None 空字符串或空白
ReplyToQMgr(回复队列管理器名称) None 空字符串或空白
UserIdentifier (用户标识) None 空字符串或空白
AccountingToken (记帐令牌) MQACT_NONE Null
ApplIdentityData(与身份有关的应用程序数据) None 空字符串或空白
PutApplType(发送信息的应用程序类型) MQAT_NO_CONTEXT 0
PutApplName(发送信息的应用程序名称) None 空字符串或空白
PutDate (放入消息的日期) None 空字符串或空白
PutTime (放入消息的时间) None 空字符串或空白
ApplOriginData(与原点有关的应用数据) None 空字符串或空白
注: 如果 Version 小于 MQMD_VERSION_2,那么将忽略其余字段。
GroupId (组标识) MQGI_NONE Null
MsgSeqNumber(组内逻辑报文的序列号) None 1
偏移量 (物理消息中的数据与逻辑消息开始的偏移量) None 0
MQMD- MsgFlags 字段 (消息标志) MQMF_NONE 0
OriginalLength (原始消息的长度) MQOL_UNDEFINED -1
备注信息:
  1. 值 Null 字符串或空白表示 C 中的空字符串,而空白字符表示其他编程语言中的空字符。
  2. 在 C 编程语言中,宏变量 MQMD_DEFAULT 包含表中列出的值。 它可以通过以下方式用于为结构中的字段提供初始值:
    MQMD MyMD = {MQMD_DEFAULT};
    

语言声明

MQMD 的 C 声明

typedef struct tagMQMD MQMD;
struct tagMQMD {
  MQCHAR4   StrucId;           /* Structure identifier */
  MQLONG    Version;           /* Structure version number */
  MQLONG    Report;            /* Options for report messages */
  MQLONG    MsgType;           /* Message type */
  MQLONG    Expiry;            /* Message lifetime */
  MQLONG    Feedback;          /* Feedback or reason code */
  MQLONG    Encoding;          /* Numeric encoding of message data */
  MQLONG    CodedCharSetId;    /* Character set identifier of message
                                  data */
  MQCHAR8   Format;            /* Format name of message data */
  MQLONG    Priority;          /* Message priority */
  MQLONG    Persistence;       /* Message persistence */
  MQBYTE24  MsgId;             /* Message identifier */
  MQBYTE24  CorrelId;          /* Correlation identifier */
  MQLONG    BackoutCount;      /* Backout counter */
  MQCHAR48  ReplyToQ;          /* Name of reply queue */
  MQCHAR48  ReplyToQMgr;       /* Name of reply queue manager */
  MQCHAR12  UserIdentifier;    /* User identifier */
  MQBYTE32  AccountingToken;   /* Accounting token */
  MQCHAR32  ApplIdentityData;  /* Application data relating to
                                  identity */
  MQLONG    PutApplType;       /* Type of application that put the
                                  message */
  MQCHAR28  PutApplName;       /* Name of application that put the
                                  message */
  MQCHAR8   PutDate;           /* Date when message was put */
  MQCHAR8   PutTime;           /* Time when message was put */
  MQCHAR4   ApplOriginData;    /* Application data relating to origin */
  MQBYTE24  GroupId;           /* Group identifier */
  MQLONG    MsgSeqNumber;      /* Sequence number of logical message
                                  within group */
  MQLONG    Offset;            /* Offset of data in physical message
                                  from start of logical message */
  MQLONG    MsgFlags;          /* Message flags */
  MQLONG    OriginalLength;    /* Length of original message */
};

MQMD 的 COBOL 声明

**   MQMD structure
  10 MQMD.
**    Structure identifier
   15 MQMD-STRUCID          PIC X(4).
**    Structure version number
   15 MQMD-VERSION          PIC S9(9) BINARY.
**    Options for report messages
   15 MQMD-REPORT           PIC S9(9) BINARY.
**    Message type
   15 MQMD-MSGTYPE          PIC S9(9) BINARY.
**    Message lifetime
   15 MQMD-EXPIRY           PIC S9(9) BINARY.
**    Feedback or reason code
   15 MQMD-FEEDBACK         PIC S9(9) BINARY.
**    Numeric encoding of message data
   15 MQMD-ENCODING         PIC S9(9) BINARY.
**    Character set identifier of message data
   15 MQMD-CODEDCHARSETID   PIC S9(9) BINARY.
**    Format name of message data
   15 MQMD-FORMAT           PIC X(8).
**    Message priority
   15 MQMD-PRIORITY         PIC S9(9) BINARY.
**    Message persistence
   15 MQMD-PERSISTENCE      PIC S9(9) BINARY.
**    Message identifier
   15 MQMD-MSGID            PIC X(24).
**    Correlation identifier
   15 MQMD-CORRELID         PIC X(24).
**    Backout counter
   15 MQMD-BACKOUTCOUNT     PIC S9(9) BINARY.
**    Name of reply queue
   15 MQMD-REPLYTOQ         PIC X(48).
**    Name of reply queue manager
   15 MQMD-REPLYTOQMGR      PIC X(48).
**    User identifier
   15 MQMD-USERIDENTIFIER   PIC X(12).
**    Accounting token
   15 MQMD-ACCOUNTINGTOKEN  PIC X(32).
**    Application data relating to identity
   15 MQMD-APPLIDENTITYDATA PIC X(32).
**    Type of application that put the message
   15 MQMD-PUTAPPLTYPE      PIC S9(9) BINARY.
**    Name of application that put the message
   15 MQMD-PUTAPPLNAME      PIC X(28).
**    Date when message was put
   15 MQMD-PUTDATE          PIC X(8).
**    Time when message was put
   15 MQMD-PUTTIME          PIC X(8).
**    Application data relating to origin
   15 MQMD-APPLORIGINDATA   PIC X(4).
**    Group identifier
   15 MQMD-GROUPID          PIC X(24).
**    Sequence number of logical message within group
   15 MQMD-MSGSEQNUMBER     PIC S9(9) BINARY.
**    Offset of data in physical message from start of logical message
   15 MQMD-OFFSET           PIC S9(9) BINARY.
**    Message flags
   15 MQMD-MSGFLAGS         PIC S9(9) BINARY.
**    Length of original message
   15 MQMD-ORIGINALLENGTH   PIC S9(9) BINARY.

MQMD 的 PL/I 声明

dcl
 1 MQMD based,
  3 StrucId          char(4),       /* Structure identifier */
  3 Version          fixed bin(31), /* Structure version number */
  3 Report           fixed bin(31), /* Options for report messages */
  3 MsgType          fixed bin(31), /* Message type */
  3 Expiry           fixed bin(31), /* Message lifetime */
  3 Feedback         fixed bin(31), /* Feedback or reason code */
  3 Encoding         fixed bin(31), /* Numeric encoding of message
                                       data */
  3 CodedCharSetId   fixed bin(31), /* Character set identifier of
                                       message data */
  3 Format           char(8),       /* Format name of message data */
  3 Priority         fixed bin(31), /* Message priority */
  3 Persistence      fixed bin(31), /* Message persistence */
  3 MsgId            char(24),      /* Message identifier */
  3 CorrelId         char(24),      /* Correlation identifier */
  3 BackoutCount     fixed bin(31), /* Backout counter */
  3 ReplyToQ         char(48),      /* Name of reply queue */
  3 ReplyToQMgr      char(48),      /* Name of reply queue manager */
  3 UserIdentifier   char(12),      /* User identifier */
  3 AccountingToken  char(32),      /* Accounting token */
  3 ApplIdentityData char(32),      /* Application data relating to
                                       identity */
  3 PutApplType      fixed bin(31), /* Type of application that put the
                                       message */
  3 PutApplName      char(28),      /* Name of application that put the
                                       message */
  3 PutDate          char(8),       /* Date when message was put */
  3 PutTime          char(8),       /* Time when message was put */
  3 ApplOriginData   char(4),       /* Application data relating to
                                       origin */
  3 GroupId          char(24),      /* Group identifier */
  3 MsgSeqNumber     fixed bin(31), /* Sequence number of logical
                                       message within group */
  3 Offset           fixed bin(31), /* Offset of data in physical
                                       message from start of logical
                                       message */
  3 MsgFlags         fixed bin(31), /* Message flags */
  3 OriginalLength   fixed bin(31); /* Length of original message */

MQMD 的 High Level Assembler 声明

MQMD                   DSECT
MQMD_STRUCID           DS   CL4   Structure identifier
MQMD_VERSION           DS   F     Structure version number
MQMD_REPORT            DS   F     Options for report messages
MQMD_MSGTYPE           DS   F     Message type
MQMD_EXPIRY            DS   F     Message lifetime
MQMD_FEEDBACK          DS   F     Feedback or reason code
MQMD_ENCODING          DS   F     Numeric encoding of message data
MQMD_CODEDCHARSETID    DS   F     Character set identifier of message
*                                 data
MQMD_FORMAT            DS   CL8   Format name of message data
MQMD_PRIORITY          DS   F     Message priority
MQMD_PERSISTENCE       DS   F     Message persistence
MQMD_MSGID             DS   XL24  Message identifier
MQMD_CORRELID          DS   XL24  Correlation identifier
MQMD_BACKOUTCOUNT      DS   F     Backout counter
MQMD_REPLYTOQ          DS   CL48  Name of reply queue
MQMD_REPLYTOQMGR       DS   CL48  Name of reply queue manager
MQMD_USERIDENTIFIER    DS   CL12  User identifier
MQMD_ACCOUNTINGTOKEN   DS   XL32  Accounting token
MQMD_APPLIDENTITYDATA  DS   CL32  Application data relating to identity
MQMD_PUTAPPLTYPE       DS   F     Type of application that put the
*                                 message
MQMD_PUTAPPLNAME       DS   CL28  Name of application that put the
*                                 message
MQMD_PUTDATE           DS   CL8   Date when message was put
MQMD_PUTTIME           DS   CL8   Time when message was put
MQMD_APPLORIGINDATA    DS   CL4   Application data relating to origin
MQMD_GROUPID           DS   XL24  Group identifier
MQMD_MSGSEQNUMBER      DS   F     Sequence number of logical message
*                                 within group
MQMD_OFFSET            DS   F     Offset of data in physical message
*                                 from start of logical message
MQMD_MSGFLAGS          DS   F     Message flags
MQMD_ORIGINALLENGTH    DS   F     Length of original message
*
MQMD_LENGTH            EQU  *-MQMD
                       ORG  MQMD
MQMD_AREA              DS   CL(MQMD_LENGTH)

MQMD 的 Visual Basic 声明

Type MQMD
  StrucId          As String*4  'Structure identifier'
  Version          As Long      'Structure version number'
  Report           As Long      'Options for report messages'
  MsgType          As Long      'Message type'
  Expiry           As Long      'Message lifetime'
  Feedback         As Long      'Feedback or reason code'
  Encoding         As Long      'Numeric encoding of message data'
  CodedCharSetId   As Long      'Character set identifier of message'
                                'data'
  Format           As String*8  'Format name of message data'
  Priority         As Long      'Message priority'
  Persistence      As Long      'Message persistence'
  MsgId            As MQBYTE24  'Message identifier'
  CorrelId         As MQBYTE24  'Correlation identifier'
  BackoutCount     As Long      'Backout counter'
  ReplyToQ         As String*48 'Name of reply queue'
  ReplyToQMgr      As String*48 'Name of reply queue manager'
  UserIdentifier   As String*12 'User identifier'
  AccountingToken  As MQBYTE32  'Accounting token'
  ApplIdentityData As String*32 'Application data relating to identity'
  PutApplType      As Long      'Type of application that put the'
                                'message'
  PutApplName      As String*28 'Name of application that put the'
                                'message'
  PutDate          As String*8  'Date when message was put'
  PutTime          As String*8  'Time when message was put'
  ApplOriginData   As String*4  'Application data relating to origin'
  GroupId          As MQBYTE24  'Group identifier'
  MsgSeqNumber     As Long      'Sequence number of logical message'
                                'within group'
  Offset           As Long      'Offset of data in physical message'
                                'from start of logical message'
  MsgFlags         As Long      'Message flags'
  OriginalLength   As Long      'Length of original message'
End Type