********************************************** * amqsput: Put a message on a queue ********************************************** include MQSeries,mqsbp, include prompt '' * Values from the configuration file * ---------------------------------- execute 'MQSeries-setup display manager.name' capturing QMName * Startup values * -------------- HConn = -1 HObj = -1 * Parse the sentence * ------------------ gosub sen.get QName = field(sen,' ',tok); tok += 1 if QName = '' then print 'Required parameter missing - queue name' stop end * Build the connection * -------------------- QMName = '' ;* Queue manager name (use the default) call MQCONN(QMName, HConn, CompCode, Reason) gosub iserror * Open the queue * -------------- od='' od<MQOD.ObjectName> = QName Options = MQOO_INPUT_AS_Q_DEF + MQOO_OUTPUT + MQOO_INQUIRE + MQOO_SET call MQOPEN(HConn, od, Options, HObj, CompCode, Reason) gosub iserror print 'Sample AMQSPUT start' print 'Queue Name : "':QName:'"' * Put in the queue * ---------------------- loop input buffer while len(buffer) do md=''; pmo='' buff.len=len(buffer) md<MQMD.Format> = MQFMT_STRING md<MQMD.MsgId> = MQMI_NONE md<MQMD.CorrelId> = MQCI_NONE call MQPUT(HConn, HObj, md, pmo, buff.len, buffer, CompCode, Reason) gosub iserror repeat * Close the queue, then the connection * ----------------------------------- call MQCLOSE(HConn, HObj, Options, CompCode, Reason) call MQDISC(HConn, CompCode, Reason) print 'Sample AMQSPUT end' stop
sen.get: ********************************************** * Get the sentence ********************************************** tclread sen sen = trim(sen) opt = field(sen,'(',2) sen = field(sen,'(',1) tok = 1 verb = field(sen,' ',tok); tok += 1 vflg = index(opt,'v',1) return iserror: ********************************************** * if it's an error then stop ********************************************** if Reason = MQRC_NONE then return if Reason>2000 then print Reason:' (':MQRC_DESC<Reason-2000>:')' end else print Reason end if HObj > 0 then call MQCLOSE(HConn, HObj, Options, CompCode, Reason) if HConn > 0 then call MQDISC(HConn, CompCode, Reason) stop