{"id":120,"date":"2019-07-12T15:20:58","date_gmt":"2019-07-12T15:20:58","guid":{"rendered":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/?p=120"},"modified":"2024-07-05T11:40:40","modified_gmt":"2024-07-05T10:40:40","slug":"ibm-mq-basics-publish-and-subscribe","status":"publish","type":"post","link":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/2019\/07\/12\/ibm-mq-basics-publish-and-subscribe\/","title":{"rendered":"<span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> basics: publish and subscribe"},"content":{"rendered":"<p>In the first three arti\u00adcles of this series, I intro\u00adduced you to <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> and its basic func\u00adtion\u00adal\u00adi\u00adties (queues, local and remote, chan\u00adnels and listeners).<\/p>\n<p>This time, I\u2019ll start com\u00adpli\u00adcat\u00ading things a bit. This time I\u2019ll write about the pub\u00adlish and sub\u00adscribe fea\u00adture of <span class=\"caps\">IBM<\/span>&nbsp;<span class=\"caps\">MQ<\/span>.<\/p>\n<p><!--more--><\/p>\n<h2>Overview<\/h2>\n<p>Sup\u00adpose you have some data that is pro\u00adduced by one appli\u00adca\u00adtion and want to have that data processed by two dif\u00adfer\u00adent appli\u00adca\u00adtions. It would be high\u00adly inef\u00adfi\u00adcient to have that data pro\u00adduced twice or copied by oth\u00ader&nbsp;means.<\/p>\n<p>Using MQ\u2019s pub\u00adlish and sub\u00adscribe func\u00adtion\u00adal\u00adi\u00adty it is pos\u00adsi\u00adble to have the same data sent to one or more des\u00adti\u00adna\u00adtions, which, in <span class=\"caps\">MQ<\/span>, means any object which you can write to (local, alias or remote queues, etc.).<\/p>\n<p>In the\u00ado\u00adry, it works like this: you cre\u00adate a top\u00adic object, then an alias queue spec\u00adi\u00adfy\u00ading its tar\u00adget as the top\u00adic pre\u00advi\u00adous\u00adly cre\u00adat\u00aded. Final\u00adly, you cre\u00adate as many sub\u00adscrip\u00adtions as you want\/need.<\/p>\n<h2>Putting all together<\/h2>\n<p>In the fol\u00adlow\u00ading exam\u00adple, I\u2019ll show how to con\u00adfig\u00adure <span class=\"caps\">MQ<\/span> so that mes\u00adsages sent to an alias queue get writ\u00adten in two dif\u00adfer\u00adent local queues.<\/p>\n<p>First\u00adly, cre\u00adate two local queues.<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QLOCAL<\/span>(<span class=\"caps\">Q1<\/span>.R) <span class=\"caps\">DEFPSIST<\/span>(<span class=\"caps\">YES<\/span>) <span class=\"caps\">MAXDEPTH<\/span>(5000) <span class=\"caps\">REPLACE<\/span><br>\n<span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QLOCAL<\/span>(<span class=\"caps\">Q2<\/span>.R) <span class=\"caps\">DEFPSIST<\/span>(<span class=\"caps\">YES<\/span>) <span class=\"caps\">MAXDEPTH<\/span>(5000) <span class=\"caps\">REPLACE<\/span><\/p>\n<p>Then cre\u00adate a top\u00adic, an alias queue and two subscriptions.<\/p>\n<p class=\"code-example\"><span class=\"caps\">DEFINE<\/span> <span class=\"caps\">TOPIC<\/span>(<span class=\"caps\">TOPIC1<\/span>.T) <span class=\"caps\">TOPICSTR<\/span>(<span class=\"caps\">TOPIC1<\/span>.T) <span class=\"caps\">REPLACE<\/span><br>\n<span class=\"caps\">DEFINE<\/span> <span class=\"caps\">QALIAS<\/span>(<span class=\"caps\">Q1<\/span>.A) <span class=\"caps\">TARGET<\/span>(<span class=\"caps\">TOPIC1<\/span>.T) <span class=\"caps\">TARGTYPE<\/span>(<span class=\"caps\">TOPIC<\/span>) <span class=\"caps\">DEFPSIST<\/span>(<span class=\"caps\">YES<\/span>) <span class=\"caps\">REPLACE<\/span><br>\n<span class=\"caps\">DEFINE<\/span> <span class=\"caps\">SUB<\/span>(<span class=\"caps\">SUB1<\/span>.S) <span class=\"caps\">TOPICSTR<\/span>(<span class=\"caps\">TOPIC1<\/span>.T) <span class=\"caps\">DEST<\/span>(<span class=\"caps\">Q1<\/span>.R) <span class=\"caps\">REPLACE<\/span><br>\n<span class=\"caps\">DEFINE<\/span> <span class=\"caps\">SUB<\/span>(<span class=\"caps\">SUB2<\/span>.S) <span class=\"caps\">TOPICSTR<\/span>(<span class=\"caps\">TOPIC1<\/span>.T) <span class=\"caps\">DEST<\/span>(<span class=\"caps\">Q2<\/span>.R) <span class=\"caps\">REPLACE<\/span><\/p>\n<p>After this, any mes\u00adsage that is put in the alias queue <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">Q1<\/span>.A<\/span> gets sent to both <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">Q1<\/span>.R<\/span> and <span style=\"font-family: terminal, monaco, monospace;\"><span class=\"caps\">Q2<\/span>.R<\/span> local queues.<\/p>\n<p>Instead of local queues, the sub\u00adscrip\u00adtions\u2019 des\u00adti\u00adna\u00adtions can also be remote queues or oth\u00ader alias queues.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the first three arti\u00adcles of this series, I intro\u00adduced you to <span class=\"caps\">IBM<\/span> <span class=\"caps\">MQ<\/span> and its basic func\u00adtion\u00adal\u00adi\u00adties (queues, local and remote, chan\u00adnels and lis\u00adten\u00aders). This time, I\u2019ll start com\u00adpli\u00adcat\u00ading things a bit. This time I\u2019ll write about the pub\u00adlish \u2026 <a href=\"https:\/\/trindade.myphotos.cc\/lazysysadmin\/2019\/07\/12\/ibm-mq-basics-publish-and-subscribe\/\">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":[1],"tags":[],"class_list":["post-120","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"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\/120","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=120"}],"version-history":[{"count":4,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":137,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/posts\/120\/revisions\/137"}],"wp:attachment":[{"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/media?parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/categories?post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trindade.myphotos.cc\/lazysysadmin\/wp-json\/wp\/v2\/tags?post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}