Reputation: 3439
I try to inquire status of channels of IBM MQ. The next snippet of PowerShell is my attempt to do it. But i am in doubt about how i get the status of inactive channels.
&{
$erroractionpreference='stop'
try{
$mq="${env:programfiles(x86)}\IBM\WebSphere MQ\bin\amqmdnet.dll"
[void][reflection.assembly]::loadfrom($mq)
$mqe=[ibm.wmq.mqenvironment]
$mqe::hostname='localhost'
$mqe::port=1414
$mqe::channel='SYSTEM.DEF.SVRCONN'
$mqc=[ibm.wmq.mqc]
$mqe::properties[$mqc::transport_property]=$mqc::transport_mqseries_managed
$mqe::properties[$mqc::ccsid_property]=$mqc::codeset_utf
$qm=new-object ibm.wmq.mqqueuemanager EKR_33
$ag=new-object ibm.wmq.pcf.pcfmessageagent
$ag.connect($qm)
$cmqcfc=[ibm.wmq.pcf.cmqcfc]
$rq=new-object ibm.wmq.pcf.pcfmessage $cmqcfc::mqcmd_inquire_channel_names
$rq.addparameter($cmqcfc::mqcach_channel_name,'*')
$chst=@{}
$ag.send($rq)|%{
$_.getstringlistparametervalue($cmqcfc::mqcach_channel_names)|%{
$chst[$_.trim()]='INACTIVE'
}
}
$rq=new-object ibm.wmq.pcf.pcfmessage $cmqcfc::mqcmd_inquire_channel_status
$rq.addparameter($cmqcfc::mqcach_channel_name,'*')
$st=@{$cmqcfc::mqchs_binding='BINDING'
$cmqcfc::mqchs_inactive='INACTIVE'
$cmqcfc::mqchs_initializing='INITIALIZING'
$cmqcfc::mqchs_paused='PAUSED'
$cmqcfc::mqchs_requesting='REQUESTING'
$cmqcfc::mqchs_retrying='RETRYING'
$cmqcfc::mqchs_running='RUNNING'
$cmqcfc::mqchs_starting='STARTING'
$cmqcfc::mqchs_stopped='STOPPED'
$cmqcfc::mqchs_stopping='STOPPING'}
$ag.send($rq)|%{
$chst[$_.getstringparametervalue($cmqcfc::mqcach_channel_name).trim()]=
$st[$_.getintparametervalue($cmqcfc::mqiach_channel_status)]
}
$chst|ft -a
}finally{
if($ag){$ag.disconnect()}
if($qm){$qm.disconnect()}
}
}
Some technical details:
OS: Windows Server 2008 R2 Standard
IBM Websphere MQ Version: 7.1.0.5
2 JoshMc:
Actually, there is no any error in the snippet.
At first i presume inactive status of channels...
$rq=new-object ibm.wmq.pcf.pcfmessage $cmqcfc::mqcmd_inquire_channel_names
$rq.addparameter($cmqcfc::mqcach_channel_name,'*') $chst=@{} $ag.send($rq)|%{
$_.getstringlistparametervalue($cmqcfc::mqcach_channel_names)|%{
$chst[$_.trim()]='INACTIVE' # My guess
}
}
... and only then inquire their status in reality.
$rq=new-object ibm.wmq.pcf.pcfmessage $cmqcfc::mqcmd_inquire_channel_status
$rq.addparameter($cmqcfc::mqcach_channel_name,'*')
$ag.send($rq)|%{ # I have never got channels with inactive status through sending the 'mqcmd_inquire_channel_names' message.
$chst[$_.getstringparametervalue($cmqcfc::mqcach_channel_name).trim()]=
$st[$_.getintparametervalue($cmqcfc::mqiach_channel_status)]
I don't know whether it is right or not.
Upvotes: 0
Views: 994
Reputation: 7629
If a channel is INACTIVE, this means it has no status. That is, no record associated with that channel will be returned on the Inquire Channel Status command.
To put it another way. If you have no record returned on the Inquire Channel Status command for a particular channel name, then this means that the channel is INACTIVE.
Upvotes: 2