0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 #include <string.h>
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037 #include <memory.h>
0038 #include <sys/param.h>
0039 #include <errno.h>
0040
0041 #include <ndrstandard.h>
0042 #include <ndebug.h>
0043 #include <nstdutil.h>
0044
0045 #include <ndrxdcmn.h>
0046 #include <atmi_int.h>
0047 #include <gencall.h>
0048 #include <utlist.h>
0049 #include <Exfields.h>
0050
0051 #include "xa_cmn.h"
0052 #include <ndrx.h>
0053 #include <qcommon.h>
0054 #include <nclopt.h>
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070 expublic int cmd_mqdm(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0071 {
0072 int ret = EXSUCCEED;
0073 short srvid;
0074 short nodeid;
0075 char msgid_str[TMMSGIDLEN_STR+1];
0076 char msgid[TMMSGIDLEN+1];
0077 char *buf = NULL;
0078 UBFH *p_ub = NULL;
0079 UBFH *p_ub2 = NULL;
0080 TPQCTL qc;
0081 long len = 1;
0082 char typ[64];
0083 long blen;
0084 ncloptmap_t clopt[] =
0085 {
0086 {'n', BFLD_SHORT, (char *)&nodeid, 0,
0087 NCLOPT_MAND|NCLOPT_HAVE_VALUE, "Q cluster node id"},
0088 {'i', BFLD_SHORT, (char *)&srvid, 0,
0089 NCLOPT_MAND|NCLOPT_HAVE_VALUE, "Q Server Id"},
0090 {'m', BFLD_STRING, msgid_str, sizeof(msgid_str),
0091 NCLOPT_MAND|NCLOPT_HAVE_VALUE, "Message id"},
0092 {0}
0093 };
0094
0095
0096 if (nstd_parse_clopt(clopt, EXTRUE, argc, argv, EXFALSE))
0097 {
0098 fprintf(stderr, XADMIN_INVALID_OPTIONS_MSG);
0099 EXFAIL_OUT(ret);
0100 }
0101
0102
0103 memset(&qc, 0, sizeof(qc));
0104
0105 tmq_msgid_deserialize(msgid_str, msgid);
0106
0107 qc.flags|= TPQPEEK;
0108 qc.flags|= TPQGETBYMSGID;
0109
0110 memcpy(qc.msgid, msgid, TMMSGIDLEN);
0111
0112 buf = tpalloc("STRING", "", 1);
0113
0114 if (EXSUCCEED!=tpdequeueex(nodeid, srvid, "*N/A*", &qc, (char **)&buf, &len, 0))
0115 {
0116 fprintf(stderr, "failed %s diag: %ld:%s",
0117 tpstrerror(tperrno), qc.diagnostic, qc.diagmsg);
0118 EXFAIL_OUT(ret);
0119 }
0120
0121 if (NULL==(p_ub = (UBFH *)tpalloc("UBF", "", 1024)))
0122 {
0123 NDRX_LOG(log_error, "Failed to alloc: %s", strerror(errno));
0124 EXFAIL_OUT(ret);
0125 }
0126
0127 if (EXSUCCEED!=tmq_tpqctl_to_ubf_deqrsp(p_ub, &qc))
0128 {
0129 NDRX_LOG(log_error, "Failed to build tpqctl struct ubf");
0130 EXFAIL_OUT(ret);
0131 }
0132
0133 printf("*************** TPQCTL ***************\n");
0134
0135 Bprint(p_ub);
0136
0137 printf("*************** MESSAGE **************\n");
0138
0139
0140
0141 if (EXFAIL==(blen=tptypes(buf, typ, NULL)))
0142 {
0143 NDRX_LOG(log_error, "Failed to detect buffer type");
0144 EXFAIL_OUT(ret);
0145 }
0146
0147 printf("* Buffer type = %s\n", typ);
0148
0149 if (0==strcmp(typ, "UBF"))
0150 {
0151 Bprint((UBFH *)buf);
0152 }
0153 else
0154 {
0155
0156 STDOUT_DUMP(log_info, "Binary message contents", buf, len);
0157 }
0158
0159 out:
0160 if (NULL!=p_ub)
0161 {
0162 tpfree((char *)p_ub);
0163 }
0164
0165 if (NULL!=buf)
0166 {
0167 tpfree(buf);
0168 }
0169
0170 return ret;
0171 }
0172
0173