{"id":103,"date":"2019-04-14T21:39:25","date_gmt":"2019-04-14T21:39:25","guid":{"rendered":"http:\/\/trindade.myphotos.cc\/lazysysadmin\/?p=103"},"modified":"2024-07-05T11:40:40","modified_gmt":"2024-07-05T10:40:40","slug":"ibm-mq-basics-remote-queues-and-channels","status":"publish","type":"post","link":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/2019\/04\/14\/ibm-mq-basics-remote-queues-and-channels\/","title":{"rendered":"<span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> basics: remote queues and channels"},"content":{"rendered":"<p>In the first install\u00adment of the <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> Basics, avail\u00adable <a href=\"https:\/\/trindade.myphotos.cc\/lazysysadmin\/ibm-mq-basics\/\">here<\/a>, I showed you basic queue cre\u00adation and&nbsp;usage.<\/p>\n<p>If <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> would only allow local queues to be cre\u00adat\u00aded and used, it would be less use\u00adful. One of the strengths of <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> is the abil\u00adi\u00adty to link two or more queue man\u00adagers and send mes\u00adsages to anoth\u00ader queue manager.<\/p>\n<p>In this arti\u00adcle, I\u2019m going to show you how to link two queue man\u00adagers using a remote queues and channels.<\/p>\n<p><!--more--><\/p>\n<p>First of all, you need two dif\u00adfer\u00adent queue man\u00adagers. It does\u00adn\u2019t mat\u00adter if they are in the same machine. I\u2019m using two machines (actu\u00adal\u00adly, two vir\u00adtu\u00adal machines in my work machine, but the end result is absolute\u00adly the&nbsp;same).<\/p>\n<p>I\u2019m using the same queue man\u00adag\u00ader that I con\u00adfig\u00adured in the last arti\u00adcle of this series and anoth\u00ader one, named <span class=\"caps\">QM2<\/span>, with the same con\u00adfig\u00adu\u00adra\u00adtion, that is, a lis\u00adten\u00ader named <span class=\"caps\">LISTENER<\/span>.<span class=\"caps\">TCP<\/span>, with trans\u00adport type (<span class=\"caps\">TRPTYPE<\/span>) <span class=\"caps\">TCP<\/span>, lis\u00adte\u00adnen\u00ading on port 1414 and a chan\u00adnel for admin\u00adis\u00adtra\u00adtion pur\u00adpos\u00ades of type serv\u00ader con\u00adnec\u00adtion (<span class=\"caps\">SVRCONN<\/span>) name <span class=\"caps\">CLNT<\/span>.<span class=\"caps\">ADM<\/span>.<\/p>\n<h2>Remote queues<\/h2>\n<p>A remote queue is a queue like any oth\u00ader, with a few notable exceptions:<\/p>\n<ul>\n<li>it is impos\u00adsi\u00adble to read from; it can only be writ\u00adten&nbsp;to;<\/li>\n<li>it refers to anoth\u00ader queue (remote, local, or alias) in anoth\u00ader queue manager;<\/li>\n<li>it does not occu\u00adpy any hard disk space, except for the space need\u00aded to store its definition;<\/li>\n<li>you can (and should) spec\u00adi\u00adfy a trans\u00admis\u00adsion queue (more on this type of queue&nbsp;later);<\/li>\n<\/ul>\n<h2>Channels and channel types<\/h2>\n<p>Com\u00admu\u00adni\u00adca\u00adtion between queue man\u00adagers and between clients and queue man\u00adagers is always done using channels.<\/p>\n<p>Chan\u00adnels\u2019 names can be at most 21 char\u00adac\u00adters&nbsp;long.<\/p>\n<p>We\u2019ve already talked about one type of chan\u00adnel (the <span class=\"caps\">SVRCONN<\/span> type). The serv\u00ader-con\u00adnec\u00adtion chan\u00adnel is used for com\u00admu\u00adni\u00adcat\u00ading between <span class=\"caps\">MQ<\/span> client appli\u00adca\u00adtions and a queue manager.<\/p>\n<p>The oth\u00ader two types of chan\u00adnels I am going to talk about now are the sender chan\u00adnel (<span class=\"caps\">SDR<\/span>) and receiv\u00ader chan\u00adnel (<span class=\"caps\">RCVR<\/span>) types.<\/p>\n<p>As their name implies, the receiv\u00ader chan\u00adnel is used as the receiv\u00ading end of a sender chan\u00adnel. So, they always come in&nbsp;pairs.<\/p>\n<p>The sender and receiv\u00ader chan\u00adnels must have the same name. That\u2019s how a send\u00ading queue man\u00adag\u00ader iden\u00adti\u00adfies the receiv\u00ading&nbsp;end.<\/p>\n<h2>Transmission queues<\/h2>\n<p>Final\u00adly, one must define a trans\u00admis\u00adsion queue before cre\u00adat\u00ading a sender channel.<\/p>\n<p>This is a spe\u00adcial type of local queue (you can write to and read from it, although it is not advis\u00adable) that serves as a tem\u00adpo\u00adrary mes\u00adsage store for mes\u00adsages being sent to a remote queue man\u00adag\u00ader. If, for exam\u00adple, the remote queue man\u00adag\u00ader is down for some rea\u00adson or the net\u00adwork con\u00adnec\u00adtion between the two queue man\u00adagers is not avail\u00adable, the send\u00ading queue man\u00adag\u00ader stores the mes\u00adsages des\u00adtined to the remote one in this type of&nbsp;queue.<\/p>\n<p>For each sender chan\u00adnel you need cre\u00adate a trans\u00admis\u00adsion&nbsp;queue.<\/p>\n<h2>Putting it all together<\/h2>\n<h3>Configuring <span class=\"caps\">QM1<\/span><\/h3>\n<p>Ok. Let \u2018s&nbsp;start.<\/p>\n<p>In the fol\u00adlow\u00ading exam\u00adple, I\u2019m going to cre\u00adate a remote queue in the <span class=\"caps\">QM1<\/span> queue man\u00adag\u00ader that refers to a local queue in the <span class=\"caps\">QM2<\/span> queue manager.<\/p>\n<p>Begin\u00adning with the <span class=\"caps\">QM1<\/span> queue manager.<\/p>\n<p>First, cre\u00adate a trans\u00admis\u00adsion&nbsp;queue:<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QLOCAL<\/span>(\u2018<span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>.X\u2019) <span class=\"caps\">USAGE<\/span>(<span class=\"caps\">XMITQ<\/span>) <span class=\"caps\">TRIGGER<\/span> <span class=\"caps\">TRIGDATA<\/span>(<span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>) <span class=\"caps\">TRIGTYPE<\/span>(<span class=\"caps\">FIRST<\/span>)<\/p>\n<p>This com\u00admand defines some\u00adthing not dis\u00adcussed above: trig\u00adger\u00ading. For now, let me just say that the last three options enables auto start\u00ading the chan\u00adnel named <span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span> when a mes\u00adsage is placed in the <span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>.XmitQ trans\u00admis\u00adsion&nbsp;queue.<\/p>\n<p>Next, we need to cre\u00adate a sender channel:<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">CHANNEL<\/span>(<span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>) <span class=\"caps\">CHLTYPE<\/span>(<span class=\"caps\">SDR<\/span>) <span class=\"caps\">CONNAME<\/span>(\u2018mq2(1414)\u2019) <span class=\"caps\">XMITQ<\/span>(\u2018<span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>.X\u2019)<\/p>\n<p>This com\u00admand defines a sender chan\u00adnel named <span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span> to host mq2, <span class=\"caps\">TCP<\/span> port 1414 that uses the <span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>.XmitQ trans\u00admis\u00adsion&nbsp;queue.<\/p>\n<p>Final\u00adly, to wrap the con\u00adfig\u00adu\u00adra\u00adtions in the <span class=\"caps\">QM1<\/span> queue man\u00adag\u00ader, define the <span class=\"caps\">Q2<\/span>.W remote queue:<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QREMOTE<\/span>(<span class=\"caps\">Q2<\/span>.W) <span class=\"caps\">RQMNAME<\/span>(<span class=\"caps\">QM2<\/span>) <span class=\"caps\">RNAME<\/span>(<span class=\"caps\">Q2<\/span>.R) <span class=\"caps\">XMITQ<\/span>(\u2018<span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>.X\u2019)<\/p>\n<p>This remote queue def\u00adi\u00adn\u00adi\u00adtion has a con\u00adfig\u00adu\u00adra\u00adtion option which is not wide\u00adly used: the option <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">XMITQ<\/span><\/span>. This option allows you to choose the sender chan\u00adnel which will be used by this remote queue by spec\u00adi\u00adfy\u00ading its trans\u00admis\u00adsion queue. If you do not spec\u00adi\u00adfy the trans\u00admis\u00adsion queue used by a remote one, the queue man\u00adag\u00ader will choose an appro\u00adpri\u00adate chan\u00adnel to send your mes\u00adsages through.<\/p>\n<h3>Configuring <span class=\"caps\">QM2<\/span><\/h3>\n<p>The con\u00adfig\u00adu\u00adra\u00adtion for the <span class=\"caps\">QM2<\/span> queue man\u00adag\u00ader is very simple.<\/p>\n<p>First, define a local queue with the name of the <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">RNAME<\/span><\/span> option of the remote queue you cre\u00adat\u00aded in <span class=\"caps\">QM1<\/span> (<span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">Q2<\/span>.R<\/span>).<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QLOCAL<\/span>(<span class=\"caps\">Q2<\/span>.R)<\/p>\n<p>Final\u00adly, define a receiv\u00ader chan\u00adnel with the same name of the sender chan\u00adnel defined in the <span class=\"caps\">QM1<\/span> queue manager.<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">CHANNEL<\/span>(<span class=\"caps\">TO<\/span>.<span class=\"caps\">QM2<\/span>) <span class=\"caps\">CHLTYPE<\/span>(<span class=\"caps\">RCVR<\/span>)<\/p>\n<h2>Testing<\/h2>\n<p>In the mq1 machine run the fol\u00adlow\u00ading command<\/p>\n<p class=\"code-example\">~$ \/opt\/mqm\/samp\/bin\/amqsput <span class=\"caps\">Q2<\/span>.W&nbsp;<span class=\"caps\">QM1<\/span><br>\nSam\u00adple <span class=\"caps\">AMQSPUT0<\/span> start<br>\ntar\u00adget queue is <span class=\"caps\">Q2<\/span>.W<br>\nHel\u00adlo,&nbsp;World!<br>\nend<br>\nEnd of messages<br>\nSam\u00adple <span class=\"caps\">AMQSPUT0<\/span> end<\/p>\n<p>And, in the mq2 machine:<\/p>\n<p class=\"code-example\">~$ \/opt\/mqm\/samp\/bin\/amqsget <span class=\"caps\">Q2<\/span>.R&nbsp;<span class=\"caps\">QM2<\/span><br>\nSam\u00adple <span class=\"caps\">AMQSGET0<\/span> start<br>\nmes\u00adsage &lt;Hel\u00adlo,&nbsp;World!&gt;<br>\nmes\u00adsage &lt;end&gt;<br>\nmes\u00adsage &lt;End of messages&gt;<br>\n^C<\/p>\n<p>That\u2019s a&nbsp;wrap.<\/p>\n<p>Stay tuned. In the next post, I\u2019ll be talk\u00ading about the publish\/subscribe feature.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the first install\u00adment of the <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> Basics, avail\u00adable here, I showed you basic queue cre\u00adation and&nbsp;usage. If <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> would only allow local queues to be cre\u00adat\u00aded and used, it would be less use\u00adful. One of the strengths \u2026 <a href=\"https:\/\/trindade.myphotos.cc\/lazysysadmin\/2019\/04\/14\/ibm-mq-basics-remote-queues-and-channels\/\">Con\u00adtin\u00adue read\u00ading <span class=\"meta-nav\">\u2192<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[3],"tags":[10,12,9,4,8,6,13],"class_list":["post-103","post","type-post","status-publish","format-standard","hentry","category-mq","tag-ibm-mq","tag-ibmmq","tag-middleware","tag-mq","tag-mqseries","tag-websphere-mq","tag-webspheremq"],"featured_image_src":null,"featured_image_src_square":null,"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\/103","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=103"}],"version-history":[{"count":7,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts\/103\/revisions"}],"predecessor-version":[{"id":119,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts\/103\/revisions\/119"}],"wp:attachment":[{"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/media?parent=103"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/categories?post=103"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/tags?post=103"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}