{"id":71,"date":"2019-03-05T19:01:42","date_gmt":"2019-03-05T19:01:42","guid":{"rendered":"http:\/\/trindade.myphotos.cc\/lazysysadmin\/?p=71"},"modified":"2024-07-05T11:40:40","modified_gmt":"2024-07-05T10:40:40","slug":"ibm-mq-basics","status":"publish","type":"post","link":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/2019\/03\/05\/ibm-mq-basics\/","title":{"rendered":"<span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> basics: the first&nbsp;queue"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-99 size-medium\" src=\"http:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-content\/uploads\/sites\/7\/2019\/03\/IBM-MQ-Sticker-300x260.png\" alt width=\"300\" height=\"260\" srcset=\"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-content\/uploads\/sites\/7\/2019\/03\/IBM-MQ-Sticker-300x260.png 300w, https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-content\/uploads\/sites\/7\/2019\/03\/IBM-MQ-Sticker-768x665.png 768w, https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-content\/uploads\/sites\/7\/2019\/03\/IBM-MQ-Sticker.png 996w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\"><\/p>\n<p>Now that we\u2019ve installed <span class=\"caps\">MQ<\/span>, it\u2019s time to try it out. If you haven\u2019t read it, you can go to <a href=\"http:\/\/trindade.myphotos.cc\/lazysysadmin\/2019\/02\/25\/ibm-mq-installation-in-linux\/\">Installing <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> on Lin\u00adux<\/a> to learn how to do&nbsp;it.<\/p>\n<p>In this arti\u00adcle, I\u2019ll show you the basics of <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> and what it can do for your appli\u00adca\u00adtions\u2019 infrastructure.<\/p>\n<p><!--more--><\/p>\n<p>As the name points out, <span class=\"caps\">MQ<\/span> relies on\u2026 you guessed it, mes\u00adsage queues. Mes\u00adsage queues are man\u00adaged by\u2026 You guessed it again: queue managers.<\/p>\n<p>So, the first thing to do before cre\u00adat\u00ading your own queues is to cre\u00adate a queue manager.<\/p>\n<p>When <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> is installed it cre\u00adates an <span style=\"font-family: terminal,monaco,monospace;\">mqm<\/span> user group and an <span style=\"font-family: terminal,monaco,monospace;\">mqm<\/span> user. <span class=\"caps\">MQ<\/span> admin\u00adis\u00adtra\u00adtors have to be in the <span style=\"font-family: terminal,monaco,monospace;\">mqm<\/span> user group. The user <span style=\"font-family: terminal,monaco,monospace;\">mqm<\/span> is also part of this&nbsp;group.<\/p>\n<p>The most basic way to cre\u00adate a queue man\u00adag\u00ader is with the <span style=\"font-family: terminal,monaco,monospace;\">ctr\u00admqm<\/span> com\u00admand. To cre\u00adate the <span class=\"caps\">QM1<\/span> queue man\u00adag\u00ader, we can use the com\u00admand&nbsp;below:<\/p>\n<p class=\"code-example\">ctr\u00admqm&nbsp;<span class=\"caps\">QM1<\/span><\/p>\n<p>There are oth\u00ader options, as for most <span class=\"caps\">MQ<\/span> com\u00admands, but this is enough for&nbsp;now.<\/p>\n<p>If there are no errors in the cre\u00adation of the new queue man\u00adag\u00ader, you should see the fol\u00adlow\u00ading output:<\/p>\n<div class=\"code-example\"><span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> queue man\u00adag\u00ader created.<br>\nDirec\u00adto\u00adry \u2018\/var\/mqm\/qmgrs\/<span class=\"caps\">QM1<\/span>\u2019 created.<br>\nThe queue man\u00adag\u00ader is asso\u00adci\u00adat\u00aded with instal\u00adla\u00adtion \u2018Installation1\u2019.<br>\nCre\u00adat\u00ading or replac\u00ading default objects for queue man\u00adag\u00ader \u2018<span class=\"caps\">QM1<\/span>\u2019.<br>\nDefault objects sta\u00adtis\u00adtics : 84 cre\u00adat\u00aded. 0 replaced. 0 failed.<br>\nCom\u00adplet\u00ading&nbsp;setup.<br>\nSet\u00adup completed.<\/div>\n<p>After cre\u00adat\u00ading the queue man\u00adag\u00ader, it must be run\u00adning before it can be configured.<\/p>\n<p class=\"code-example\">str\u00admqm&nbsp;<span class=\"caps\">QM1<\/span><\/p>\n<p>If every thing is <span class=\"caps\">OK<\/span>, you should see the output:<\/p>\n<p class=\"code-example\"><span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> queue man\u00adag\u00ader \u2018<span class=\"caps\">QM1<\/span>\u2019 starting.<br>\nThe queue man\u00adag\u00ader is asso\u00adci\u00adat\u00aded with instal\u00adla\u00adtion \u2018Installation1\u2019.<br>\n5 log records accessed on queue man\u00adag\u00ader \u2018<span class=\"caps\">QM1<\/span>\u2019 dur\u00ading the log replay<br>\nphase.<br>\nLog replay for queue man\u00adag\u00ader \u2018<span class=\"caps\">QM1<\/span>\u2019 complete.<br>\nTrans\u00adac\u00adtion man\u00adag\u00ader state recov\u00adered for queue man\u00adag\u00ader \u2018<span class=\"caps\">QM1<\/span>\u2019.<br>\n<span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> queue man\u00adag\u00ader \u2018<span class=\"caps\">QM1<\/span>\u2019 start\u00aded using <span class=\"caps\">V9<\/span>.1.0.0.<\/p>\n<p>After cre\u00adat\u00ading and start\u00ading our new queue man\u00adag\u00ader, we have to cre\u00adate queues for it to be use\u00adful. Oth\u00ader basic <span class=\"caps\">MQ<\/span> objects have to be cre\u00adat\u00aded in order for our appli\u00adca\u00adtions to be able to con\u00adnect to <span class=\"caps\">MQ<\/span>: at least one lis\u00adten\u00ader, which deter\u00admines which <span class=\"caps\">IP<\/span> address and <span class=\"caps\">TCP<\/span> port <span class=\"caps\">MQ<\/span> lis\u00adtens on, and one serv\u00ader con\u00adnec\u00adtion chan\u00adnel (I\u2019ll dis\u00adcuss <span class=\"caps\">MQ<\/span> chan\u00adnels in anoth\u00ader&nbsp;post).<\/p>\n<p>For now, because our queue man\u00adag\u00ader is \u201cemp\u00adty\u201d there is only one way to add objects to it, and that is with the <span style=\"font-family: terminal,monaco,monospace;\">run\u00admqsc<\/span> command.<\/p>\n<p class=\"code-example\">run\u00admqsc&nbsp;<span class=\"caps\">QM1<\/span><\/p>\n<p>First, define a listener<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">LISTENER<\/span>(<span class=\"caps\">LISTENER1<\/span>.<span class=\"caps\">TCP<\/span>) <span class=\"caps\">TRPTYPE<\/span>(<span class=\"caps\">TCP<\/span>) <span class=\"caps\">PORT<\/span>(1414)<\/p>\n<p>This tells <span class=\"caps\">MQ<\/span> to lis\u00adten on <span class=\"caps\">TCP<\/span> port 1414 (this is the default, by the way). Because we did\u00adn\u2019t spec\u00adi\u00adfy an <span class=\"caps\">IP<\/span> address, <span class=\"caps\">MQ<\/span> will lis\u00adten on all net\u00adwork interfaces.<\/p>\n<p>Then, define a serv\u00ader con\u00adnec\u00adtion chan\u00adnel (for appli\u00adca\u00adtions to con\u00adnect to&nbsp;<span class=\"caps\">MQ<\/span>):<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">CHANNEL<\/span>(<span class=\"caps\">CLNT<\/span>.<span class=\"caps\">APP<\/span>) <span class=\"caps\">CHLTYPE<\/span>(<span class=\"caps\">SVRCONN<\/span>)<\/p>\n<p>The <span class=\"caps\">SVRCONN<\/span> chan\u00adnel type is used by appli\u00adca\u00adtions to con\u00adnect remote\u00adly to&nbsp;<span class=\"caps\">MQ<\/span>.<\/p>\n<p>Now, for just a quick expla\u00adna\u00adtion about <span class=\"caps\">MQ<\/span> objects\u2019 nam\u00ading and commands.<\/p>\n<p><span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> con\u00adverts every\u00adthing to upper case, except what is enclosed in sin\u00adgle quotes. So<\/p>\n<p class=\"code-example\">define qlocal(queue1)<\/p>\n<p>is equiv\u00ada\u00adlent&nbsp;to<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QLOCAL<\/span>(<span class=\"caps\">QUEUE1<\/span>)<\/p>\n<p>Should you want to cre\u00adate a queue named queue1 (in low\u00ader case) you have to&nbsp;type<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QLOCAL<\/span>(\u2018queue1\u2019)<\/p>\n<p><span class=\"caps\">MQSC<\/span> com\u00admands can by typed in low\u00ader or upper case and some can be abbre\u00advi\u00adat\u00aded, such as <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">DEFINE<\/span><\/span> (<span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">DEF<\/span><\/span>), <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">DELETE<\/span><\/span> (<span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">DEL<\/span><\/span>) and <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">ALTER<\/span><\/span> (<span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">ALT<\/span><\/span>). Some options can also be abbre\u00advi\u00adat\u00aded, such as <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">QL<\/span><\/span> for <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">QLOCAL<\/span><\/span>. The above com\u00admand can, thus, be typed&nbsp;as<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEF<\/span> <span class=\"caps\">QL<\/span>(\u2018queue1\u2019)<\/p>\n<p>Now that we\u2019ve cre\u00adat\u00aded our first queue, it\u2019s about time we test\u00aded it. If you installed <span class=\"caps\">IBM<\/span> MQ\u2019s sam\u00adples (you did install them, did\u00adn\u2019t you?), we can use <span style=\"font-family: terminal, monaco, monospace;\">amqsput<\/span> and <span style=\"font-family: terminal, monaco, monospace;\">amqs\u00adget<\/span> sam\u00adples to test our new&nbsp;queue.<\/p>\n<p>Open a con\u00adnec\u00adtion to the <span class=\"caps\">MQ<\/span> serv\u00ader (<span class=\"caps\">SSH<\/span> or any oth\u00ader remote access method) and issue the following:<\/p>\n<p class=\"code-example\">\/opt\/mqm\/samp\/bin\/amqsput queue1 <span class=\"caps\">QM1<\/span><\/p>\n<p>Write some\u00adthing; every time you press Enter a new mes\u00adsage is cre\u00adat\u00aded in the&nbsp;queue.<\/p>\n<p class=\"code-example\">Hi<br>\nTest\u00ading\u2026 1\u2026 2\u2026&nbsp;3\u2026<br>\nLast message<\/p>\n<p>To exit, press Control\u2011D.<\/p>\n<p>Now, if you check the queue depth (with the <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">DISPLAY<\/span> <span class=\"caps\">QLOCAL<\/span>(\u2018queue1\u2019) <span class=\"caps\">CURDEPTH<\/span><\/span> com\u00admand), you\u2019ll notice it is now&nbsp;3:<\/p>\n<p class=\"code-example\">run\u00admqsc&nbsp;<span class=\"caps\">QM1<\/span><br>\n<span class=\"caps\">DISPLAY<\/span> <span class=\"caps\">QLOCAL<\/span>(\u2018queue1\u2019) <span class=\"caps\">CURDEPTH<\/span><br>\n1 : <span class=\"caps\">DISPLAY<\/span> <span class=\"caps\">QLOCAL<\/span>(\u2018queue1\u2019) <span class=\"caps\">CURDEPTH<\/span><br>\n<span class=\"caps\">AMQ8409I<\/span>: Dis\u00adplay Queue details.<br>\n<span class=\"caps\">QUEUE<\/span>(queue1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"caps\">TYPE<\/span>(<span class=\"caps\">QLOCAL<\/span>)<br>\n<span class=\"caps\">CURDEPTH<\/span>(3)<\/p>\n<p>Issue the <span style=\"font-family: terminal, monaco, monospace;\">amqs\u00adget<\/span>:<\/p>\n<p class=\"code-example\">\/opt\/mqm\/samp\/bin\/amqsget queue1 <span class=\"caps\">QM1<\/span><br>\nSam\u00adple <span class=\"caps\">AMQSGET0<\/span> start<br>\nmes\u00adsage &lt;Hi&gt;<br>\nmes\u00adsage &lt;Test\u00ading\u2026 1\u2026 2\u2026&nbsp;3\u2026&gt;<br>\nmes\u00adsage &lt;Last message&gt;<\/p>\n<p>If you check the queue again, you\u2019ll notice its depth is now 0 (zero):<\/p>\n<p class=\"code-example\">run\u00admqsc&nbsp;<span class=\"caps\">QM1<\/span><br>\n<span class=\"caps\">DISPLAY<\/span> <span class=\"caps\">QLOCAL<\/span>(\u2018queue1\u2019) <span class=\"caps\">CURDEPTH<\/span><br>\n1 : <span class=\"caps\">DISPLAY<\/span> <span class=\"caps\">QLOCAL<\/span>(\u2018queue1\u2019) <span class=\"caps\">CURDEPTH<\/span><br>\n<span class=\"caps\">AMQ8409I<\/span>: Dis\u00adplay Queue details.<br>\n<span class=\"caps\">QUEUE<\/span>(queue1)&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span class=\"caps\">TYPE<\/span>(<span class=\"caps\">QLOCAL<\/span>)<br>\n<span class=\"caps\">CURDEPTH<\/span>(0)<\/p>\n<p>That\u2019s all for now, folks! See you in the next install\u00adment of this arti\u00adcle series.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now that we\u2019ve installed <span class=\"caps\">MQ<\/span>, it\u2019s time to try it out. If you haven\u2019t read it, you can go to Installing <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> on Lin\u00adux to learn how to do&nbsp;it. In this arti\u00adcle, I\u2019ll show you the basics of <span class=\"caps\">IBM<\/span> \u2026 <a href=\"https:\/\/trindade.myphotos.cc\/lazysysadmin\/2019\/03\/05\/ibm-mq-basics\/\">Con\u00adtin\u00adue read\u00ading <span class=\"meta-nav\">\u2192<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":99,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[2,3],"tags":[10,12,4,8,6,13],"class_list":["post-71","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-middleware","category-mq","tag-ibm-mq","tag-ibmmq","tag-mq","tag-mqseries","tag-websphere-mq","tag-webspheremq"],"featured_image_src":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-content\/uploads\/sites\/7\/2019\/03\/IBM-MQ-Sticker.png","featured_image_src_square":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-content\/uploads\/sites\/7\/2019\/03\/IBM-MQ-Sticker.png","author_info":{"display_name":"Ant\u00f3nio Trindade","author_link":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/author\/trindade\/"},"_links":{"self":[{"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts\/71","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/comments?post=71"}],"version-history":[{"count":18,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts\/71\/revisions"}],"predecessor-version":[{"id":102,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts\/71\/revisions\/102"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/media\/99"}],"wp:attachment":[{"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/media?parent=71"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/categories?post=71"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/tags?post=71"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}