{"id":263,"date":"2018-04-20T12:20:20","date_gmt":"2018-04-20T11:20:20","guid":{"rendered":"https:\/\/www.cogin.com\/blog\/?p=263"},"modified":"2018-04-26T10:41:13","modified_gmt":"2018-04-26T09:41:13","slug":"policies-rabbitmq-for-msmq-users-part-4","status":"publish","type":"post","link":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/","title":{"rendered":"Policies &#8211; RabbitMQ for MSMQ users, part 4"},"content":{"rendered":"<h2>What is RabbitMQ policy?<\/h2>\n<p>Policy is a way to centralize management of queue properties. It&#8217;s common that queues which are used for similar things have the same configuration. For example, they could have same &#8220;time to live&#8221;, or deadletter settings. Instead of setting up the same list of settings for each queue, which is time-consuming and error-prone, you can create a policy which contains all these mutual settings, and then apply it to a set of queues. That way settings are defined in one place and shared where needed.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-315\" src=\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png\" alt=\"\" width=\"451\" height=\"422\" srcset=\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png 451w, https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation-300x281.png 300w\" sizes=\"auto, (max-width: 451px) 100vw, 451px\" \/><\/p>\n<p>If queue has some argument set, it has higher priority and\u00a0overrides\u00a0what&#8217;s configured in a\u00a0policy.<\/p>\n<p>Btw. policies can be also applied to exchanges, but since they work the same way we won&#8217;t discuss that separately.<\/p>\n<h2>You can\u2019t reconfigure queues or exchanges<\/h2>\n<p>In RabbitMQ, you can\u2019t change any property of queue or exchange once it\u2019s created. The only things you can edit are bindings. So if you need to change anything else, you\u2019ll have to delete existing object and create a new one. That\u2019s problematic if object is in use, with messages flowing in and out. However, policies are editable. If queue settings are configured through a policy, they can be changed.<\/p>\n<h2>Choosing queues where policy is applied<\/h2>\n<p>Unfortunately, RabbitMQ doesn\u2019t offer you to go to a queue and say \u201cI want this policy to apply to this queue\u201d. Instead, you have to go to a policy and enter a <i>regular expression pattern.<\/i> Policy is then applied to all queues which name matches that patter. Since it\u2019s kind of awkward to create a regular expression to match arbitrary queue names, it helps if your queues have structured names, like \u201corder.incoming\u201d, \u201corder.errors\u201d, etc. or something similar which is easier to match. It&#8217;s easier to set up a pattern\u00a0which would apply to all &#8220;.error&#8221; queues.<\/p>\n<p><a href=\"https:\/\/www.cogin.com\/mq\/\">QueueExplorer<\/a> allows you to see which policy and which settings from it will be applied to a queue:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-316\" src=\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-for-queue.png\" alt=\"\" width=\"829\" height=\"398\" srcset=\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-for-queue.png 829w, https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-for-queue-300x144.png 300w, https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-for-queue-768x369.png 768w\" sizes=\"auto, (max-width: 829px) 100vw, 829px\" \/><\/p>\n<h2>Conflicting policies<\/h2>\n<p>Only one policy can be applied to a single queue. That&#8217;s why policies have priorities. If you have two or more policies whose patterns match the\u00a0same queue, the one with higher &#8220;priority&#8221; will be used. If policies have the same\u00a0priority, RabbitMQ will choose one nondeterministically, i.e. more or less random, so that&#8217;s not something we should ever rely on.<\/p>\n<h2>Operator policies<\/h2>\n<p>There are some cases where an administrator would want to override some of the settings from regular policies. Operator policies offer a way to do that, but only for following arguments:<\/p>\n<ul>\n<li>expires<\/li>\n<li>message-ttl<\/li>\n<li>max-length<\/li>\n<li>max-length-bytes<\/li>\n<\/ul>\n<p>Important difference is that operator policy is merged with a regular policy\u00a0if there\u2019s any. If there\u2019s the same argument defined in both regular and operator policy, a <b>smaller value<\/b> is used. That can work since all of these 4 applicable settings are numeric. That also means that operator policy can be used to make some of these arguments lower, but not higher than specified elsewhere.<\/p>\n<p>In the <a href=\"https:\/\/www.cogin.com\/blog\/rabbitmq\/distributed-brokers-rabbitmq-for-msmq-users-part-5\/\">next part<\/a> we&#8217;ll talk about distributed brokers.<\/p>\n<p><a href=\"https:\/\/www.cogin.com\/articles\/Introduction-to-RabbitMQ-for-MSMQ-users.php\">Links to all 6 parts<\/a> of this series.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>What is RabbitMQ policy? Policy is a way to centralize management of queue properties. It&#8217;s common that queues which are used for similar things have the same configuration. For example, they could have same &#8220;time to live&#8221;, or deadletter settings. Instead of setting up the same list of settings for each queue, which is time-consuming [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,12],"tags":[5,13],"class_list":["post-263","post","type-post","status-publish","format-standard","hentry","category-msmq","category-rabbitmq","tag-msmq","tag-rabbitmq"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Policies - RabbitMQ for MSMQ users, part 4<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Policies - RabbitMQ for MSMQ users, part 4\" \/>\n<meta property=\"og:description\" content=\"What is RabbitMQ policy? Policy is a way to centralize management of queue properties. It&#8217;s common that queues which are used for similar things have the same configuration. For example, they could have same &#8220;time to live&#8221;, or deadletter settings. Instead of setting up the same list of settings for each queue, which is time-consuming [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/\" \/>\n<meta property=\"og:site_name\" content=\"Cogin blog\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-20T11:20:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-04-26T09:41:13+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png\" \/>\n<meta name=\"author\" content=\"Dejan Grujic\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dejan Grujic\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/\",\"url\":\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/\",\"name\":\"Policies - RabbitMQ for MSMQ users, part 4\",\"isPartOf\":{\"@id\":\"https:\/\/www.cogin.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png\",\"datePublished\":\"2018-04-20T11:20:20+00:00\",\"dateModified\":\"2018-04-26T09:41:13+00:00\",\"author\":{\"@id\":\"https:\/\/www.cogin.com\/blog\/#\/schema\/person\/e0c4fd92043868daa052d5978d69ed22\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#primaryimage\",\"url\":\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png\",\"contentUrl\":\"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png\",\"width\":451,\"height\":422},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.cogin.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Policies &#8211; RabbitMQ for MSMQ users, part 4\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.cogin.com\/blog\/#website\",\"url\":\"https:\/\/www.cogin.com\/blog\/\",\"name\":\"Cogin blog\",\"description\":\"Queuing tools and articles\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.cogin.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.cogin.com\/blog\/#\/schema\/person\/e0c4fd92043868daa052d5978d69ed22\",\"name\":\"Dejan Grujic\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.cogin.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e0bf2f4ab23ef7c6f2784ae50708b926?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e0bf2f4ab23ef7c6f2784ae50708b926?s=96&d=mm&r=g\",\"caption\":\"Dejan Grujic\"},\"sameAs\":[\"http:\/\/www.cogin.com\"],\"url\":\"https:\/\/www.cogin.com\/blog\/author\/gruja\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Policies - RabbitMQ for MSMQ users, part 4","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/","og_locale":"en_US","og_type":"article","og_title":"Policies - RabbitMQ for MSMQ users, part 4","og_description":"What is RabbitMQ policy? Policy is a way to centralize management of queue properties. It&#8217;s common that queues which are used for similar things have the same configuration. For example, they could have same &#8220;time to live&#8221;, or deadletter settings. Instead of setting up the same list of settings for each queue, which is time-consuming [&hellip;]","og_url":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/","og_site_name":"Cogin blog","article_published_time":"2018-04-20T11:20:20+00:00","article_modified_time":"2018-04-26T09:41:13+00:00","og_image":[{"url":"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png"}],"author":"Dejan Grujic","twitter_misc":{"Written by":"Dejan Grujic","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/","url":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/","name":"Policies - RabbitMQ for MSMQ users, part 4","isPartOf":{"@id":"https:\/\/www.cogin.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#primaryimage"},"image":{"@id":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#primaryimage"},"thumbnailUrl":"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png","datePublished":"2018-04-20T11:20:20+00:00","dateModified":"2018-04-26T09:41:13+00:00","author":{"@id":"https:\/\/www.cogin.com\/blog\/#\/schema\/person\/e0c4fd92043868daa052d5978d69ed22"},"breadcrumb":{"@id":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#primaryimage","url":"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png","contentUrl":"https:\/\/www.cogin.com\/blog\/wp-content\/uploads\/2018\/04\/Policy-creation.png","width":451,"height":422},{"@type":"BreadcrumbList","@id":"https:\/\/www.cogin.com\/blog\/rabbitmq\/policies-rabbitmq-for-msmq-users-part-4\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.cogin.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Policies &#8211; RabbitMQ for MSMQ users, part 4"}]},{"@type":"WebSite","@id":"https:\/\/www.cogin.com\/blog\/#website","url":"https:\/\/www.cogin.com\/blog\/","name":"Cogin blog","description":"Queuing tools and articles","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.cogin.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.cogin.com\/blog\/#\/schema\/person\/e0c4fd92043868daa052d5978d69ed22","name":"Dejan Grujic","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.cogin.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e0bf2f4ab23ef7c6f2784ae50708b926?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e0bf2f4ab23ef7c6f2784ae50708b926?s=96&d=mm&r=g","caption":"Dejan Grujic"},"sameAs":["http:\/\/www.cogin.com"],"url":"https:\/\/www.cogin.com\/blog\/author\/gruja\/"}]}},"_links":{"self":[{"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/posts\/263","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/comments?post=263"}],"version-history":[{"count":5,"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"predecessor-version":[{"id":350,"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/posts\/263\/revisions\/350"}],"wp:attachment":[{"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cogin.com\/blog\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}