MQSeriesとDataQueueプログラムの例

LANSA Integrator

MQSeriesとDataQueueプログラムの例


この例では、1つのプログラムでMQSeriesとDataQueueの両方にアクセスします。

********** Beginning of RDML commands **********
FUNCTION   OPTIONS(*DIRECT)
********** 
DEFINE     FIELD(#JSMSTS) TYPE(*CHAR) LENGTH(20)
DEFINE     FIELD(#JSMMSG) TYPE(*CHAR) LENGTH(255)
DEFINE     FIELD(#JSMCMD) TYPE(*CHAR) LENGTH(255)
**********
********** Stop MQ fields going across by prefixing with JSM
********** 
DEFINE     FIELD(#JSMQMGR) TYPE(*CHAR) LENGTH(48)
DEFINE     FIELD(#JSMQNAME) TYPE(*CHAR) LENGTH(48)
********** 
DEFINE     FIELD(#JSMRQMGR) TYPE(*CHAR) LENGTH(48)
DEFINE     FIELD(#JSMREPLYQ) TYPE(*CHAR) LENGTH(48)
********** 
DEFINE     FIELD(#JSMWAIT) TYPE(*DEC) LENGTH(8) DECIMALS(0)
DEFINE     FIELD(#JSMMSIZE) TYPE(*DEC) LENGTH(8) DECIMALS(0)
DEFINE     FIELD(#JSMDEPTH) TYPE(*DEC) LENGTH(8) DECIMALS(0)
DEFINE     FIELD(#JSMCCSID) TYPE(*DEC) LENGTH(8) DECIMALS(0)
DEFINE     FIELD(#JSMPST) TYPE(*CHAR) LENGTH(1)
DEFINE     FIELD(#JSMPTY) TYPE(*DEC) LENGTH(8) DECIMALS(0)
DEFINE     FIELD(#JSMMID) TYPE(*CHAR) LENGTH(24)
DEFINE     FIELD(#JSMCID) TYPE(*CHAR) LENGTH(24)
DEFINE     FIELD(#JSMMTYPE) TYPE(*DEC) LENGTH(9) DECIMALS(0)
**********
********** Data Queue
**********
DEFINE     FIELD(#JSMQLIB) TYPE(*CHAR) LENGTH(10)
DEFINE     FIELD(#JSMQNME) TYPE(*CHAR) LENGTH(10)
DEFINE     FIELD(#JSMQKEY) TYPE(*CHAR) LENGTH(256)
**********
DEFINE     FIELD(#ORDER) TYPE(*CHAR) LENGTH(10)
DEFINE     FIELD(#NAME) TYPE(*CHAR) LENGTH(50)
DEFINE     FIELD(#STREET) TYPE(*CHAR) LENGTH(50)
DEFINE     FIELD(#CITY) TYPE(*CHAR) LENGTH(50)
DEFINE     FIELD(#STATE) TYPE(*CHAR) LENGTH(5)
DEFINE     FIELD(#ZIP) TYPE(*CHAR) LENGTH(5)
********** 
DEFINE     FIELD(#LINENUM) TYPE(*DEC) LENGTH(3) DECIMALS(0)
DEFINE     FIELD(#PARTNUM) TYPE(*DEC) LENGTH(3) DECIMALS(0)
DEFINE     FIELD(#PARTDSC) TYPE(*CHAR) LENGTH(50)
DEFINE     FIELD(#PARTAMT) TYPE(*DEC) LENGTH(10) DECIMALS(2)
DEFINE     FIELD(#PARTQTY) TYPE(*DEC) LENGTH(3) DECIMALS(0)
**********
**********
DEF_LIST   NAME(#WRKLST) FIELDS((#LINENUM) (#PARTNUM) (#PARTDSC)
          ( #PARTAMT) (#PARTQTY)) TYPE(*WORKING)
**********
CHANGE     FIELD(#JSMQMGR) TO('TEST.QMANAGER')
CHANGE     FIELD(#JSMQNAME) TO('TEST.QUEUE')
**********
********** Get Queue Depth
********** 
CALL       PGM(JSMMQDEPTH) PARM(#JSMQMGR #JSMQNAME #JSMDEPTH #JSMSTS #JSMMSG)
          NUM_LEN (*DEFINED)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
**********
DISPLAY    FIELDS((#JSMDEPTH))
********** 
********** Open service
**********
USE        BUILTIN(JSM_OPEN) TO_GET(#JSMSTS #JSMMSG)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
**********
********** Load service
**********
USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_LOAD SERVICE(XMLQueueService)') 
          TO_GET(#JSMSTS #JSMMSG) 
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
********** Get message
********** 
CHANGE     FIELD(#JSMQLIB) TO(JSMSRC)
CHANGE     FIELD(#JSMQNME) TO(JSMQUEUE)
CHANGE     FIELD(#JSMQKEY) TO(*BLANK)
CHANGE     FIELD(#JSMWAIT) TO(5000)
**********
CALL       PGM(JSMDQGET) PARM(#JSMQLIB #JSMQNME #JSMQKEY #JSMWAIT
          #JSMSTS #JSMMSG) NUM_LEN(*DEFINED
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
CALL       PGM(JSMMQGET) PARM(#JSMQMGR #JSMQNAME #JSMWAIT #JSMMSIZE
          #JSMMID #JSMCID #JSMRQMGR #JSMREPLYQ #JSMMTYPE #JSMSTS #JSMMSG)
          NUM_LEN(*DEFINED)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
********** Receive XML
********** 
CHANGE     FIELD(#JSMCMD) TO('RECEIVE XSL(RECEIVEORDER) SERVICE_LIST
          (LINENUM,PARTNUM,PARTDSC,PARTAMT,PARTQTY)')
**********
USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) TO_GET
          (#JSMSTS #JSMMSG #WRKLST)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
********** 
DISPLAY    FIELDS((#ORDER))
**********
********** Send XML
********** 
CHANGE     FIELD(#JSMCMD) TO('SEND XSL(SENDORDER)
          SERVICE_LIST(LINENUM,PARTNUM,PARTDSC,PARTAMT,PARTQTY)')
**********
USE        BUILTIN(JSM_COMMAND) WITH_ARGS(#JSMCMD) 
          TO_GET(#JSMSTS #JSMMSG #WRKLST)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
********** Put new message
********** 
CHANGE     FIELD(#JSMCCSID) TO(0)
CHANGE     FIELD(#JSMMTYPE) TO(8)
CHANGE     FIELD(#JSMMID) TO(*BLANK)
CHANGE     FIELD(#JSMCID) TO(*BLANK)
CHANGE     FIELD(#JSMPST) TO(Y)
CHANGE     FIELD(#JSMPTY) TO(4)
CHANGE     FIELD(#JSMRQMGR) TO(*BLANK)
CHANGE     FIELD(#JSMREPLYQ) TO(*BLANK)
********** 
CALL       PGM(JSMMQPUT) PARM(#JSMQMGR #JSMQNAME #JSMCCSID #JSMPST
          #JSMPTY #JSMMID #JSMCID #JSMMTYPE #JSMRQMGR #JSMREPLYQ
          #JSMSTS #JSMMSG) NUM_LEN(*DEFINED)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
CALL       PGM(JSMDQPUT) PARM(#JSMQLIB #JSMQNME #JSMQKEY
          #JSMSTS #JSMMSG) 
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
********** Close service
**********                                 
USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG) 
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
********** 
********** SUB ROUTINES 
**********                            
SUBROUTINE NAME(CHECK) PARMS((#JSMSTS *RECEIVED) (#JSMMSG *RECEIVED))
********** 
IF         COND('#JSMSTS *NE OK')
**********     
DISPLAY    FIELDS((#JSMSTS) (#JSMMSG))
********** 
USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)
********** 
MENU       MSGTXT('Java service error has occurred')
********** 
ENDIF                                        
********** 
ENDROUTINE 
********** End of RDML commands **********