|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Listener problem (Message exit) |
« View previous topic :: View next topic » |
Author |
Message
|
Carla Viragh |
Posted: Wed Nov 19, 2003 12:00 pm Post subject: Listener problem (Message exit) |
|
|
 Voyager
Joined: 31 Oct 2003 Posts: 92 Location: São Paulo - Brasil
|
Hi all...
I have a listener problem in my production environment for a long time. IBM from england asked me to send trace all, and the answer is a message exit problem. Probably, the exit is in trouble, receiver stops and listener goes down.
All receivers and senders use a exit called MSGMON, it´s supplied by IBM (SupportPac MA06) but this suffered some modifications, as you can see below. After removing the exit from my channels, the listener is up full time! (bingo)
The question is: Does anybody know if this exit could cause a problem? If Yes, what can I do to use this exit again? I don´t know how to program this... But if someone could help me, I would be glad.
Is there other exit sample provided by IBM that does the same thing?
Thanks in advance
/*---------------------------------------------------------------------------*/
/* */
/* Filename: MSGMON.C */
/* */
/* Description: */
/* This is a sample message exit function record all messages */
/* transmitted through a channel defined in MQSeries. */
/* A companion utility program called PUTMSGQ can be used to */
/* read the messages in the log file and writes them to a queue.*/
/* This function will work on any channels, e.g. send, receive, */
/* requester,etc. */
/* */
/* Please read the user documentation on how to set up this */
/* channel exit function under MQSeries. */
/* */
/* This function is used as Channel Message Exit Function under */
/* MQSeries. You must create this function as a library */
/* function under UNIX, or a DLL under NT for it to be */
/* functional. Please see user document for details on how to */
/* specify the Channel Message Exit function within MQSeries. */
/* This function opens an INI file, which can be specified in */
/* Channel Message Exit Data in the channel definition, see */
/* user document. This function uses CHANNEL.INI under \tmp */
/* directory as default if no INI is specified in Channel */
/* Message Exit Data. The key values the function looks for in */
/* the INI file are Channel Log Filename and Message Buffer */
/* filename, please see CHANNEL.INI for setup. This function */
/* logs all channel activities into the Channel Log file. */
/* Messages passing through the channel will be written into */
/* the Message Buffer file. */
/* */
/* Statement: Licensed Materials - Property of IBM */
/* Copyright IBM Corp. 1997 */
/* All rights reserved. */
/* */
/* U.S. Government Users Restricted Rights -*/
/* use, duplication or disclosure restricted*/
/* by GSA ADP Schedule Contract with IBM */
/* Corp. */
/* */
/* Modification History: */
/* Date Who Version Description of change */
/* ---------- --------------- --------- ------------------------- */
/* 03/20/1997 Chak Pang 1.0 changed "[" to "??(" and "]" */
/* to "??)". Also added comments */
/* suggested by Jeff Hooper and */
/* Harry Halliwell from Hursley, */
/* U.K. */
/* */
/* 04/03/1997 Chak Pang 1.0 Tidied up comments. */
/* */
/* 04/28/1997 Chak Pang 1.1 Changed "fopen( INI_FILENAME" */
/* to "fopen( fn" in getINI() */
/* So it won't open the default */
/* INI file everytime. */
/* Authors: Tom McCann */
/* IBM Global Services */
/* Cincinnati, Ohio, USA */
/* Phone: 513-762-2060 */
/* */
/* Chak Pang */
/* IBM Global Services */
/* Columbus, Ohio, USA */
/* Phone: 614-225-3663 */
/* */
/* Dependencies: channel.h */
/* */
/* Restrictions: The INI filename must be less than 128 characters */
/* */
/* Disclaimer: this program has been tested under AIX and NT to the */
/* authors' satisfaction. You may use this program at your own */
/* risk. IBM and the authors are not responsible for any */
/* unexpected results generated by this program. */
/* */
/*---------------------------------------------------------------------------*/
/* standard headers */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <locale.h>
#ifdef AIX
#include <langinfo.h>
#endif
#include <sys/types.h>
#include <sys/timeb.h>
#include <time.h>
/* MQSeries headers */
#include <cmqc.h>
#include <cmqxc.h>
#include "channel.h"
char timebuf??(130??);
char Channel_Logfile??(129??);
char MsgBufFile??(129??);
char ini_filename??(129??);
FILE * OST = 0;
/* define output file and statement prototype */
#define DBGPRINTF(x) { \
OST=fopen(Channel_Logfile,"a+"); \
if(OST) fprintf x; \
fclose(OST); \
}
void writer (long *, char *); /* prototype for file writer function */
void getINI( void );
/* dummy function used as entry point to exit, only needed for AIX boxes */
void MQENTRY MQStart(void) {;}
void MQENTRY MsgExit( PMQCXP pChannelExitParams,
PMQCD pChannelDefinition,
PMQLONG pDataLength,
PMQLONG pAgentBufferLength,
PMQBYTE AgentBuffer,
PMQLONG pExitBufferLength,
PMQPTR pExitBufferAddr)
{
short i;
struct timeb t;
char millisec??(25??);
/*** Get time string to use in all messages ***/
time_t clock = time( (time_t*) NULL);
struct tm *tmptr = localtime(&clock);
strcpy(timebuf, asctime(tmptr));
ftime( &t );
memset( millisec, 0, sizeof( millisec ) );
sprintf( millisec, " Time:%ld.%d", t.time, t.millitm );
strcat( timebuf, millisec );
if ( strlen(pChannelExitParams->ExitData) )
{
memset( ini_filename, 0, sizeof( ini_filename ) );
/* strncpy( ini_filename, pChannelExitParams->ExitData, MQ_EXIT_DATA_LENGTH ); */
/* This lines were included to substitute the line: */
/* strncpy( ini_filename, pChannelExitParams->ExitData, MQ_EXIT_DATA_LENGTH ); */
if(pChannelDefinition->ChannelType == MQCHT_SENDER)
strncpy( ini_filename, getenv("MQEXITDIRSND"), MQ_EXIT_DATA_LENGTH );
if(pChannelDefinition->ChannelType == MQCHT_RECEIVER)
strncpy( ini_filename, getenv("MQEXITDIRRCVR"), MQ_EXIT_DATA_LENGTH );
/* end */
/*------------------------*/
/* remove space from data */
/*------------------------*/
for ( i = MQ_EXIT_DATA_LENGTH - 1; i > 0; i-- )
{
if ( ini_filename??(i??) != ' ' && ini_filename??(i??) )
break;
ini_filename??(i??) = 0;
}
}
getINI();
/*** Check call type - initialization, message, or exit ***/
/* */
switch( pChannelExitParams-> ExitReason )
{
case MQXR_INIT:
DBGPRINTF((OST,"\nChannel message exit called at MCA initialization %s",timebuf));
break;
case MQXR_MSG:
/*** Call subroutine to write record to output file ***/
/* */
writer (pDataLength, (char *)AgentBuffer);
DBGPRINTF((OST,"\nMessage written, length = %li %s \n",*pDataLength, timebuf));
break;
case MQXR_TERM:
DBGPRINTF((OST, "\nMessage channel exit called at MCA termination %s\n",timebuf));
break;
default:
DBGPRINTF((OST,"\nMessage channel exit called with invalid reason code: %d %s", pChannelExitParams-> ExitReason, timebuf));
break;
} /* switch */
/*** Set exit response = OK in all circumstances ***/
pChannelExitParams -> ExitResponse = MQXCC_OK;
return;
}/* end exit */
/*------------------------------------------------------------------
write() - writes a MQSeries message to a log file.
-------------------------------------------------------------------*/
void writer(long *lngth, char *bf)
{
long msgsize;
int n;
FILE *fp;
getINI();
fp = fopen(MsgBufFile, "ab");
if (fp == NULL)
{
printf("Error opening <%s> to write message. Error #: %d", MsgBufFile, errno );
return;
}
msgsize = *lngth;
n = fwrite(&msgsize, sizeof(msgsize), 1, fp); /* put record length */
n = fwrite(bf, msgsize, 1, fp); /* and message buffer */
fclose(fp);
} /* end writer */
/*---------------------------------------------------------
getINI() - read information from INI file
-----------------------------------------------------------*/
void getINI( void )
{
FILE *ini_fp;
char *ptr, *name_ptr;
char field_val??(129??), Ini_s??(129??), fn??(129??);
short len;
memset( Ini_s, 0, sizeof( Ini_s ) );
memset( field_val, 0, sizeof( field_val ) );
memset( MsgBufFile, 0, sizeof ( MsgBufFile ) );
memset( Channel_Logfile, 0, sizeof( Channel_Logfile ) );
if ( strlen( ini_filename ) ) /* if Channel Exit defined INI filename */
strcpy( fn, ini_filename ); /* use it */
else /* otherwise use default INI filename */
strcpy( fn, INI_FILENAME );
if ( (ini_fp = fopen( fn, "r" )) == NULL )
{
fprintf(stderr, "\nUnable to open %s. Error #: %d", fn, errno );
return;
}
/*-----------------------------*/
/* read the INI file until eof */
/*-----------------------------*/
while ( (ptr = fgets( Ini_s, sizeof(Ini_s) - 1, ini_fp )) != NULL )
{
len = strlen( Ini_s );
if ( Ini_s??(len -1??) == LINEFEED )
Ini_s??(len-1??) = 0; /* null out '\n' */
if ( (name_ptr = strchr( Ini_s, EQUAL )) == NULL ) /* no '=' found */
continue;
ptr = name_ptr + 1;
*name_ptr = 0; /* set null for s[] */
strcpy( field_val, ptr );
/*---------------------------------------------------*/
/* remove comments and unwanted characters from data */
/*---------------------------------------------------*/
while ( *ptr )
{
if ( *ptr == ' ' ) /* stop at first space */
{
*ptr = 0;
break;
}
ptr++;
}
if ( !strcmp( MESSAGE_BUFFER_FILE, Ini_s ) ) /* look for message buffer filename */
{
strcpy( MsgBufFile, field_val );
}
else
{
if ( !strcmp( CHANNEL_LOGFILE, Ini_s ) )
{
strcpy( Channel_Logfile, field_val );
}
}
memset( Ini_s, 0, sizeof( Ini_s ) );
memset( field_val, 0, sizeof( field_val ) );
}
fclose( ini_fp );
return;
} _________________ Carla Viragh |
|
Back to top |
|
 |
LuisFer |
Posted: Wed Nov 19, 2003 12:45 pm Post subject: Re: Listener problem (Message exit) |
|
|
 Partisan
Joined: 17 Aug 2002 Posts: 302
|
Be carefull with the use of the MSGMON exit .the performance of the channels is affected.
In our test Env. with the original Exit we send/receive no more than 5 or 6 Msg's (12k max) by second betwen an z/OS <==> NSK. Without exit send/receive over 75 msgs/sec.(the exit in the two sides) |
|
Back to top |
|
 |
Carla Viragh |
Posted: Wed Nov 19, 2003 12:51 pm Post subject: |
|
|
 Voyager
Joined: 31 Oct 2003 Posts: 92 Location: São Paulo - Brasil
|
Do you have any suggestions Luiz? I don´t need to use this exit, but I need to log the messages anyway!
Thanks _________________ Carla Viragh |
|
Back to top |
|
 |
LuisFer |
Posted: Wed Nov 19, 2003 1:03 pm Post subject: |
|
|
 Partisan
Joined: 17 Aug 2002 Posts: 302
|
An idea is to make all the Messages as Persistent. The persistent msgs are logged by MQSeries. In the z/OS/ (by example) the messages are logged & the log archived every an interval time. In this case should can retrieved for other objects (i'm not sure but i think that it should can it).
I don't know , in detall, how works the logging in other platfoms. |
|
Back to top |
|
 |
LuisFer |
Posted: Wed Nov 19, 2003 1:09 pm Post subject: |
|
|
 Partisan
Joined: 17 Aug 2002 Posts: 302
|
I suppose that write a Channel Msg Exit that change all the Msg to change persistents should be less expensive.(i will probe it) |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Nov 19, 2003 1:45 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
If you want to mark all messages as persistent, I'd look into using the API exits. However, depending on what you are doing now, all persistent messages could be a performance hit.
I would think that you could fix the msgmon exit so that it did what you wanted it to do rather than just quit using it? |
|
Back to top |
|
 |
Carla Viragh |
Posted: Thu Nov 20, 2003 5:31 am Post subject: |
|
|
 Voyager
Joined: 31 Oct 2003 Posts: 92 Location: São Paulo - Brasil
|
My messages are all persistents and my log is linear but that´s for MQ administrators only
This exit msgmon saves a file on disk and laypeople read the file if necessary. I need a way to create this file to them, no matters if it´s done by a exit or whatever...
Someone knows what could help me? Or how to fix the msgmon? Why is msgmon bringing the receiver/listener down? _________________ Carla Viragh |
|
Back to top |
|
 |
Carla Viragh |
Posted: Fri Nov 21, 2003 4:58 am Post subject: |
|
|
 Voyager
Joined: 31 Oct 2003 Posts: 92 Location: São Paulo - Brasil
|
People, I discovered that this exit was working fine until the date we changed the AdoptMCA parameters! Is it coincidence or this exit fails if these parameters are checked? IBM says to be careful using exits with this parameters checked. Do you know something about it? Why do we need to be careful to use exits with AdoptMCA? _________________ Carla Viragh |
|
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
|
|
|
|