ListenerController

The second part of the URI must be listener to call the ListenerController.

inquire

Get information about one ore more listeners. This actions executes the PCF commando MQCMD_INQUIRE_LISTENER. On success, the returned JSON object will have a data array, on failure an error object.

URL Parameters

/api/listener/inquire/<QueueManager>/<ListenerName>

QueueManager

The name of the queuemanager. This parameter is required!

ListenerName

The name of the listener. When this parameter is used, the ListerName query parameter is ignored. This parameter is optional. Generic names can be used.

Query Parameters

####ExcludeSystem When value is true, system listeners are not returned. By default this parameter is false. This parameter is optional.

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.

ListenerAttrs

With the ListenerAttrs 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.

Attrs is a synonym for ListenerAttrs

ListenerName

The name of the listener. Generic names can be used. When an listenername is passed as part of the URL, this query parameter will be ignored.

TransportType

Only return listeners with the given transport type. The following types are possible: All, Local, LU62, TCP, NetBIOS, SPX, DECnet or UDP. The default is All. The value is case-sensitive.

Example

/api/listener/inquire/PIGEON
/api/listener/inquire/PIGEON?listerName=*&listenerExcludeSystem=false

This sample is a PHP script that inquires all SYSTEM listeners with transporttype TCP from queuemanager PIGEON:

<?php
	/*
	 * Inquire all SYSTEM listeners with transporttype TCP from queuemanager 
	 * PIGEON. MQWeb runs on localhost and is listening on port 8081. 
	 */
	$url = "http://localhost:8081/api/listener/inquire/PIGEON/SYSTEM*/TCP";

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


	$response = curl_exec($curl);
	$data = json_decode($response, true);		
	print_r($data);

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.

{
  'ListenerName' : 'SYSTEM*',
  'ListenerAttrs' : [
    'ListenerName',
    'TransportType'
  ]
}

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

An IntegerFilterCommand can’t be used together with a StringFilterCommand

This is a Perl example that inquires all listeners and returns the listenername and transportype attributes.

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

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

# This sample shows all listeners with the properties ListenerName and 
# TransportType

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

my $json = JSON->new;

my %input = ( 
	'ListenerName' => '*',
	'ListenerAttrs' => [ 
		'ListenerName', # Can be omitted, because it is always returned 
		'TransportType'
	]
);

my $content = $json->encode(\%input);    

my $ua = LWP::UserAgent->new;
my $req = POST 'http://localhost:8081/api/listener/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 listeners.';
	say 'Reason Code: '
		, $mqweb->{error}->{reason}->{code}
		, ' - '
		, $mqweb->{error}->{reason}->{desc};
}
else {
	foreach my $listener(@{$mqweb->{data}}) {
		say $listener->{ListenerName}->{value}
			, ' - '
			, $listener->{TransportType}->{display};
	}
}