|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Messages arriving in DLQ |
« View previous topic :: View next topic » |
Author |
Message
|
santuna |
Posted: Wed Aug 02, 2006 1:47 am Post subject: Messages arriving in DLQ |
|
|
Novice
Joined: 15 Apr 2005 Posts: 12 Location: Hambach FRANCE
|
Hello,
I've got a triggered local queue receiving messages from an application.
When messages arrived they are readed by the trigger monitor who write them in a file on the hard disk.
The process worked correctly but sometimes the messages are sended in the DLQ instead of been written in the file and the type of the messages became MQTRIG.
I would be pleased if someone could explain me what happened.
Stef |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 02, 2006 1:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Some clarifiation if you'd be so good; do you actually mean that the trigger monitor is dealing with these messages or is it the more normal situation where you have the trigger monitor launching a 2nd application to deal with these messages?
Also, what does the DLH reason code say about these messages? _________________ Honesty is the best policy.
Insanity is the best defence.
Last edited by Vitor on Wed Aug 02, 2006 2:06 am; edited 1 time in total |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Aug 02, 2006 2:06 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
If you're seeing MQTRIG messages on the DLQ, it is because the triggered application failed to start for some reason.
Or at least because the trigger monitor thought the application failed to start.
Most likely your process started but then abended, and the trigger monitor is seeing that as a failure to start.
This is one of the reasons it's a good idea to have your process definitions run "in the background" from the trigger monitor - using the & on Unix or 'start' on windows. Then the trigger monitor always gets a good return code from the program starting up. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
santuna |
Posted: Wed Aug 02, 2006 5:00 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 12 Location: Hambach FRANCE
|
hello,
here a screenshot about the contents of a incorrect message in the Dead Letter queue.
If you have an idea. Thanks bye.
Stephane.
------------------------------------------------------------------------------------
[ 364 bytes] Message Descriptor (MQMD)
StrucId :'MD '
Version :2
Report :0
Message Type :8
Expiry :-1
Feedback :0
MQEncoding :0x'222'
CCSID :850
Format :'MQDEAD '
Priority :0
Persistence :0 (Not Persistent)
Message Id :A M Q E H 0 2 0 0 4 1 D . | . . R .
414D512045483032303034312020202044A27C12200B52CA
Correl. Id :. . . . . . . . . . . . . . . . . . . . . . . .
000000000000000000000000000000000000000000000000
Backout Cnt. :0
ReplyToQ :' '
ReplyToQMgr :'EH020041 '
UserId :' '
AccountingTkn:. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
0000000000000000000000000000000000000000000000000000000000000000
ApplIndentity:' '
PutApplType :7
PutApplName :'EH020041 '
Put Date :'20060802'
Put Time :'12295526'
ApplOriginDat:' '
Group Id :. . . . . . . . . . . . . . . . . . . . . . . .
000000000000000000000000000000000000000000000000
Msg Seq No. :1
Offset :0
MsgFlags :0
Original Len.:-1
ApplOriginDat:' '
Group Id :. . . . . . . . . . . . . . . . . . . . . . . .
000000000000000000000000000000000000000000000000
Msg Seq No. :1
Offset :0
MsgFlags :0
Original Len.:-1
+00000000 444C4820 01000000 09010000 4548302E 4D52532E 312E4D52 532E494E 49545120 DLH ........EH0.MRS.1.MRS.INITQ
+00000020 20202020 20202020 20202020 20202020 20202020 20202020 20202020 45483032 EH02
+00000040 30303431 20202020 20202020 20202020 20202020 20202020 20202020 20202020 0041
+00000060 20202020 20202020 20202020 22020000 52030000 4D515452 49472020 06000000 "...R...MQTRIG ....
+00000080 52554E4D 5154524D 00000000 00000000 00000000 00000000 00000000 32303036 RUNMQTRM....................2006
+000000A0 30383032 31323330 32393638 544D2020 01000000 4548302E 4D52532E 312E504C 080212302968TM ....EH0.MRS.1.PL
+000000C0 55532E4D 52532E30 31202020 20202020 20202020 20202020 20202020 20202020 US.MRS.01
+000000E0 20202020 4548302E 4D52532E 312E504C 55532E4D 52532E30 31202020 20202020 EH0.MRS.1.PLUS.MRS.01
+00000100 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+00000120 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+00000140 20202020 20202020 20202020 20202020 20202020 06000000 2F766172 2F6D716D ..../var/mqm
+00000160 2F696E74 2F707267 2F6D7162 71746F66 6C5F7064 72202020 20202020 20202020 /int/prg/mqbqtofl_pdr
+00000180 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+000001A0 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+000001C0 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+000001E0 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+00000200 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+00000220 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+00000240 20202020 20202020 20202020 20202020 20202020 20202020 2D6D4548 30323030 -mEH0200
+00000260 3431202D 71454830 2E4D5253 2E312E50 4C55532E 4D52532E 30312020 20202020 41 -qEH0.MRS.1.PLUS.MRS.01
+00000280 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+000002A0 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+000002C0 20202020 20202020 20202020 20202020 20202020 20202020 50524F43 4553535F PROCESS_
+000002E0 50445220 20202020 20202020 20202020 20202020 20202020 20202020 20202020 PDR
+00000300 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+00000320 20202020 20202020 20202020 20202020 20202020 20202020 20202020 20202020
+00000340 20202020 20202020 20202020 20202020 20202020 20202020
----------------------------------------------------------------------------------- |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Aug 02, 2006 5:09 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
jefflowrey wrote: |
If you're seeing MQTRIG messages on the DLQ, it is because the triggered application failed to start for some reason.
Or at least because the trigger monitor thought the application failed to start. |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 02, 2006 5:09 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Again I ask if you're running the standard trigger monitor or if you are (as you intimated) using a trigger monitor to process the application messages?
Can you also please post details of your platform and the language your application is written in?
Also, (as jefflowrey correctly points out) if there are any application errors being thrown? From however many programs you have? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
santuna |
Posted: Wed Aug 02, 2006 5:22 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 12 Location: Hambach FRANCE
|
Vitor wrote: |
Again I ask if you're running the standard trigger monitor or if you are (as you intimated) using a trigger monitor to process the application messages?
|
I am running a standard trigger monitor process which calls a modified "mqbqtofl" program from IBM
Vitor wrote: |
Can you also please post details of your platform and the language your application is written in?
|
The platform is HP-UX 11.11 and the application is written in C |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 02, 2006 5:27 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
santuna wrote: |
I am running a standard trigger monitor process which calls a modified "mqbqtofl" program from IBM
|
Modified how? I am increasingly behind jefflowrey in thinking there's an application fault. Is there any other evidence of failure? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
santuna |
Posted: Wed Aug 02, 2006 5:28 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 12 Location: Hambach FRANCE
|
Moreover here is the content of the modified "mqbqtofl" process:
/***************************************************************************/
/* */
/* (c) Copyright IBM Corp. 2004 All rights reserved. */
/* */
/***************************************************************************/
/* */
/* Program name: mqbqtofl.c */
/* */
/***************************************************************************/
/* */
/* Description: Sample C program that reads messages in a group */
/* from a message queue using MQGET and writes it to a file */
/* */
/***************************************************************************/
/* */
/* Function: The program copies a binary file of a max. size of 150 MByte */
/* to a queue. The max. Msg Length in MQ is set to 100 MByte, */
/* we use the feature of msg gouping and sequencing to cut the */
/* orignial file in several msgs and put it together again on */
/* receiving side */
/* */
/***************************************************************************/
/* */
/* call parameters */
/* -m queue manager name (optional) */
/* default is default qmgr */
/* -q queue name (required) */
/* -f path of output file (optional) */
/* default is same directory as application is called from */
/* -v verbose level (optional) */
/* - 0 -> only errors (default) */
/* - 1 -> info level */
/* - 2 -> function trace level */
/* - 3 -> value trace level */
/* -w wait time for another msg in milli seconds */
/* default is 15000 msecs */
/* */
/***************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdarg.h>
#include <cmqc.h>
#include <sys/types.h>
#include <sys/stat.h>
#define MQ_MODE_ASCII 1L
#define MQ_MODE_BIN 0L
/******************************************************************/
/* global variables */
/******************************************************************/
MQHCONN hCon = MQHC_DEF_HCONN; /* connection handle */
MQHOBJ hObj = MQHO_UNUSABLE_HOBJ ; /* object handle */
int outputLevel = 0; /* verbose level */
char logfilename[150];
char filename[25];
MQBYTE24 groupId;
MQLONG waitTime;
MQLONG matchOpts;
MQLONG msgFlag;
MQLONG modeString = MQ_MODE_BIN; /*0 = MQFMT_STRING , 1 = ...*/
char * version = "1.02";
/******************************************************************/
/* function proto types */
/******************************************************************/
int _mqconn(MQCHAR48 qm);
int _mqopen(MQCHAR48 q);
int _mqput();
int _mqclose();
int _mqdisc();
int _mqcmit();
int _mqback();
void LogMsg(int level, char *format, ...);
long getnumb( char * const ptr );
/******************************************************************/
/* functions */
/******************************************************************/
/*----------------------------------------------------------------*/
/* function: _mqconn */
/*----------------------------------------------------------------*/
/* connecting to an mq queue manager */
/*----------------------------------------------------------------*/
/* parameter */
/* - qm - queue manager name */
/* - hCon - connection handle */
/*----------------------------------------------------------------*/
int _mqconn(MQCHAR48 qm)
{
MQLONG cc = MQCC_OK;
MQLONG rc = MQRC_NONE;
LogMsg(2, "--> function _mqconn entered \n");
MQCONN(qm, &hCon, &cc, &rc);
/* report reason and stop if it failed */
if (cc == MQCC_FAILED) {
LogMsg(0,"MQCONN ended with reason code %ld\n", rc);
exit( (int)rc );
}
LogMsg(2, "--> function _mqconn left \n");
return rc;
}
/*----------------------------------------------------------------*/
/* function: _mqopen */
/*----------------------------------------------------------------*/
/* open a queue for putting msgs to */
/*----------------------------------------------------------------*/
int _mqopen(MQCHAR * q)
{
MQOD od = {MQOD_DEFAULT}; /* Object Descriptor */
MQLONG cc = MQCC_OK;
MQLONG rc = MQRC_NONE;
int openOpts = 0;
LogMsg(2, "--> function _mqopen entered \n");
strncpy(od.ObjectName, q, (size_t)MQ_Q_NAME_LENGTH);
LogMsg(3,"target queue is %s\n", od.ObjectName);
/******************************************************************/
/* Open the source message queue for input */
/******************************************************************/
openOpts = MQOO_INPUT_SHARED /* open queue for input */
+ MQOO_FAIL_IF_QUIESCING; /* but not if MQM stopping */
MQOPEN(hCon, &od, openOpts, &hObj, &cc, &rc);
/* report reason, if any; stop if failed */
if (rc != MQRC_NONE) {
LogMsg(0, "MQOPEN ended with reason code %ld\n", rc);
LogMsg(0, "unable to open queue <%s> \n", q);
}
LogMsg(2, "--> function _mqopen left \n");
return rc;
}
/*----------------------------------------------------------------*/
/* function: _mqput */
/*----------------------------------------------------------------*/
/* puts a mqs to a queue */
/*----------------------------------------------------------------*/
int _mqget(char * buffer, /* msg buffer */
long buflen , /* length of msg buffer */
MQLONG * msglen
)
{
MQLONG cc = MQCC_OK;
MQLONG rc = MQRC_NONE;
MQMD md = {MQMD_DEFAULT}; /* Message Descriptor */
MQGMO gmo = {MQGMO_DEFAULT}; /* put message options */
LogMsg(2, "--> function _mqget entered \n");
/* reset MsgId and CorrelId to get new ones */
memcpy(md.MsgId, MQMI_NONE, sizeof(md.MsgId) );
memcpy(md.CorrelId, MQCI_NONE, sizeof(md.CorrelId) );
memcpy(md.GroupId, groupId, sizeof(md.GroupId));
/* Message groups require a Version 2 MD. */
md.Version = MQMD_VERSION_2;
gmo.MatchOptions = matchOpts;
/*********************************************************/
/* Message groups require a Version 2 PMO. In addition, */
/* put the entire group in syncpoint. */
/*********************************************************/
gmo.Version = MQGMO_VERSION_2;
gmo.Options = MQGMO_LOGICAL_ORDER
+ MQGMO_SYNCPOINT /* syncpoint control */
+ MQGMO_FAIL_IF_QUIESCING /* fail if qmgr quiesce */
+ MQGMO_WAIT /* wait for new messages */
;
if (modeString == MQ_MODE_ASCII)
gmo.Options = gmo.Options + MQGMO_CONVERT; /* messages will be converted if possible */
gmo.WaitInterval = waitTime; /* limit for waiting in milli seconds */
MQGET(hCon, hObj, &md, &gmo, buflen, buffer, &(*msglen), &cc, &rc);
if (rc == MQRC_NONE) {
memcpy(groupId, md.GroupId, sizeof(md.GroupId));
msgFlag = md.MsgFlags;
LogMsg(3, " msg seq <%d> MsgFlags <%08x> size<%4d> <%.50s>\n",
md.MsgSeqNumber, md.MsgFlags, *msglen, buffer);
memcpy(filename, md.CorrelId, sizeof(md.CorrelId) );
}
if (strncmp(md.Format, MQFMT_STRING, strlen(MQFMT_STRING) == 0 )) {
LogMsg(3, "Message Format is STRING\n");
modeString = MQ_MODE_ASCII;
}
if ( (rc != MQRC_TRUNCATED_MSG_FAILED)
&& (rc != MQRC_NONE)
&& (rc != MQRC_NO_MSG_AVAILABLE)
)
{
LogMsg(0, "mqget error %d \n",rc);
}
LogMsg(2, "--> function _mqget left \n");
return rc;
}
/*----------------------------------------------------------------*/
/* function: _mqclose */
/*----------------------------------------------------------------*/
/* closes a queue */
/*----------------------------------------------------------------*/
int _mqclose() {
MQLONG cc = MQCC_OK;
MQLONG rc = MQRC_NONE;
MQLONG C_options; /* MQCLOSE options */
LogMsg(2, "--> function _mqclose entered \n");
C_options = 0; /* no close options */
MQCLOSE(hCon, &hObj, C_options, &cc, &rc);
/* report reason, if any */
if (rc != MQRC_NONE) {
LogMsg(0, "MQCLOSE ended with reason code %ld\n", rc);
}
LogMsg(2, "--> function _mqclose left\n");
return rc;
}
/*----------------------------------------------------------------*/
/* function: _mqdisc */
/*----------------------------------------------------------------*/
/* disconnects from a mq queue manager */
/*----------------------------------------------------------------*/
int _mqdisc( )
{
MQLONG cc = MQCC_OK;
MQLONG rc = MQRC_NONE;
LogMsg(2, "--> function _mqdisc entered \n");
MQDISC(&hCon, &cc, &rc);
/* report reason, if any */
if (rc != MQRC_NONE) {
LogMsg(0, "MQDISC ended with reason code %ld\n", rc);
}
LogMsg(2, "--> function _mqdisc left \n");
return rc;
}
/*----------------------------------------------------------------*/
/* function: _mqcmit */
/*----------------------------------------------------------------*/
/* commits the queue manager connection */
/*----------------------------------------------------------------*/
int _mqcmit()
{
MQLONG cc = MQCC_OK;
MQLONG rc = MQRC_NONE;
LogMsg(2, "--> function _mqcmit entered \n");
MQCMIT(hCon, &cc, &rc);
if (rc != MQRC_NONE) {
LogMsg(0,"MQCMIT ended with reason code %ld\n", rc);
}
LogMsg(2, "--> function _mqcmit left \n");
return rc;
}
/*----------------------------------------------------------------*/
/* function: _mqback */
/*----------------------------------------------------------------*/
/* rolls the queue manager connection back */
/*----------------------------------------------------------------*/
int _mqback()
{
MQLONG cc = MQCC_OK;
MQLONG rc = MQRC_NONE;
LogMsg(2, "--> function _mqback entered \n");
MQBACK(hCon, &cc, &rc);
if (rc != MQRC_NONE) {
LogMsg(0,"MQBACK ended with reason code %ld\n", rc);
}
LogMsg(2, "--> function _mqback left \n");
return rc;
}
/*----------------------------------------------------------------*/
/* function: getNumb */
/*----------------------------------------------------------------*/
/* reads number as char pointer and returns the long value */
/*----------------------------------------------------------------*/
long getnumb( char * const ptr )
{
long numb = 0 ;
char * p = 0 ;
char c = ' ' ;
for ( p = ptr ; *p != '\0' ; p++ )
{
c = *p ;
if ( c == ' ' ) break ;
if ( ( c >= '0' ) && ( c <= '9' ) )
numb = ( numb * 10 ) + ( c - '0' ) ;
}
return ( numb ) ;
}
/*----------------------------------------------------------------*/
/* function: getParms */
/*----------------------------------------------------------------*/
/* reads the parameters and sets them */
/*----------------------------------------------------------------*/
void getParms ( int const argc ,
char ** const argv ,
char * qm ,
char * q ,
long * maxMsgSize
)
{
int i = 0 ;
char * p = 0 ;
char c = ' ' ;
char s = ' ' ;
char v = ' ' ;
MQTMC2 *trig; /* Trigger header MQTMC2 */
/* set default values if no one is entered */
strcpy(qm, " ");
strcpy(q , "TEST");
//strcpy(path, "");
strcpy(logfilename, "mqbfltoq.log");
outputLevel = 0;
*maxMsgSize = 1;
waitTime = 15000;
for ( i=1 ; i < argc ; i++ ) /* loop through all the parms */
{
/* ignore trigger msg */
trig = (MQTMC2*)argv[i]; /* -> trigger message */
if (!strncmp(trig->StrucId,MQTMC_STRUC_ID,4))
i++;
p = argv??(i??) ; /* start of current parm */
c = *p ; /* should be the selector, so ignore it */
s = *(++p) ; /* the parm key */
p++ ; /* start of parm data */
v = *p ; /* first of the parm data */
switch ( s )
{
case 'M' : /* Queue Manager - source */
case 'm' :
strncpy(qm,p,MQ_Q_MGR_NAME_LENGTH) ;
qm[strlen(p)] = '\0';
break ;
case 'Q' : /* Queue - source */
case 'q' :
strncpy(q,p,MQ_Q_NAME_LENGTH) ;
q[strlen(p)] = '\0';
break ;
case 'v' : /* Message output - verbose */
case 'V' :
outputLevel = getnumb(p);
break ;
/** case 'f' : // file path
case 'F' :
strncpy(path,p, strlen(p)) ;
path[strlen(p)] = '\0';
break ;
**/
case 'l' : /* log file name with path*/
case 'L' :
strncpy(logfilename,p, strlen(p)) ;
logfilename[strlen(p)] = '\0';
break ;
case 'w' : /* wait time */
case 'W' :
waitTime = getnumb(p);
break ;
default :
break ; /* unknown parm, so ignore it*/
} ;
} ;
return ;
}
/*----------------------------------------------------------------*/
/* Function: LogMsg */
/*----------------------------------------------------------------*/
/* write protocol information */
/*----------------------------------------------------------------*/
void LogMsg(int level, char *format, ...)
{
FILE *log_file = NULL; /* error messages go to a log file */
va_list args;
struct tm *tm;
time_t tv;
char levelchar[5];
char path[100];
/* only if the ouptut level is set or an error */
if ((outputLevel > 0) || (level == 0))
{
if (level > 0) {
if ((outputLevel < 2) && (level >= 2))
return;
if ((outputLevel < 3) && (level >= 3))
return;
}
/* define output text for different levels */
/* level text */
/* --------------------------------------- */
/* 0 ERROR */
/* 1 INFO */
/* 2 TRACE */
/* 3 PARSE */
if (level == 0)
strcpy(levelchar, "ERROR");
else
if (level == 1)
strcpy(levelchar, "INFO ");
else
if (level == 2)
strcpy(levelchar, "TRACE");
else
if (level == 3)
strcpy(levelchar, "PARSE");
if (log_file == NULL) {
strcpy(path, logfilename);
log_file = fopen( path, "a");
}
if ( log_file == NULL) {
printf("cannot open log file\n");
return; /* can't open so can't print */
}
time( &tv);
tm = localtime( &tv);
fprintf(log_file,"%04d/%02d/%02d %02d:%02d:%02d %.5s : ",
(tm->tm_year + 1900), (tm->tm_mon + 1), tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, lev
elchar);
va_start( args, format);
vfprintf( log_file, format, args);
printf("%04d/%02d/%02d %02d:%02d:%02d %.5s : ",
(tm->tm_year + 1900), (tm->tm_mon + 1), tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, levelchar);
vprintf( format, args);
va_end( args);
fflush( log_file);
fclose(log_file);
log_file=NULL;
}
}
/*----------------------------------------------------------------*/
/* Function: openFile */
/*----------------------------------------------------------------*/
/* write protocol information */
/*----------------------------------------------------------------*/
int openFile(FILE ** hOutFile, /* filehandle */
char * path, /* file name to open */
long * fileSize) /* return how many bytes read from file */
{
/** char zwstr[150]; **/
LogMsg(2, "--> function openFile entered \n");
/** strcpy(zwstr, path);
strcat(zwstr, filename); **/
/*delete old file if it exists */
/** if( (*hOutFile = fopen( zwstr, "wb" )) == NULL ) { **/
if( (*hOutFile = fopen( path, "wb" )) == NULL ) {
/** LogMsg(0, "Outputfile <%s> could not be open\n", zwstr); **/
LogMsg(0, "Outputfile <%s> could not be open\n", path);
exit(99);
}
LogMsg(2, "--> function openFile left \n");
return (0);
}
/*----------------------------------------------------------------*/
/* Function: readFile */
/*----------------------------------------------------------------*/
/* write protocol information */
/*----------------------------------------------------------------*/
int writeFile(FILE * hOutFile, /* filehandle */
char * buffer, /* pointer to buffer with the data */
int blockSize, /* how many bytes should be written */
MQLONG * noOfBytesWritten /* starting at which position */
)
{
int cursorPos=0;
int rc = 0;
LogMsg(2, "--> function writeFile entered \n");
*noOfBytesWritten = fwrite(buffer, 1, blockSize, hOutFile);
cursorPos = ftell(hOutFile);
if (ferror(hOutFile))
rc = ferror(hOutFile);
LogMsg(2, "--> function writeFile left \n");
return(rc);
}
/*----------------------------------------------------------------*/
/* function: main */
/*----------------------------------------------------------------*/
/* main function */
/*----------------------------------------------------------------*/
int main(int argc, char **argv)
{
FILE * hOutFile = NULL; /* input file handle */
MQLONG rc = MQRC_NONE; /* reason code */
MQLONG orc = MQRC_NONE; /* reason code for MQOPEN */
MQLONG crc = MQRC_NONE; /* reason code for MQCONN */
MQLONG rrc = MQRC_NONE; /* reason code for read file */
MQLONG mrc = MQRC_NONE; /* reason code for MQPUT */
MQLONG cc = MQCC_OK; /* completion code */
MQLONG cc4g = MQCC_OK; /* completion code for groups */
char * buffer = NULL; /* message buffer */
MQLONG bufferLen = 0; /* message buffer length */
MQLONG msglen;
char QMName[MQ_Q_MGR_NAME_LENGTH + 1]; /* queue manager name */
char QName[MQ_Q_NAME_LENGTH + 1]; /* queue manager name */
char path[150];
int prio = MQPRI_PRIORITY_AS_Q_DEF; /* message priority */
long fileSize = 0;
long maxMsgSize = 0;
int counter = 0;
long msgCounter = 0;
struct tm *tm;
time_t tv;
char date_stamp[9];
struct stat *stat_buffer;
struct tm *gmtime_stat_buffer, *gmtime_now_buffer;
struct timeval *timeval_now_buffer;
struct timezone *timezone_now_buffer;
FILE *ficdaynum;
char lu[7];
char newval[7];
int jour_fic;
/*at least the queue name and the filename have to be entered */
if (argc < 2) {
printf("program started version %s \n", version);
printf( "Required parameter missing :\n");
printf( " -m queue manager name (optional)\n");
printf( " default is default qmgr \n");
printf( " -q queue name (required) \n");
printf( " -f path of output file (optional) \n");
printf( " default is same directory as application is called from \n");
printf( " -v verbose level (optional) \n");
printf( " - 0 -> only errors (default) \n");
printf( " - 1 -> info level \n");
printf( " - 2 -> function trace level \n");
printf( " - 3 -> value trace level \n");
printf( " -w wait time for another msg in milli seconds \n");
printf( " default is 15000 msecs \n");
exit(99);
}
/* read the input parameters */
getParms(argc, argv, QMName, QName, &maxMsgSize);
// Gestion du No incremental :
// on recup la date de MODIF du fichier :
stat_buffer=(struct stat *)malloc(sizeof(struct stat));
if (stat ("/interface/data/plus_pdr/daynum",stat_buffer)!=0)
{
LogMsg (0,"Stat command failed on /interface/data/plus_pdr/daynum\n");
exit(4);
}
gmtime_stat_buffer=(struct tm *)malloc(sizeof(struct tm));
gmtime_stat_buffer=gmtime(&stat_buffer->st_mtime);
jour_fic=gmtime_stat_buffer->tm_mday;
// On recup les infos de la date du jour :
timeval_now_buffer=(struct timeval *)malloc(sizeof(struct timeval));
timezone_now_buffer=(struct timezone *)malloc(sizeof(struct timezone));
gettimeofday(timeval_now_buffer,timezone_now_buffer);
gmtime_now_buffer=gmtime(&timeval_now_buffer->tv_sec);
// On compare date du jour a date de modification du fichier :
if (jour_fic != gmtime_now_buffer->tm_mday)
{
// on recree le fichier, avec 000000 dedans :
ficdaynum=fopen("/interface/data/plus_pdr/daynum","w");
fprintf(ficdaynum,"000000");
fclose(ficdaynum);
strcpy(newval,"000000");
}
else
{
// on incremente de 1 le contenu :
ficdaynum=fopen("/interface/data/plus_pdr/daynum","r");
fscanf(ficdaynum,"%s",lu);
sprintf(newval,"%06d",atoi(lu)+1);
fclose(ficdaynum);
ficdaynum=fopen("/interface/data/plus_pdr/daynum","w");
fseek(ficdaynum,0,SEEK_SET);
fputs(newval,ficdaynum);
//fprintf(ficdaynum,"%s",newval);
fclose(ficdaynum);
}
// Je rempli la variable path:
time( &tv);
tm = localtime( &tv);
strcpy(path,"/interface/data/plus_pdr/pdr_");
sprintf(date_stamp,"%d%02d%02d",tm->tm_year+1900,tm->tm_mon,tm->tm_mday);
strcat(path,date_stamp);
strcat(path,"_");
strcat(path,newval);
path[44]=0;
/* let's begin */
LogMsg(1, "program started version %s \n", version);
/* Connect to queue manager */
crc =_mqconn(QMName);
/* Open the target message queue for output */
if (crc == MQRC_NONE)
orc = _mqopen(QName);
/******************************************************************/
/* */
/* Read from the file and put them to the message queue */
/* Loop until end of file, or there is a failure */
/* */
/* Note: If you are usign file redirection as input, the file */
/* MUST have two blank lines at the end of it. */
/* */
/******************************************************************/
if (orc == MQRC_NONE)
{
msgCounter = 0;
msglen = maxMsgSize;
/*alloc memory for the buffer*/
buffer = malloc( maxMsgSize );
if( buffer == NULL ) {
LogMsg(0, "Insufficient memory available\n" );
exit(13) ;
}
while ((mrc == MQRC_NONE) && (rrc == 0) )
{
/*set on the first call the */
if ( msgCounter == 0 ) {
memcpy(groupId, MQGI_NONE, sizeof(MQGI_NONE));
matchOpts = MQMO_NONE;
}
else {
matchOpts = MQMO_MATCH_GROUP_ID;
}
bufferLen = msglen;
mrc = _mqget(buffer, bufferLen, &msglen);
if (mrc == MQRC_NONE) {
/*open file before open mq connection*/
if ( msgCounter == 0 ) {
openFile(&hOutFile, path, &fileSize);
}
rrc = writeFile(hOutFile, buffer, msglen, &bufferLen);
}
/* change buffer size if neccessary */
if (mrc == MQRC_TRUNCATED_MSG_FAILED) {
free(buffer);
buffer = malloc(msglen + 1);
if( buffer == NULL ) {
LogMsg(0, "Insufficient memory available\n" );
exit(13);
}
mrc = MQRC_NONE;
} else {
msgCounter = msgCounter + 1;
if (msgCounter == 1 )
LogMsg(1, "-->GroupID <%-24.24s>\n", groupId);
}
/* is it the last msg for this file ? */
if ((msgFlag == (MQMF_LAST_MSG_IN_GROUP + MQMF_MSG_IN_GROUP) )
&& (mrc == MQRC_NONE)){
_mqcmit();
fclose(hOutFile);
msgCounter = 0;
modeString = MQ_MODE_BIN;
}
}
free( buffer );
if (hOutFile != NULL)
fclose(hOutFile);
}
//if ((mrc == MQRC_NONE) && (rrc == 0))
if ((mrc == MQRC_NO_MSG_AVAILABLE) && (rrc == 0))
_mqcmit() ;
else
_mqback() ;
/* Close the target queue (if it was opened) */
if (orc != MQCC_FAILED) {
rc = _mqclose();
}
/* Disconnect from QM if not already connected */
if (crc!= MQRC_ALREADY_CONNECTED) {
rc = _mqdisc();
/* report reason, if any */
if (rc != MQRC_NONE) {
LogMsg(0, "MQDISC ended with reason code %ld\n", rc);
}
}
/* END OF PROGRAM */
LogMsg(1, "program mqbfltoq end\n");
return(0);
} |
|
Back to top |
|
 |
santuna |
Posted: Wed Aug 02, 2006 5:31 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 12 Location: Hambach FRANCE
|
Vitor wrote: |
santuna wrote: |
I am running a standard trigger monitor process which calls a modified "mqbqtofl" program from IBM
|
Modified how? I am increasingly behind jefflowrey in thinking there's an application fault. Is there any other evidence of failure? |
Sorry but I'm not a C specialist and that wasn't me that has modified this process. I can't tell us what is modified.
But perhaps when takin a look in the code someone could help me finding an error or something wrong.
Thanks
Stef |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 02, 2006 5:37 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
At first glance it seems the program will perform exit and write to the log if some conditions are met, like the output file not opening or there being "Insufficent memory". What are you getting in the log (and if there's no log file that too could be the problem! )? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Aug 02, 2006 5:48 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Can we see your process definition? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
santuna |
Posted: Wed Aug 02, 2006 6:28 am Post subject: |
|
|
Novice
Joined: 15 Apr 2005 Posts: 12 Location: Hambach FRANCE
|
Hello,
i have no errors messages in the Log file from that Queue Manager, also no errors Messages under /var/mqm/errors.
So here my Process definition :
application type : Unix
application : /var/mqm/int/prg/mqbqtofl_pdr
environment data : -mEH020041 -qEH0.MRS.1.PLUS.MRS.01
Process data : PROCESS_PDR
Thanks , bye
Stef. |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Aug 02, 2006 6:33 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Add "&" to the end of your environment data.
Your problem should go away. _________________ I am *not* the model of the modern major general. |
|
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
|
|
|
|