|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
question about MQPUT1 |
« View previous topic :: View next topic » |
Author |
Message
|
adder |
Posted: Mon Apr 10, 2006 1:12 pm Post subject: question about MQPUT1 |
|
|
Apprentice
Joined: 06 Dec 2005 Posts: 43
|
I encounter some problem when using MQPUT1, following code is changed based on amqsput0.c, only drop MQOPEN and MQCLOSE, but when I run this application, I got 2155 error
output is like: please give me some suggestion
./mqput1 pingq ITQM
Sample AMQSPUT0 start
target queue is pingq
jdfd
MQPUT ended with reason code 2155
Sample AMQSPUT0 end
Code: |
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* includes for MQI */
#include <cmqc.h>
int main(int argc, char **argv)
{
/* Declare file and character for sample input */
FILE *fp;
/* Declare MQI structures needed */
MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */
MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
MQPMO pmo = {MQPMO_DEFAULT}; /* put message options */
/** note, sample uses defaults where it can **/
MQHCONN Hcon; /* connection handle */
MQHOBJ Hobj; /* object handle */
MQLONG O_options; /* MQOPEN options */
MQLONG C_options; /* MQCLOSE options */
MQLONG CompCode; /* completion code */
MQLONG OpenCode; /* MQOPEN completion code */
MQLONG Reason; /* reason code */
MQLONG CReason; /* reason code for MQCONN */
MQLONG messlen; /* message length */
char buffer[100]; /* message buffer */
char QMName[50]; /* queue manager name */
printf("Sample AMQSPUT0 start\n");
if (argc < 2)
{
printf("Required parameter missing - queue name\n");
exit(99);
}
QMName[0] = 0; /* default */
if (argc > 2)
strcpy(QMName, argv[2]);
MQCONN(QMName, /* queue manager */
&Hcon, /* connection handle */
&CompCode, /* completion code */
&CReason); /* reason code */
/* report reason and stop if it failed */
if (CompCode == MQCC_FAILED)
{
printf("MQCONN ended with reason code %d\n", CReason);
exit( (int)CReason );
}
strncpy(od.ObjectName, argv[1], (size_t)MQ_Q_NAME_LENGTH);
printf("target queue is %s\n", od.ObjectName);
O_options = MQOO_OUTPUT /* open queue for output */
| MQOO_FAIL_IF_QUIESCING /* but not if MQM stopping */
; /* = 0x2010 = 8208 decimal */
CompCode = OpenCode; /* use MQOPEN result for initial test */
fp = stdin;
memcpy(md.Format, /* character string format */
MQFMT_STRING, (size_t)MQ_FORMAT_LENGTH);
while (CompCode != MQCC_FAILED)
{
if (fgets(buffer, sizeof(buffer), fp) != NULL)
{
messlen = (MQLONG)strlen(buffer); /* length without null */
if (buffer[messlen-1] == '\n') /* last char is a new-line */
{
buffer[messlen-1] = '\0'; /* replace new-line with null */
--messlen; /* reduce buffer length */
}
}
else messlen = 0; /* treat EOF same as null line */
/****************************************************************/
/* */
/* Put each buffer to the message queue */
/* */
/****************************************************************/
if (messlen > 0)
{
/**************************************************************/
/* The following two statements are not required if the */
/* MQPMO_NEW_MSG_ID and MQPMO_NEW _CORREL_ID options are used */
/**************************************************************/
memcpy(md.MsgId, /* reset MsgId to get a new one */
MQMI_NONE, sizeof(md.MsgId) );
memcpy(md.CorrelId, /* reset CorrelId to get a new one */
MQCI_NONE, sizeof(md.CorrelId) );
MQPUT1(Hcon, /* connection handle */
&Hobj, /* object handle */
&md, /* message descriptor */
&pmo, /* default options (datagram) */
messlen, /* message length */
buffer, /* message buffer */
&CompCode, /* completion code */
&Reason); /* reason code */
/* report reason, if any */
if (Reason != MQRC_NONE)
{
printf("MQPUT ended with reason code %d\n", Reason);
}
}
else /* satisfy end condition when empty line is read */
CompCode = MQCC_FAILED;
}
MQDISC(&Hcon, /* connection handle */
&CompCode, /* completion code */
&Reason); /* reason code */
/* report reason, if any */
if (Reason != MQRC_NONE)
{
printf("MQDISC ended with reason code %d\n", Reason);
}
printf("Sample AMQSPUT0 end\n");
return(0);
}
|
|
|
Back to top |
|
 |
mvic |
Posted: Mon Apr 10, 2006 1:37 pm Post subject: Re: question about MQPUT1 |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
|
Back to top |
|
 |
adder |
Posted: Mon Apr 10, 2006 3:05 pm Post subject: |
|
|
Apprentice
Joined: 06 Dec 2005 Posts: 43
|
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|