Basics IBM Websphere MQ Series

This article introduced a simple MQ Server composed of a queue manager, local queues, channels. Channels allow the queues to communicate between each other. Aliases can also be used to give an alias to queues.

Create a queue manager

Queue managers are the main components in a WebSphere MQ messaging network.

Display queue managers before


If the queue manager does not already exist create a queue manager

crtmqm QM1

Start the queue manager

strmqm QM1

This command will modify the queue manager. For example here channel authentication are not recorded :


Create a channel

Definition of a channel

WebSphere MQ uses two different types of channels:

  • A message channel, which is a unidirectional communications link between two queue managers.
  • An MQI channel, which is bidirectional and connects an application (MQI client) to a queue manager on a server machine.

    How to create a Channel ?

    In our app we use a “receiver channel”

    A receiver channel is a message channel that the queue manager uses to receive messages from other queue managers.

    Verify existence of channel

    dspmqfls -m QM1 -t CHAN_RCV

    Create a receiver channel

     runmqsc QM1  <<e@

    Also we use “Sender channel”

    A sender channel is a message channel that the queue manager uses to send messages to other queue managers.

    Create a receiver channel

     runmqsc QM1  <<e@

    What is a purpose of a transmission queue ?

    We need this queue to send a message to another queue.

    Create a transmission queue :

    runmqsc QM1 <<e@

    Create a local queue/in for the reception of message

    runmqsc QM1 <<e@

    Create a corresponding alias of the queue. It is a link to the queue.


    Create a local queue/out to send messages

    It is the same thing as for the reception of the message. Only the name of the queue is different.

    What is the difference between queue and channel in MQ ?

    For IBM MQ one endpoint is always the queue manager (a type of messaging engine) and the other is an application or another queue manager.

    Based on this example, it should be obvious that channel as used in the book and channel as defined by any messaging transport are at different levels of abstraction. As used by MQ, a channel is a specific set of configuration parameters that define a communication path and includes such attributes as CONNAME, MAXMSGL, tuning parameters, SSL parameters,

    Once an MQ channel is successfully started, you can see a running instance of it by displaying the channel status. In the case of CLUSRCVR, SVRCONN, and (less commonly) RCVR or RQSTR channels, you may see multiple instances of the same channel active simultaneously.

    How to connect to a queue manager in MQ ?

    I actually use the mqexplorer(mqj.cmd) from Windows. The project is opensource at .

    Run the program MQ explorer and from “Show Queue Manager” choose a remote queue for distant server MQ.

    show_queue_manager - Copy


    If there is an error in mqjexplorer(example with MQRC_Q_MGR_NOT_AVAILABLE) , verify that queue is started:

    strmqm QM1

    If it is OK then verify that the listener is started :

    runmqlsr -m QM1 -t TCP -p PORT_MQ &

    Normally it fixes the issue of queue manager not being accessible from mqexplorer.


    How to simulate a MQ server ?

    The problem

    Our application is retrieving information from a distant server using IBM Websphere Mq messaging system. In production we need to install two MQ servers , one on machine A and another one on machine B:

    Creation Fil MQ

    We want to avoid installing MQ Server on two machines for the qualification platform. How to simulate machine B ‘s MQ Server ?

    The solution

    This article will explain several steps taken to simulate the communication between two MQ servers. These are the steps explained :

  • Create a MQ server on machine A
  • Run a Java application on machine B within tomcat which listens to inqueue QueueManager and send back information to Outqueue MQ queue manager
  • Create a MQ server on machine A

    A IBM MQ server is composed of a queue manager, local queues, channels. Channels allow the queues to communicate between each other. Aliases can also be used to give an alias to queues.

    Simulate a MQ server on machine B

    First of all install tomcat on the machine B. The solution is using Java to catch JMS information from our MQ Server on machine A. To simulate the MQ Server these are the steps :

  • Add a listener in web.xml
  • The Java class listener will be launched at tomcat startup.
  • At statup , the listener starts one Thread or multiple ones to listen one or multiples queue managers
  • Let’s assume we have one thread listening to one Queue manager
  • When a Thread is cathing a JMS message, from receiver/in queue of machine A, it will parse the message
  • Based on the parsed message we check a database or filesystem for a DataSet response
  • Finally we send the dataset response to the Out/sender queue of machine A
  • The application in machine A reads the out/sender queue and process it like normal not knowing it is consuming messages from the simulator
  • That’s it : the machine B simulated a MQ Server
  • Add a listener to tomcat web.xml


    At startup of tomcat the MQlistener will be launched. The thread is started within the listener like this :

    final MqThread mq= new MqThread (mqinfo);
    MqThread .start();

    Read MQ configuration detailed from a file

    We need to know to which receiver/in queue we will listen to and which sender/out queue we will send message to.

    Example of properties file containing these information :

    hostname	  = myserver
    port		  = 9999
    queueManager = MYQUEUEMANAGER	  = QUEUE.OUT
    queue.out	  = QUEUE.IN

    “” represents the queue we are lestening to. “queue.out” is the queue we are going to send message to.

    Start a thread listening to a receiver queue

    The MqThread extends Thread class. It contains a run() method which will be executed when the thread is started.

    The MqThread constructor prepares an active connection with the queue manager and the queue receiver and sender in order to communicate with the MQ server .

    import javax.jms.QueueConnection;
    public MqThread (MqInfo mqInfo) throws JMSException {
    final MQQueueConnectionFactory queueConnectionFactory = new MQQueueConnectionFactory();
          queueConnection = queueConnectionFactory.createQueueConnection(mqInfo.user, mqInfo.password);
          // A QueueConnection object is
          // an active connection to a point-to-point JMS provider.
          this.queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
          // A QueueConnection can be used 
          // to create a QueueSession, 
          // from which specialized 
          // queue-related objects can be created
          this.receiver = session.createReceiver(mqInfo.receiverQueue);
          // Creates a QueueReceiver object to receive 
          // messages from the specified queue.
          this.sender = session.createSender(mqInfo.senderQueue);
          // Creates a QueueSender object to send 
          // messages to the specified queue.

    More information about QueueConnection

    The thread will be listening to MQ receiver queue. When a JMS message is sent to that queue the thread will consume and parse the message.

    public run() {
    		this.queueManager = queueManager;
                    while (isThreadTerminated) {
    		    final Message message = receiver.receive(1000);
    		    proccessMessage(message );

    The run() method is listening to queue receiver to handle messages from this queue.

    Receives the next message that arrives within the specified timeout interval.

    Based on the parsed message we check a database or filesystem for a DataSet response

    Once the message is parsed we can retrieve a DataSet response from a file system. This example is not complet but give an idea what to do :

    	private String getDataSetResponse(String inputMessage) {
    		final String filename = getFileNameDataSet(inputMessage);
    		return getFile(filename );

    Finally we send the dataset to the Out/sender queue of machine A

    private void sendMessage(String message, String messageId) throws JMSException {
           final TextMessage dataSetMessage = session.createTextMessage(message);
           sender.send(dataSetMessage );

    That ‘s it

    How to apply CSS specific on several tables ?


    Our website did not look nice because of a CSS problem.
    Indeed some data on one row of a table was scrollable.
    The data of one row would overflow.

    How to stop this data to be scrollable on one line ?
    The goal was to present the information in several lines instead of one line. The solution to this first problem was to modify the table-layout for the CSS element table to “fixed” property.

    table {
        border-collapse: collapse;
        clear: both;
        margin-left: auto;
        margin-right: auto;
        width: 98%;
        table-layout: fixed;

    Unfortunalely because of this global modification of CSS another problem popped up in a diffrent webpage :


    The solution for this second problem was to make the CSS table tag to this configuration :

    table-layout: auto

    Auto layout is the default property for most of the tables of my website in CSS.The auto property adapts the table layout to all different browers which is practical. But how can we apply specific CSS properties to specific tables ?

    This link help me to apply specific CSS to one specific table using id :


    This is the html page where we had a scrollable/overflow initial problem :

    <table id="my_tableA_X" class="result ">
    <table id="my_tableA_Y" class="result ">
    <table id="my_tableA_Z" class="result ">

    my_tableA_Y is having the scrollable/overflow problem. But I want also all other tables (starting with my_tableA) to have a similar look. Therefore i  will  apply the same CSS properties to all tables with id starting  by “my_tableA”. Regex is used to achieve this inside CSS file :

    The solution to the two problems :

        border-collapse: collapse;
        clear: both;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 5px;
        margin-top: 5px;
        width: 98%;    
        table-layout: fixed;
    table {
        border-collapse: collapse;
        clear: both;
        margin-left: auto;
        margin-right: auto;
        width: 98%;
        table-layout: auto;

    Now all table which start with an id my_tableA have the same layout and columns have same size , width, etc… This solution fixed the problem. The second table CSS tag indicates that other tables will have auto layout.


    How to bind apache server non localhost to tomcat server?


    We would like to make sur tomcat only listen to apache server which was not on localhost adress. It is a security measure to protect the tomcat port.

    In order to do that we need to add the attribute “address” to the connector of the tomcat port.
    Few words about the connector :

    The HTTP Connector element represents a Connector component that supports the HTTP/1.1 protocol. It enables Catalina to function as a stand-alone web server, in addition to its ability to execute servlets and JSP pages.

    <Connector port="8111"                

    Few words about the attribute address :

    For servers with more than one IP address, this attribute specifies which address will be used for listening on the specified port. By default, this port will be used on all IP addresses associated with the server.

    NOTE : this solution uses HTTP protocol connector to connect to apache instead of AJP protocol. The connector AJP should be used between apache and tomcat for performance reason.


    At first I used the localhost address( to make tomcat listening to this address. I wrongly assume the apache server was at the local address server.

    Apache and tomcat would start with no errors. However the application would not start. There was no errors meaningful in the application logs, tomcat logs. At last i found some error in apache server error.log :

    [Thu Jun 15 17:56:15 2017] [error] (111)Connection refused: proxy: HTTP: attempt to connect to (machine_adress) failed
    [Thu Jun 15 17:56:15 2017] [error] ap_proxy_connect_backend disabling worker for (machine_adress)

    This error helped to find a solution to this problem.
    I checked the IP address and I found out in /etc/hosts that the adress was link to a server called apache_instance1

    Solution :

    I check in apache configuration “httpd.conf” and I found out that the name of the server is :

    ServerName apache_instance1

    Therefore to bind tomcat port to listen only to apache server, I had to do modify the attribute adress like this :


    <Connector port="8111"                

    It fixes my problem.

    Set up apache reverse proxy with tomcat

    This article will overview the relation between Apache HTTP Server and tomcat and also the reverse proxy.

    For a long time tomcat/apache was a black-box for me because I did not have to manage it. But few years ago I had the opportunity to gain more knowledge on this subject. The aim of this article is to focus on the big picture of apache/tomcat and present the mod reverse proxy for Apache HTTP server.

    What is tomcat ?

    Tomcat executes Java servlets and renders Webpages JSP ( Java server page). This guide can help you to understand and run tomcat

    Tomcat is a web server used in the Java world most of the time. It is also easy to use in dev environment with Eclipse for quick testing of JSP/Javascript/HTML/CSS pages.

    Install tomcat on linux :

    Why use Apache if tomcat is a web server ?

    Apache is more robust for HTML/images static content. For production environment it is necessary to have Apache HTTP web server combined with tomcat for dynamic content(JSP).

    How apache and tomcat communicate together ?

    I am not going into details since there is a documentation about it in user’s guide and also here

    I am just going through the most important steps briefly and give real world example along the way. For information the example i am giving is in with tomcat version 8.0.23 and apache version Apache/2.2.15 (Unix).

    What’s required to pull this off?
    Answers to the above three questions!
    1. Configure Tomcat
    2. Install a web server adapter.
    3. Modify Apache’s httpd.conf file.

    1.Configure Tomcat

    1.1 Modify Tomcat’s server.xml file.
    -> Create connectors (HTTP/HTTPS/AJP). A “Connector” represents an endpoint by which requests are received and responses are returned.
    ->The AJP connector is mechanism by which Tomcat will communicate with Apache.

    1.2 Defining a context.
    ->It is NOT recommended to place elements directly in the server.xml file. Defined in context.xml instead.
    -> We can also defined here the jdbc configuration used to access the database. Jdbc Example under the context :

    The Resources element represents all the resources available to the web application. . Example of resource within the context to mount the web app :

    2.Install a web server adapter.

    This adapter is not located in apache or tomcat configuration. It answers the question : “How will Apache forward these requests to Tomcat?”.

    mod_jk requires two entities: – The Apache HTTP Server module, depending on your operating system, it will be, mod_jk.nlm or MOD_JK.SRVPGM (see the build section).For example in our linux machine.
    find / -iname ‘*MOD_JK*’ -print 2>/dev/null
    /usr/lib64/httpd/modules/ – A file that describes the host(s) and port(s) used by the workers (Tomcat processes). A sample can be found under the conf directory in the source download.
    Also as with other Apache modules, mod_jk should be first installed on the modules directory of your Apache HTTP Server, ie: /usr/lib/apache and you should update your httpd.conf file.
    Mod_jk.conf – It is not necessarily needed to make custom changes of this file. There are situation where we need to make changes.

    For information and Mod_jk.conf are located under our module apache/conf.d

    3.Modify Apache’s httpd.conf file.

    We need to tell Apache how to load and initialize our adapter, and that certain requests should be handled by this adapter and forwarded onto Tomcat.Tomcat does most of the work for you.

    Each time you start Tomcat, after it loads Contexts (both from the server.xml and automatically from $TOMCAT_HOME/webapps), it automagically generates a number of files for you. The two that we’re concerned with are:
    tomcat-apache.conf (should really be named mod_jserv.conf-auto)

    For example on my latest project our httpd.file we have simply a line to include all configuration files for apache including mod_jk.conf. :

    Include conf.d/*.conf

    NOTE : For this application we do not use mod_jk.conf-auto but our own custom configuration file mod_jk.conf.

    More information at chapter “httpd.conf – Apache’s main configuration file”

    Reverse Proxy in Apache

    A reverse proxy (or gateway), appears to the client just like an ordinary web server. No special configuration on the client is necessary. The client makes ordinary requests for content in the namespace of the reverse proxy. The reverse proxy then decides where to send those requests and returns the content as if it were itself the origin.

    We wanted to set up a reverse proxy in order to access to a remote web server running on different machine but on the same network. The idea was to access a servlet running on different application. It would save us duplicating the servlet and a database for our application. Instead of creating something existing we could just reuse an existing web server.

    As you have seen previously we have loaded all .conf files in conf.d directory including our reverse_proxy.conf file.

    Our configuration file for the reverse proxy is the following :

    # Load the proxy module
    LoadModule proxy_http_module modules/

    # HTTP
    ProxyPass /foo/loadsomeinfo
    ProxyPassReverse /foo/loadsomeinfo

    ProxyPass / http://machinea:9000/
    ProxyPassReverse / http://machinea:9000/

    Apache module mod_proxy :

    Basics knowledge of Apache HTTP Server

    I created this article as a reminder about some basics of Apache HTTP Server with real examples. I will present how to start apache,look for logs, and give information about the configuration.

    The HTTP server handles request and does the mapping from URL to Filesystem locations. More information at

    How do we start Apache ?

    On Unix, the httpd program is run as a daemon that executes continuously in the background to handle requests.

    According to the documentation, httpd should be invoked by a script called apachectl.

    Let’s see with an example a running apache daemon. It happens I have an apache server on a test machine .

    ps -edf | grep httpd
    root     23154     1  0 10:44 ?        00:00:00 /usr/sbin/httpd.worker -f /var/apache/conf/httpd.conf -f /var/apache/conf/httpd.conf -k start

    This command ps – edf tells us where is located the configuration file used for this apache running. On our machine exists many old install of apache. Therefore this command helps to find the right configuration file used by the current apache server.

    One would wonder why httpd.worker is being run and not httpd? What is httpd.worker?
    The answer to this question is here :

    Basically at the installation of our product we install a new Apache/tomcat and deploy the application automatically. More information about how it is installed with shell scripts and deployed from Jenkins at

    Here are the commands executed by the shell script to launch our Apache server when installing on our machine :

    # Start the Apache http daemon
        write_log "Starting Apache..."
                export OPTIONS="-f ${ApacheDir}/conf/httpd.conf"
    /usr/sbin/apachectl $OPTIONS -k start
    #more code to handle the response

    Where are the logs?

    To my mind it is an important question if we want to troubleshoot problems on the server.
    More about logging and how to understand the format of the logs :

    Previously we find out where is the configuration for the httpd running at /var/apache/conf/httpd.conf. If I look into this file i can find where are located the log :

    ErrorLog logs/error_log

    Thus , on my server, the error log is located at /var/apache/logs/error_log

    NOTE : If you have several Virtualhosts you will have one log for each of them.
    It happens that on the directory /var/apache/logs there are more logs than just error_log. It is because we have defined some other configuration in /var/apache/conf.d.

    For example if i want to find which module generate ssl_error_log, i will execute on the linux machine :

     grep -rnw '/var/apache' -e "ssl_error_log"
    /var/apache/conf.d/mod_jk.conf:57:ErrorLog logs/ssl_error_log

    Understand Apache Configuration

    The following considerations are about about the HTTP Server configuration : “httpd.conf”, and other custom made configuration files.

    What is the purpose of DocumentRoot ?

    Extract from httpd.conf :

    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot "/var/apache/www/html"

    Files and directories underneath the DocumentRoot make up the basic document tree which will be visible from the web.

    Therefore what you see on a website is the tree structure under DocumentRoot :
    Then a request for will cause httpd to attempt to serve the file /var/www/html/fish/index.html.

    What does IfModule tag in configuration files ?

    Did you notice


    tag in configuration files of apache server and wondered what is it exactly ?

    In the following example, the MimeMagicFile directive will be applied only if mod_mime_magic is available.

    <IfModule mod_mime_magic.c>
        MimeMagicFile "conf/magic"

    Therefore this tag will apply directives from module.

    What is ServerName ?

    Extract from httpd.conf :

    # ServerName gives the name and port that the server uses to identify itself.
    # This can often be determined automatically, but we recommend you specify
    # it explicitly to prevent problems during startup.
    # If this is not set to valid DNS name for your host, server-generated
    # redirections will not work.  See also the UseCanonicalName directive.
    # If your host doesn't have a registered DNS name, enter its IP address here.
    # You will have to access it by its address anyway, and this will make
    # redirections work in a sensible way.
    ServerName apache-myinstance:8080

    Do the following command in a shell terminal to have more information about the IP address of the server name:

    cat \etc\hosts

    What is doing the directive Listen ?

    The Listen directive tells the server to accept incoming requests only on the specified port(s) or address-and-port combinations.

    For example we have on our server used two times the directive for

    # Virtual HOST HTTP **
    Listen apache-myinstance:8080
    # Virtual HOST HTTPS **
    Listen apache-myinstance:447

    What is a Virtual Host ?

    httpd is also capable of Virtual Hosting, where the server receives requests for more than one host. For example on the same server you would have and,etc.. running.

    <VirtualHost apache-myinstance:447>
          JkMount /* myworker
    ErrorLog logs/ssl_error_log
    CustomLog logs/ssl_access.log java_format
    LogLevel warn
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCertificateFile /etc/certs/localhost.crt
    SSLCertificateKeyFile /etc/certs/localhost.key
    <Files ~ "\.(cgi|shtml|phtml|php3?)$">
        SSLOptions +StdEnvVars
    <Directory "/var/www/cgi-bin">
        SSLOptions +StdEnvVars
    SetEnvIf User-Agent ".*MSIE.*"          nokeepalive ssl-unclean-shutdown          downgrade-1.0 force-response-1.0

    How to modify your git credentials when cloning from Git Extensions ?


    I installed recently git extensions on Windows . I had to clone a repository located on a distant server.


    But I used a wrong login (mywronglogin). Here is the error :

    "C:\Program Files (x86)\Git\bin\git.exe" clone -v --recurse-submodules --progress --branch develop "" "D:/my_repo_git"
    Cloning into 'D:/my_repo_git/myproject'...
    fatal: remote error: FATAL: R any myproject mywronglogin DENIED by fallthru
    (or you mis-spelled the reponame)

    Unfortunately from the user interface of git extensions it is not possible to modify the credentials !

    I have done the following without success

    • Modifying login in git extensions UI
    • Looking for the configuration with my wronglogin in C:/Users/mylogin, the directory of git and git extensions
    • Modifying regedit
    • I tried to uninstall git exensions but after reinstall : i got the same issue !
    • Finally I found out about the credential helper for Windows which can cache git credentials.


    I had to unset the cache credential in order to modify this login. Indeed the credentials are stored in the “credentials.helper” to avoid typing them every time. It is a nice feature except when you want you to modify the credentials for some reason.

    I had to unset credentials like this :

    git config --system --unset credential.helper

    Now when you will clone the repo you will be asked for the login/password !
    If you were not aware of this feature you can spend quite some time on this problem.