Configuring RabbitMQ instances

RabbitMQ configuration can be established in several ways:

  • By setting proper environment variables
  • By modifying the RabbitMQ configuration file
  • By defining runtime parameters and policies that can be modified at runtime

Setting environment variables

Environment variables can be set using a standard mechanism provided by your OS (for example, using the Control Panel in Windows or setting them permanently from the shell in Linux). However they can also be specified in the scripts used to run the RabbitMQ broker, such as the rabbitmq-server utility, the rabbitmq-service utility (used in Windows to start RabbitMQ as a Windows service), or rabbitmq-env.conf (using in Unix-like operating systems by RabbitMQ to configure environment variables). At the beginning of the chapter we covered several such variables related to the location of the RabbitMQ database, logs, and configuration file. Here are several more you can configure:

  • RABBITMQ_NODE_IP_ADDRESS: The IP address of network interface to which you want to bind the RabbitMQ broker. This is useful if you have multiple such interfaces on the machine where the broker is installed and you want to bind it to only one of them (an empty value means that the broker is bound to all network interface addresses).
  • RABBITMQ_NODE_PORT: The port on which the RabbitMQ broker listens.
  • RABBITMQ_NODENAME: The name of the RabbitMQ broker instance (this is required in a clustered configuration—more on that in the next chapter).
  • RABBITMQ_SERVICENAME: The name of the Windows service for the RabbitMQ broker instance.

Modifying the RabbitMQ configuration file

The rabbitmq configuration file (rabbitqm.config) can be used to provide additional configuration of the broker, such as how much RAM the broker is allowed to consume before messages are flushed to the hard disk (vm_memory_high_watermark); what IP addresses and ports of the network interfaces the broker listens on (tcp_listeners); or what the maximum file size is of the RabbitMQ message stores— both transient and persistent (msg_store_file_size_limit). If that limit is exceeded then messages are garbage-collected. The default location for rabbitmq.config is under the %RABBITMQ_BASE% directory; if RabbitMQ is not specified under Windows the default location of the file will be under %APPDATA%. There is a sample configuration file in the etc directory for the installation of the RabbitMQ server. If you copy it and save it under the root installation directory of RabbitMQ with the name rabbitmq.config, you can simply uncomment and change the various configuration parameters based on your preferences. Here is a sample configuration that sets limits on the used RAM and message store size:

[
 {rabbit,
  [
   {vm_memory_high_watermark, 0.4},
   {msg_store_file_size_limit, 16777216}
   ]
 }
]
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.141.192.120