Class MCollective::Connector::Activemq
In: lib/mcollective/connector/activemq.rb
Parent: Base

Handles sending and receiving messages over the Stomp protocol for ActiveMQ servers specifically, we take advantages of ActiveMQ specific features and enhancements to the Stomp protocol. For best results in a clustered environment use ActiveMQ 5.5.0 at least.

This plugin takes an entirely different approach to dealing with ActiveMQ from the more generic stomp connector.

 - Agents use /topic/<collective>.<agent>.agent
 - Replies use temp-topics so they are private and transient.
 - Point to Point messages using topics are supported by subscribing to
   /queue/<collective>.nodes with a selector "mc_identity = 'identity'

The use of temp-topics for the replies is a huge improvement over the old style. In the old way all clients got replies for all clients that were active at that time, this would mean that they would need to decrypt, validate etc in order to determine if they need to ignore the message, this was computationally expensive and on large busy networks the messages were being sent all over the show cross broker boundaries.

The new way means the messages go point2point back to only whoever requested the message, they only get their own replies and this is ap private channel that casual observers cannot just snoop into.

This plugin supports 1.1.6 and newer of the Stomp rubygem.

   connector = activemq
   plugin.activemq.pool.size = 2

   plugin.activemq.pool.1.host = stomp1.your.net
   plugin.activemq.pool.1.port = 61613
   plugin.activemq.pool.1.user = you
   plugin.activemq.pool.1.password = secret
   plugin.activemq.pool.1.ssl = true
   plugin.activemq.pool.1.ssl.cert = /path/to/your.cert
   plugin.activemq.pool.1.ssl.key = /path/to/your.key
   plugin.activemq.pool.1.ssl.ca = /path/to/your.ca
   plugin.activemq.pool.1.ssl.fallback = true
   plugin.activemq.pool.1.ssl.ciphers = TLSv1:!MD5:!LOW:!EXPORT

   plugin.activemq.pool.2.host = stomp2.your.net
   plugin.activemq.pool.2.port = 61613
   plugin.activemq.pool.2.user = you
   plugin.activemq.pool.2.password = secret
   plugin.activemq.pool.2.ssl = false

Using this method you can supply just STOMP_USER and STOMP_PASSWORD. The port will default to 61613 if not specified.

The ssl options are only usable in version of the Stomp gem newer than 1.2.2 where these will imply full SSL validation will be done and you‘ll only be able to connect to a ActiveMQ server that has a cert signed by the same CA. If you only set ssl = true and do not supply the cert, key and ca properties or if you have an older gem it will fall back to unverified mode only if ssl.fallback is true

In addition you can set the following options for the rubygem:

    plugin.activemq.initial_reconnect_delay = 0.01
    plugin.activemq.max_reconnect_delay = 30.0
    plugin.activemq.use_exponential_back_off = true
    plugin.activemq.back_off_multiplier = 2
    plugin.activemq.max_reconnect_attempts = 0
    plugin.activemq.randomize = false
    plugin.activemq.timeout = -1

You can set the initial connetion timeout - this is when your stomp server is simply unreachable - after which it would failover to the next in the pool:

    plugin.activemq.connect_timeout = 30

ActiveMQ JMS message priorities can be set:

    plugin.activemq.priority = 4

This plugin supports Stomp protocol 1.1 when combined with the stomp gem version 1.2.10 or newer. To enable network heartbeats which will help keep the connection alive over NAT connections and aggresive session tracking firewalls you can set:

    plugin.activemq.heartbeat_interval = 30

which will cause a heartbeat to be sent on 30 second intervals and one to be expected from the broker every 30 seconds. The shortest supported period is 30 seconds, if you set it lower it will get forced to 30 seconds.

After 2 failures to receive a heartbeat the connection will be reset via the normal failover mechanism.

By default if heartbeat_interval is set it will request Stomp 1.1 but support fallback to 1.0, but you can enable strict Stomp 1.1 only operation

    plugin.activemq.stomp_1_0_fallback = 0

Methods

Classes and Modules

Class MCollective::Connector::Activemq::DummyError
Class MCollective::Connector::Activemq::EventLogger

Constants

Error = DummyError unless defined?(::Stomp::Error)
NoCurrentConnection = DummyError unless defined?(::Stomp::Error::NoCurrentConnection)
DuplicateSubscription = DummyError unless defined?(::Stomp::Error::DuplicateSubscription)

Attributes

connection  [R] 

Public Class methods

Public Instance methods

Connects to the ActiveMQ middleware

Disconnects from the ActiveMQ connection

Calculate the exponential backoff needed

looks up a boolean value in the config

Returns the name of the certficate file used by ActiveMQ Will first check if an environment variable MCOLLECTIVE_ACTIVEMQ_POOLX_SSL_CERT exists, where X is the ActiveMQ pool number. If the environment variable doesn‘t exist, it will try and load the value from the config.

looks in the environment first then in the config file for a specific option, accepts an optional default.

raises an exception when it cant find a value anywhere

Returns the name of the private key file used by ActiveMQ Will first check if an environment variable MCOLLECTIVE_ACTIVEMQ_POOLX_SSL_KEY exists, where X is the ActiveMQ pool number. If the environment variable doesn‘t exist, it will try and load the value from the config.

looks for a config option, accepts an optional default

raises an exception when it cant find a value anywhere

Sends a message to the ActiveMQ connection

Receives a message from the ActiveMQ connection

Sets the SSL paramaters for a specific connection

Subscribe to a topic or queue

UnSubscribe to a topic or queue

[Validate]