ChannelController

The second part of the URI must be channel to call the ChannelController. This controller can be used to get information from a channel.

inquire

Get information about one or more queues. This action executes the MQCMD_INQUIRE_CHANNEL pcf command. On success, the returned JSON object will have a data array, on failure an error object.

URL Parameters

/api/channel/inquire/<QueueManager>/<ChannelName>/<ChannelType>

QueueManager

The name of the queuemanager. This parameter is required!

ChannelName

The name of a channel. Generic names are supported. When this parameter is used, query parameters are ignored. This parameter is optional.

ChannelType

The type of the channel. ChannelType must be All, Sender, Server, Receiver, Requester, Server-connection, Client-connection, Cluster-receiver or Cluster-sender. This value is case-sensitive.

Query Parameters

ChannelAttrs

With the ChannelAttrs parameter you can specify which attributes must be returned from the PCF command. Multiple occurences of this parameter are possible. The value must be a (case-sensitive) valid attribute name.

ChannelName

The name of a channel. Generic names are supported. This parameter is ignored when a channelname is passed as URL parameter. When this parameter is omitted, * will be used. name is a synonym for this parameter.

ChannelType

ChannelType must be All, Sender, Server, Receiver, Requester, Server-connection, Client-connection, Cluster-receiver or Cluster-sender. This value is case-sensitive. When channel type is passed as URL parameter, this query parameter is ignored.

CommandScope

Specifies how the command is executed when the queue manager is a member of a queue-sharing group. This parameter applies to z/OS only.

DefaultChannelDisposition

This parameter is not allowed for Client-connection channels and only applies to z/OS. Possible values are All, Private or Shared. It Specifies the disposition of the channels for which information is to be returned.

ExcludeSystem

When value is true, all channels with a name starting with SYSTEM. will be discarded. This parameter is optional. By default the value is set to false.

Filter

Speficies which filter to use: I means Integerfilter, S means Stringfilter. FilterParam and FilterValue are required to create the filter. When a filter can’t be build because of too little information, it will be silently discarded.

FilterOp

The operator that is being used to evaluate whether the parameter satisfies the filter-value. The default is EQ.

The following values are allowed:

A Stringfilter can use some additional operators:

FilterParam

The name of the parameter to filter on. The names are based on the names used in the WebSphere MQ information center.

FilterValue

The value to use for filtering. When a string is passed for an Integerfilter, a WebSphere MQ constant is assumed.

QSGDisposition

Disposition of the object within the group. Possible values are Live, Copy, Group, QMgr, Private or All. This parameter applies to z/OS only.

Example

/api/channel/inquire/PIGEON
/api/channel/inquire/PIGEON/CL.*
/api/channel/inquire/PIGEON?ChannelName=CL.*

<?php

	/*
	 * Inquire all client channels from queuemanager PIGEON.
	 * MQWeb runs on localhost and is listening on port 8081. 
	 */
	$url = "http://localhost:8081/api/channel/inquire/PIGEON/*/Server-connection";

	$curl = curl_init();
	curl_setopt($curl, CURLOPT_URL, $url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

	if ( ($response = curl_exec($curl) ) === false ) {
		$err = curl_error($curl);
		echo "An HTTP error occurred while inquiring channel information: $err\n";
	}
	else {
		$json = json_decode($response);
		if ( isset($json->error) ) {
			echo "An MQ error occurred while inquiring channels.\n";
			echo "Reason Code: {$json->error->reason->code} - {$json->error->reason->desc}\n";
		}
		else {
			if ( isset($json->data) && count($json->data) > 0 ) {
				foreach($json->data as $channel)
				{
					echo $channel->ChannelName->value;
					echo "\n";
				}
			}
			else
			{
				echo "No client channels found\n";
			}
		}
	}

JSON Object

When using an application/json POST request you can post a JSON object with names like the query parameters.

All URL parameters and query parameters are ignored except for the URL parameter for the name of the queuemanager.

    {
      'ChannelName' : 'SYSTEM*',
      'ChannelAttrs' : [
        'ChannelName',
        'ConnectionName'
      ]
    }

There are some differences between query parameters and a JSON object:

An IntegerFilterCommand can’t be used together with a StringFilterCommand

This sample is a Perl script that inquires all channels starting with SYSTEM and only returns the channelname and connectionname (if available):

#!/usr/bin/perl
use strict;
use warnings;
use feature qw(say);

use JSON;
use LWP::UserAgent;
use HTTP::Request::Common;

# Get all channels and list them with the channeltype and connectionname (if
# available

my $qmgr = shift;
die("Please pass me the name of a queuemanager as argument") 
	unless defined($qmgr);

my $json = JSON->new;

my %input = ( 
	'ChannelName' => '*',
	'ChannelAttrs' => [ 
		'ConnectioName'
		# No need to specify ChannelName and ChannelType, they are always
		# returned.
	]
);
my $content = $json->encode(\%input);    

my $ua = LWP::UserAgent->new;
my $req = POST 'http://localhost:8081/api/channel/inquire/' . $qmgr;    
$req->header(
	'Content-Type' => 'application/json',
	'Content-length' => length($content)
);
$req->content($content);

my $res = $ua->request($req);
die $res->status_line unless $res->is_success;

my $mqweb = $json->decode($res->content());
if ( exists($mqweb->{error}) ) {
	say 'An MQ error occurred while inquiring queues.';
	say 'Reason Code: '
		, $mqweb->{error}->{reason}->{code}
		, ' - '
		, $mqweb->{error}->{reason}->{desc};
}
else {
	foreach my $channel(@{$mqweb->{data}}) {
		my $output = $channel->{ChannelName}->{value};
		$output .= '(' . $channel->{ChannelType}->{display} . ')';
		if ( exists($channel->{ConnectionName}) ) {
			my $connectionName = $channel->{ConnectionName}->{value};
			if ( length($connectionName) > 0 ) {
				$output .= ' : ' . $connectionName;
			}
			else {
				$output .= ' : - ';
			}
		}
		say $output;
	}
}