顯示具有 MQ 標籤的文章。 顯示所有文章
顯示具有 MQ 標籤的文章。 顯示所有文章

星期四, 11月 09, 2023

2017-11-21 Check Message Queue Manager started or not


Check Message Queue Manager started or not

File  : QCLSRC
Member: CHKMQM
Type  : CLLE
Usage : CrtCLMod   Module( ChkMqm )
        CrtPgm Pgm( ChkMqm ) BndSrvPgm((QMQM/LIBMQM))
        




/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Program . . : CHKMQM                                             */
/*  Description : Check MQM Status                                   */
/*  Author  . . : Vengoal Chang                                      */
/*  Published . : AS400ePaper                                        */
/*  Date  . . . : November 21, 2017                                  */
/*                                                                   */
/*  Program function:  CHKMQM   command processing program           */
/*                                                                   */
/*                                                                   */
/*  Programmer's notes:                                              */
/*                                                                   */
/*  Compile options:                                                 */
/*    CrtCLMod   Module( ChkMqm )                                    */
/*    CrtPgm Pgm( ChkMqm )                                           */
/*           BndSrvPgm((QMQM/LIBMQM))                                */
/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Exceptions monitored :                                           */
/*       MQCONN         MQRC_Q_MGR_STOPPING                          */
/*                      MQRC_Q_MGR_QUIESCING                         */
/*                      MQRC_Q_MGR_NOT_AVAILABLE                     */
/*                      MQRC_STORAGE_NOT_AVAILABLE                   */
/*                                                                   */
/*-------------------------------------------------------------------*/
     Pgm      ( &MQMName &RCChar)

     Dcl        &MQMName      *CHAR    48
     Dcl        &RCChar      *Char    10

     /* Define local variables                      */
     Dcl        &HCONN       *CHAR     4   X'00000000'
     Dcl        &CCODE       *CHAR     4   X'00000000'
     Dcl        &REASON      *CHAR     4   X'00000000'
     Dcl        &NOTAVAIL    *CHAR     4   X'0000080B'
     Dcl        &STOPPING    *CHAR     4   X'00000872'
     Dcl        &QUIESCING   *CHAR     4   X'00000871'
     Dcl        &NOSTORAGE   *CHAR     4   X'00000817'
     Dcl        &UNKNOWN     *CHAR     4   X'0000080A'

     Dcl        &MsgDta      *Char   256
     Dcl        &Rc          *Dec   (10 0)


/*-- Global error monitoring:  --------------------------------------*/
     MonMsg    (CPF0000 MCH3601)     *N        GoTo Error

     AddLibLe  QMQM
     MonMsg    CPF0000

     /******************************************************/
     /* Connect to queue manager                           */
     /******************************************************/
     CallPrc 'MQCONN' (&MQMName &Hconn &Ccode &Reason)
     If     (%bin(&Ccode) *ne 0) Do
          /*************************************************/
          /* MQCONN failed                                 */
          /*************************************************/
          ChgVar   &Rc     %Bin(&Reason)
          ChgVar   &RcChar &Rc
          Select
          When (&Reason = &STOPPING)  Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'stopping, RC =' *bcat &RcChar)
          EndDo

          When (&Reason = &NOTAVAIL)  Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'not available, RC =' *bcat &RcChar)
          EndDo
          When (&Reason = &QUIESCING) Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'quiescing, RC =' *bcat &RcChar)
          EndDo
          When (&Reason = &NOSTORAGE) Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'nostorage, RC =' *bcat &RcChar)
          EndDo
          When (&Reason = &UNKNOWN)   Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'unknown, RC =' *bcat &RcChar)
          EndDo
          Otherwise  Do
            ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                            'conn error, RC =' *bcat &RcChar)
          EndDo
          EndSelect

          SndPgmMsg  MsgId(CPF9898) MsgF(QCPFMSG) +
                     MsgDta(&MsgDta) ToPgmQ(*Ext) MsgType(*Info)
          Goto         Return
     ENDDO

     ChgVar &MsgDta ('Qmgr' *bcat &MQMName *Bcat +
                     'started')
     SndPgmMsg  MsgId(CPF9898) MsgF(QCPFMSG) +
                MsgDta(&MsgDta) ToPgmQ(*EXT) MsgType(*INFO)

     /******************************************************/
     /* MQCONN worked so disonnect                         */
     /******************************************************/
     CallPrc 'MQDISC' (&Hconn &Ccode &Reason)

 Return:
     Return

/*-- Error handling:  -----------------------------------------------*/
 Error:
     Call      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             x'00000001'                             +
                             '*PGMBDY'                               +
                             x'00000001'                             +
                             x'0000000800000000'                     +
                           )

     Call      QMHRSNEM    ( '    '                                  +
                             x'0000000800000000'                     +
                           )

 EndPgm:
     EndPgm



File  : QCMDSRC
Member: CHKMQM
Type  : CMD
Usage : CrtCmd      Cmd( CHKMQM  )	
                    Pgm( CHKMQM   )
                    SrcFile( QCMDSRC )	
                    Allow( *IPGM *BPGM )					

       


/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Compile options:                                                 */
/*                                                                   */
/*    CrtCmd Cmd( CHKMQM )                                           */
/*           Pgm( CHKMQM )                                           */
/*           SrcMbr( CHKMQM )                                        */
/*           Allow( *IPGM *BPGM )                                    */
/*                                                                   */
/*-------------------------------------------------------------------*/
          Cmd      Prompt( 'Check MQ Queue Manager')

          Parm     Kwd(MQMNAME) Type(*CHAR) Len(48) Min(1) +
                   Prompt('Message Queue Manager name')

          Parm     Kwd(RC) Type(*CHAR) Len(10)  +
                   RtnVal(*Yes)                 +
                   Prompt('Return code')


						
File  : QCLSRC
Member: CHKMQMTSTC
Type  : CLP 
Usage : CRTCLPGM CHKMQMTSTC

PGM
     DCL &MQMNAME        *CHAR     48
     DCL &RC             *CHAR     10


/*-- Global error monitoring:  --------------------------------------*/
     MonMsg     CPF0000      *N        GoTo Error

     CHGVAR     &MQMNAME              'TEST'
     CHKMQM     MQMNAME(&MQMNAME) RC(&RC)
     If        (&RC *NE ' ') Do
               DmpClPgm
       /* MQM got Exception */
       /* do exception process */
     EndDo

     CHGVAR     &MQMNAME              'TEST1'
     CHKMQM     MQMNAME(&MQMNAME) RC(&RC)
     If        (&RC *NE ' ') Do
               DmpClPgm
       /* MQM got Exception */
       /* do exception process */
     EndDo

 Return:
     RCLACTGRP  ACTGRP(*ELIGIBLE)
     Return

/*-- Error handling:  -----------------------------------------------*/
 Error:
     RCLACTGRP  ACTGRP(*ELIGIBLE)

     Call      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             x'00000001'                             +
                             '*PGMBDY'                               +
                             x'00000001'                             +
                             x'0000000800000000'                     +
                           )

     Call      QMHRSNEM    ( '    '                                  +
                             x'0000000800000000'                     +
                           )

 EndPgm:
     EndPgm



2016-10-04 Check MQ Job by APPLTYPE USER or SYSTEM(CHKMQJOB) with StrMqmMqsc command output


Check MQ Job by APPLTYPE USER or SYSTEM(CHKMQJOB) with StrMqmMqsc command output

File  : QCLSRC
Member: CHKMQJOBC
Type  : CLP
Usage : CRTCLPGM PGM(CHKMQJOBC)		
        




/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Program . . : CHKMQJOB                                           */
/*  Description : Check MQ User Job                                  */
/*  Author  . . : Vengoal Chang                                      */
/*  Published . : AS400ePaper                                        */
/*  Date  . . . : July 25, 2016                                      */
/*                                                                   */
/*  Program function:  CHKMQJOB command processing program           */
/*                                                                   */
/*                                                                   */
/*  Programmer's notes:                                              */
/*    CRTSRCPF FILE(QGPL/MQSRC) TEXT('MQ CMD SRC')                   */
/*    Put following line to file QGPL/MQSRC menber CHKMQJOB          */
/*    DISPLAY CONN(*) TYPE(CONN) APPLTAG APPLTYPE                    */
/*                                                                   */
/*  Compile options:                                                 */
/*    CrtClPgm   Pgm( CHKMQJOB )                                     */
/*               SrcFile( QCLSRC )                                   */
/*               SrcMbr( *PGM )                                      */
/*                                                                   */
/*-------------------------------------------------------------------*/
     Pgm      ( &Qmgr                  +
                &ApplType              +
                &JobAction             +
              )

/*-- Parameters:  ---------------------------------------------------*/
     Dcl        &Qmgr        *Char    48
     Dcl        &ApplType    *Char    10
     Dcl        &JobAction   *Char    10
     Dcl        &MqSrcFile   *Char    10    'MQSRC'
     Dcl        &MqSrcLib    *Char    10    'QGPL'
     Dcl        &MqSrcMbr    *Char    10    'CHKMQJOB'

/*-- Global error monitoring:  --------------------------------------*/
     MonMsg     CPF0000      *N        GoTo Error

     DltF       File(Qtemp/MqJobLst)
     MonMsg     CPF2105

     CrtPf      File(Qtemp/MqJobLst) RcdLen(133) IgcDta(*Yes)

     StrMqmMqsc SrcMbr(&MqSrcMbr) SrcFile(&MqSrcLib/&MqSrcFile) +
                          MqmName(&Qmgr)

     CpySplf    File(QsysPrt) ToFile(Qtemp/MqJobLst) SplNbr(*Last)

     Call       ChkMqJobR (&Qmgr &ApplType &JobAction)
     MonMsg     CPF9898

     DltSplF    File(QsysPrt) SplNbr(*Last)

 Return:
     Return

/*-- Error handling:  -----------------------------------------------*/
 Error:
     Call      QMHMOVPM    ( '    '                                  +
                             '*DIAG'                                 +
                             x'00000001'                             +
                             '*PGMBDY'                               +
                             x'00000001'                             +
                             x'0000000800000000'                     +
                           )

     Call      QMHRSNEM    ( '    '                                  +
                             x'0000000800000000'                     +
                           )

 EndPgm:
     EndPgm



File  : QRPGLESRC
Member: CHKMQJOBR
Type  : RPGLE
Usage : CRTBNDRPG PGM(CHKMQJOBR)		

       


     H DEBUG  OPTION(*SRCSTMT:*NODEBUGIO) dftactgrp(*NO)

     FMQJOBLST  IF   F  133        DISK

     **-- API error information:
     D ERRC0100        Ds                  Qualified
     D  BytPro                       10i 0 Inz( %Size( ERRC0100 ))
     D  BytAvl                       10i 0
     D  MsgId                         7a
     D                                1a
     D  MsgDta                      256a
     **-- Global variables:
     D MsgKey          s              4a

     **-- Send program message:
     D SndPgmMsg       Pr                  ExtPgm( 'QMHSNDPM' )
     D  SpMsgId                       7a   Const
     D  SpMsgFq                      20a   Const
     D  SpMsgDta                    128a   Const
     D  SpMsgDtaLen                  10i 0 Const
     D  SpMsgTyp                     10a   Const
     D  SpCalStkE                    10a   Const  Options( *VarSize )
     D  SpCalStkCtr                  10i 0 Const
     D  SpMsgKey                      4a
     D  SpError                   32767a          Options( *VarSize )

     **-- Send completion message:
     D SndCmpMsg       Pr            10i 0
     D  PxMsgDta                    512a   Const  Varying
     **-- Send escape message:
     D SndEscMsg       Pr            10i 0
     D  PxMsgDta                    512a   Const  Varying

     D ParseInput      PR

     D GetAtrValue     PR           512    Varying
     D  inputStr                    512    Const Varying
     D  atrName                      64    Const Varying

     **-- Execute command:
     D RunCmd          Pr                  ExtPgm( 'QCMDEXC' )
     D  CmdStr                     4096a   Const  Options( *VarSize )
     D  CmdLen                       15p 5 Const
     D  CmdIGC                        3a   Const  Options( *NoPass )

     D InputData       DS
     D   saInput                    133A

     D APPLTAGDS       DS                  dim(100) qualified
     D  CONNID                       16
     D  APPLTAG                      28
     D  APPLTYPE                     10

     D idx             S             10I 0
     D jobCount        S             10I 0
     D jobCmd          S            128
     D mqJob           S             52
     D AtrValue        S            512a   Varying

     C     *Entry        Plist
     C                   Parm                    pMqmName         48
     C                   Parm                    pApplType        10
     C                   Parm                    pJobAction       10

     C                   READ      MQJOBLST      InputData                LR
     C                   DOW       *INLR = *OFF
     C                   CALLP     ParseInput
     C                   READ      MQJOBLST      InputData                LR
     C                   ENDDO

     C                   eval      jobCount = idx
     C
     C                   For       idx = 1 to jobCount
1B   C                   If        pApplType='USER'
2B   C                   If        %trim(APPLTAGDS(idx).APPLTYPE) = 'USER'
 3b  C                   If        pJobAction = '*DSP'
     C                   eval      mqJob = APPLTAGDS(idx).APPLTYPE +
     C                                     APPLTAGDS(idx).APPLTAG
     C                   callp     SndCmpMsg('DISPLAY ' + mqJob)
 3x  C                   Else
  4b C                   If        pJobAction = '*ENDJOB'
     C                   eval      jobCmd = 'ENDJOB JOB(' +
     C                                      %trim(APPLTAGDS(idx).APPLTAG) +
     C                                      ') OPTION(*IMMED)'
     C                   callp(e)  RunCmd(%Trim(jobCmd):%Len(%Trim(jobcmd)))
  4e C                   EndIf
  4b C                   If        pJobAction = '*ENDCNN'
     C                   eval      jobCmd = 'ENDMQMCONN CONN(' +
     C                                      %trim(APPLTAGDS(idx).CONNID) +
     C                                      ') MQMNAME(' +
     C                                      %trim(pMqmName) + ')'
     C                   callp(e)  RunCmd(%Trim(jobCmd):%Len(%Trim(jobcmd)))
  4e C                   EndIf
  4b C                   If        %error
     C                   Callp     SndEscMsg ('Command Error:' +
     C                                         %trim(jobCmd)   +
     C                                        ', please see joblog'
     C                                       )
     C                   Else
     C                   Callp     SndCmpMsg ('Command :' +
     C                                         %trim(jobCmd)   +
     C                                        ' completed.'
     C                                       )
  4e C                   EndIf
 3e  C                   EndIf
2e   C                   EndIf
1X   C                   Else
2b   C                   If        %trim(APPLTAGDS(idx).APPLTYPE) <>'USER'
     C                   eval      mqJob = APPLTAGDS(idx).APPLTYPE +
     C                                     APPLTAGDS(idx).APPLTAG
     C                   callp     SndCmpMsg('DISPLAY ' + mqJob)
2e   C                   EndIf
1e   C                   EndIf
     C
     C                   EndFor

      **********************************************************************

     P ParseInput      B

     D ParseInput      PI

     C                   eval      AtrValue=
     C                               %trim(GetAtrValue(saInput: 'CONN'))
     C                   If        %len(%trim(AtrValue)) = 16
     C                   eval      idx = idx + 1
     C                   eval      APPLTAGDS(idx).CONNID  = %trim(AtrValue)
     C                   EndIf

     C                   eval      AtrValue=
     C                               %trim(GetAtrValue(saInput: 'APPLTAG'))
     C                   If        %len(%trim(AtrValue)) > 0
     C                   eval      APPLTAGDS(idx).APPLTAG = %trim(AtrValue)
     C                   eval      AtrValue=
     C                               %trim(GetAtrValue(saInput: 'APPLTYPE'))
     C                   eval      APPLTAGDS(idx).APPLTYPE=%trim(AtrValue)
     C                   EndIf

     P ParseInput      E


     P GetAtrValue     B

     D GetAtrValue     PI           512    Varying
     D  pInputStr                   512a   Const  Varying
     D  pAtrName                     64a   Const  Varying

     D  AtrName        S            512a
     D  AtrValue       S            512a   Varying

     C                   eval      AtrValue = ''
     C                   z-add     0             Str               5 0
     C                   z-add     0             End               5 0
     C                   Eval      AtrName = %trim(pAtrName)+ '('
     C                   Eval      Str=%Scan(%trim(AtrName): pInputStr: 1)
     C                   If        Str > 0
     C                   Eval      End=%Scan(%trim(')'):saInput: Str)
     C                   Eval      AtrValue =
     C                              %SubSt(pInputStr:
     C                                     str+%len(%trim(AtrName)):
     C                                     End-(str+%len(%trim(AtrName))))
     C                   EndIf

     C                   Return            AtrValue

     P GetAtrValue     E
     **-- Send escape message:  ----------------------------------------------**
     P SndEscMsg       B
     D                 Pi            10i 0
     D  PxMsgDta                    512a   Const  Varying

      /Free

        SndPgmMsg( 'CPF9898'
                 : 'QCPFMSG   *LIBL'
                 : PxMsgDta
                 : %Len( PxMsgDta )
                 : '*ESCAPE'
                 : '*PGMBDY'
                 : 1
                 : MsgKey
                 : ERRC0100
                 );

        If  ERRC0100.BytAvl > *Zero;
          Return  -1;

        Else;
          Return  0;

        EndIf;

      /End-Free

     P SndEscMsg       E
     **-- Send completion message:  ------------------------------------------**
     P SndCmpMsg       B
     D                 Pi            10i 0
     D  PxMsgDta                    512a   Const  Varying

      /Free

        SndPgmMsg( 'CPF9897'
                 : 'QCPFMSG   *LIBL'
                 : PxMsgDta
                 : %Len( PxMsgDta )
                 : '*COMP'
                 : '*PGMBDY'
                 : 1
                 : MsgKey
                 : ERRC0100
                 );

        If  ERRC0100.BytAvl > *Zero;
          Return  -1;

        Else;
          Return  0;

        EndIf;

      /End-Free

     **
     P SndCmpMsg       E



File  : QCMDSRC
Member: CHKMQJOB
Type  : CMD
Usage : CrtCmd Cmd( CHKMQJOB  )
               Pgm( CHKMQJOBC )
               SrcMbr( CHKMQJOB  )			   
			   
        CRTSRCPF FILE(QGPL/MQSRC) TEXT('MQ CMD SRC')                   
        Put following line to file QGPL/MQSRC menber CHKMQJOB          
        DISPLAY CONN(*) TYPE(CONN) APPLTAG APPLTYPE                    

        

						
/*-------------------------------------------------------------------*/
/*                                                                   */
/*  Compile options:                                                 */
/*                                                                   */
/*    CrtCmd Cmd( CHKMQJOB  )                                        */
/*           Pgm( CHKMQJOBC )                                        */
/*           SrcMbr( CHKMQJOB  )                                     */
/*                                                                   */
/*-------------------------------------------------------------------*/
             Cmd      Prompt( 'Check MQ Job')

             Parm       QMNAME       *Char      48         +
                        Min(1)                             +
                        Prompt('Queue manager name')

             PARM       ApplType     *Char      10         +
                        Rstd(*YES)                         +
                        Dft(USER)                          +
                        Values(USER SYSTEM)                +
                        Prompt('Application type')

             PARM       JobAction    *Char      10         +
                        Rstd(*YES)                         +
                        Dft(*DSP)                          +
                        Values(*DSP *ENDCNN *ENDJOB)       +
                        PmtCtl( P0001 )                              +
                        Prompt('Job action')

 P0001:      PmtCtl     Ctl( APPLTYPE )                              +
                        Cond(( *EQ 'SYSTEM' ))

             DEP        Ctl(&APPLTYPE *EQ 'SYSTEM')                  +
                        Parm((&JOBACTION *EQ '*DSP'))                +
                        NbrTrue( *EQ  1 )


Command sample:
                             Check MQ Job (CHKMQJOB)                            
                                                                                
 Type choices, press Enter.                                                     
                                                                                
 Queue manager name . . . . . . .                                               
                                                                                
 Application type . . . . . . . .   USER          USER, SYSTEM                  
 Job action . . . . . . . . . . .   *DSP          *DSP, *ENDCNN, *ENDJOB        

Note: 
*DSP    => display MQ job info
*ENDCNN => end MQ USER connection handle
*ENDJOB => end MQ USER connection job


參照: Start IBM MQ Commands (STRMQMMQSC)

參照: DISPLAY CONN




星期二, 10月 24, 2023

Domino Document

 https://help.hcltechsw.com/domino/welcome/index.html


Domino 12.0.2 Designer


Developer View for IBM/Lotus Notes


WebSphere MQ Programming Using Base Classes for Java


(PDF) Integrate Domino and WebSphere MQ - DOKUMEN.TIPS


(PDF) Writing Java to build applications using IBM Lotus Domino Designer


Example: Working with sections in Java classes
This agent displays properties for all the sections in the Body item of the current document.
import lotus.domino.*;

public class JavaAgent extends AgentBase {

 public void NotesMain() {

   try {
     Session session = getSession();
     AgentContext agentContext = session.getAgentContext();

     // (Your code goes here)
     DocumentCollection dc = agentContext.getUnprocessedDocuments();
     Document doc = dc.getFirstDocument();
     RichTextItem body = (RichTextItem)doc.getFirstItem("Body");
     RichTextNavigator rtnav = body.createNavigator();
     if (rtnav.findFirstElement(RichTextItem.RTELEM_TYPE_SECTION)) {
       do {
         RichTextSection rtsection = (RichTextSection)rtnav.getElement();
         System.out.println(
           "Title = " + rtsection.getTitle());
         System.out.println("\tBar color = " +
           rtsection.getBarColor().getNotesColor());
         System.out.println(
           "\tIs expanded = " + rtsection.isExpanded());
         System.out.println(
           "\tTitle style font = " + rtsection.getTitleStyle().getFont());
       } while (rtnav.findNextElement());
     }
     else
       System.out.println("No sections in Body");

   } catch(Exception e) {
     e.printStackTrace();
   }
 }
}  
  



星期二, 10月 03, 2023

MQ Ansible

mq-ansible

https://github.com/ibm-messaging/mq-ansible


MQ Ansible YAML Commands Collection

 https://community.ibm.com/community/user/integration/blogs/mayur-raja1/2023/05/22/mq-ansible-yaml-commands-collection


It uses the MQ REST API, it relies on configuring an MQ Web Server


Configuring an IBM MQ queue manager to use a dedicated Listener, Channel and Queue in Linux

 https://www.ibm.com/support/pages/node/1135522


Configuring MQ to use a dedicated Listener, Channel and Queue in Linux_2.pdf

Configuring an IBM MQ queue manager to use a dedicated Listener, Channel and Queue in Linux
The chapters are:
Chapter 1: User "root" adds the proper user and group in both hosts
  User "fulano" is not an MQ administrator, and will be allowed to put/get messages.
  User "bob" is not an MQ administrator, and will NOT be allowed to put/get messages.
Chapter 2: MQ administrator (user "mqm") creates a queue manager with the basic/normal objects in host-1
Chapter 3: MQ administrator adds the dedicated objects.
Chapter 4: User "fulano" from host-2 puts and gets messages using the dedicated objects.
Chapter 5: User "fulano" from host-2 uses runmqsc to look at CURDEPTH on MY.Q
Chapter 6: User "bob" from host-2 fails to put/get messages using the dedicated objects
.
The dedicated objects are:
- Listener (such as MY.LISTENER in port 1420)
- Server-Connection Channel (such as MY.CHANNEL)
- Queue in Linux (such as MY.Q)
- Channel Authentication Record (CHLAUTH) for this server-connection channel that allows only the user "fulano" who is a member of the group "mqusers".
- Authority records for group "mqusers" to display, put, get, browse, etc. from the dedicated queue.