JBoss.org Community Documentation
UDP is the preferred protocol for JGroups. UDP uses multicast or multiple unicasts to send and
receive messages. If you choose UDP as the transport protocol for your cluster service, you need
to configure it in the UDP
sub-element in the JGroups
Config
element. Here is an example.
<UDP mcast_addr="${jboss.partition.udpGroup:228.1.2.3}" mcast_port="${jboss.hapartition.mcast_port:45566}" tos="8" ucast_recv_buf_size="20000000" ucast_send_buf_size="640000" mcast_recv_buf_size="25000000" mcast_send_buf_size="640000" loopback="false" discard_incompatible_packets="true" enable_bundling="false" max_bundle_size="64000" max_bundle_timeout="30" use_incoming_packet_handler="true" use_outgoing_packet_handler="false" ip_ttl="${jgroups.udp.ip_ttl:2}" down_thread="false" up_thread="false"/>
The available attributes in the above JGroups configuration are listed below.
ip_mcast
specifies whether or not to use IP
multicasting. The default is true
. If set to false, it will send n unicast packets rather than 1 multicast packet. Either way, packets are UDP datagrams.
mcast_addr
specifies the multicast address (class D) for joining a group (i.e., the cluster). If omitted, the default is 228.8.8.8
.
mcast_port
specifies the multicast port number. If omitted, the
default is 45566
.
bind_addr
specifies the interface on which to receive and send multicasts (uses the -Djgroups.bind_address
system property, if present). If you have a multihomed machine, set the bind_addr
attribute or system property to the appropriate NIC IP address. By default, system property setting takes priority over XML attribute unless -Djgroups.ignore.bind_addr system property is set.
receive_on_all_interfaces
specifies whether this node
should listen on all interfaces for multicasts. The default is false
.
It overrides the bind_addr
property for receiving multicasts.
However, bind_addr
(if set) is still used to send multicasts.
send_on_all_interfaces specifies whether this node send UDP packets via all the NICs if you have a multi NIC machine. This means that the same multicast message is sent N times, so use with care.
receive_interfaces
specifies a list of of interfaces to receive multicasts on. The multicast receive socket will listen on all of these interfaces. This is a comma-separated list of IP addresses or interface names. E.g. "192.168.5.1,eth1,127.0.0.1
".
ip_ttl specifies time-to-live for IP Multicast packets. TTL is the commonly used term in multicast networking, but is actually something of a misnomer, since the value here refers to how many network hops a packet will be allowed to travel before networking equipment will drop it.
use_incoming_packet_handler
specifies whether to use a separate thread to process incoming messages. Sometimes receivers are overloaded (they have to handle de-serialization etc). Packet handler is a separate thread taking care of de-serialization, receiver thread(s) simply put packet in queue and return immediately. Setting this to true adds one more thread. The default is true
.
use_outgoing_packet_handler specifies whether to use a separate thread to process outgoing messages. The default is false.
enable_bundling
specifies whether to enable message bundling.
If it is true
, the node would queue outgoing messages until
max_bundle_size
bytes have accumulated, or
max_bundle_time
milliseconds have elapsed, whichever occurs
first. Then bundle queued messages into a large message and send it. The messages are
unbundled at the receiver. The default is false
.
loopback
specifies whether to loop outgoing message
back up the stack. In unicast
mode, the messages are sent to self. In
mcast
mode, a copy of the mcast message is sent. The default is false
discard_incompatibe_packets
specifies whether to
discard packets from different JGroups versions. Each message in the cluster is tagged
with a JGroups version. When a message from a different version of JGroups is received,
it will be discarded if set to true, otherwise a warning will be logged. The default is false
mcast_send_buf_size, mcast_recv_buf_size, ucast_send_buf_size, ucast_recv_buf_size define receive and send buffer sizes. It is good to have a large receiver buffer size, so packets are less likely to get dropped due to buffer overflow.
tos
specifies traffic class for sending unicast and multicast datagrams.
On Windows 2000 machines, because of the media sense feature being broken with multicast
(even after disabling media sense), you need to set the UDP protocol's
loopback
attribute to true
.