Add a plugin.stomp.priority option that will be used by recent
versions of ActiveMQ to prioritize our messages over others.

Signed-off-by: R.I.Pienaar <[email protected]>
---
Local-branch: feature/master/7246_stomp_priority
 plugins/mcollective/connector/stomp.rb       |   19 +++++++++++++++++--
 website/changelog.md                         |    1 +
 website/reference/plugins/connector_stomp.md |    9 +++++++++
 3 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/plugins/mcollective/connector/stomp.rb 
b/plugins/mcollective/connector/stomp.rb
index 17ef337..2806ed4 100644
--- a/plugins/mcollective/connector/stomp.rb
+++ b/plugins/mcollective/connector/stomp.rb
@@ -51,6 +51,13 @@ module MCollective
         #     plugin.stomp.pool.max_reconnect_attempts = 0
         #     plugin.stomp.pool.randomize = false
         #     plugin.stomp.pool.timeout = -1
+        #
+        # For versions of ActiveMQ that supports message priorities
+        # you can set a priority, this will cause a "priority" header
+        # to be emitted if present:
+        #
+        #     plugin.stomp.priority = 4
+        #
         class Stomp<Base
             attr_reader :connection
 
@@ -72,6 +79,7 @@ module MCollective
                     user = nil
                     password = nil
                     @base64 = get_bool_option("stomp.base64", false)
+                    @msgpriority = get_option("stomp.priority", 0).to_i
 
                     # Maintain backward compat for older stomps
                     unless @config.pluginconf.include?("stomp.pool.size")
@@ -144,9 +152,9 @@ module MCollective
 
                 # deal with deprecation warnings in newer stomp gems
                 if @connection.respond_to?("publish")
-                    @connection.publish(target, msg)
+                    @connection.publish(target, msg, msgheaders)
                 else
-                    @connection.send(target, msg)
+                    @connection.send(target, msg, msgheaders)
                 end
             end
 
@@ -173,6 +181,13 @@ module MCollective
             end
 
             private
+            def msgheaders
+                headers = {}
+                headers = {"priority" => @msgpriority} if @msgpriority > 0
+
+                return headers
+            end
+
             # looks in the environment first then in the config file
             # for a specific option, accepts an optional default.
             #
diff --git a/website/changelog.md b/website/changelog.md
index 2b09f71..9b4dff8 100644
--- a/website/changelog.md
+++ b/website/changelog.md
@@ -11,6 +11,7 @@ title: Changelog
 
 |Date|Description|Ticket|
 |----|-----------|------|
+|2011/05/01|Support setting a priority on Stomp messages|7246|
 |2011/04/30|Handle broken and incomplete DDLs better and improve the format of 
DDL output|7191|
 |2011/04/23|Encode the target agent and collective in requests|7223|
 |2011/04/20|Make the SSL Cipher used a config option|7191|
diff --git a/website/reference/plugins/connector_stomp.md 
b/website/reference/plugins/connector_stomp.md
index 752cd7d..96bec76 100644
--- a/website/reference/plugins/connector_stomp.md
+++ b/website/reference/plugins/connector_stomp.md
@@ -62,3 +62,12 @@ plugin.stomp.pool.max_reconnect_attempts = 0
 plugin.stomp.pool.randomize = false
 plugin.stomp.pool.timeout = -1
 {% endhighlight %}
+
+### Message Priority
+
+As of version 5.4 of ActiveMQ messages support priorities, you can pass in the 
needed
+priority header by setting:
+
+{% highlight ini %}
+plugin.stomp.priority = 4
+{% endhighlight %}
-- 
1.7.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to