Signed-off-by: Adam Stokes astokes@fedoraproject.org --- matahari-broker.init.in | 47 ++++++++++++++++++++++++++++++++++++++++++++ matahari-broker.sysconf.in | 8 +++++++ 2 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/matahari-broker.init.in b/matahari-broker.init.in index e74926c..7014e3d 100755 --- a/matahari-broker.init.in +++ b/matahari-broker.init.in @@ -43,11 +43,55 @@ pidfile=@localstatedir@/run/matahari-broker.pid # Turn off automatic systemd redirects #SYSTEMCTL_SKIP_REDIRECT=1
+# Timeout for qpid-route in seconds +TIMEOUT=5 + # Source function library. . @sysconfdir@/rc.d/init.d/functions
RETVAL=0
+# Enable broker federation +federate() { + unset array + declare -a array + for name in $@ + do + case $name in + *_matahari-broker._tcp*) + RESP=`dig SRV $name +short| awk '{print $4":"$3}'|sed 's/.:/:/'` + array+=$RESP + ;; + *:[[:digit:]]*) + array+=$name + ;; + *) + echo -n $"Invalid broker: $name" + esac + done + + for name in ${array[@]} + do + /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add $name \ + localhost:$MATAHARI_PORT amq.direct &> /dev/null + + /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add localhost:$MATAHARI_PORT \ + $name amq.direct &> /dev/null + + /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add $name \ + localhost:$MATAHARI_PORT qmf.default.direct &> /dev/null + + /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add localhost:$MATAHARI_PORT \ + $name qmf.default.direct &> /dev/null + + /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add $name \ + localhost:$MATAHARI_PORT qmf.default.topic &> /dev/null + + /usr/bin/qpid-route --timeout=$TIMEOUT dynamic add localhost:$MATAHARI_PORT \ + $name qmf.default.topic &> /dev/null + done +} + start() { echo -n $"Starting Matahari broker daemon: " install -o root -g qpidd -m 775 -d @localstatedir@/run/matahari @@ -61,6 +105,9 @@ start() { [ -x /sbin/restorecon ] && /sbin/restorecon $pidfile runuser -s /bin/sh qpidd -c "/usr/sbin/$prog --check > $pidfile" fi + + federate ${FEDERATED_BROKERS[@]} + return $RETVAL }
diff --git a/matahari-broker.sysconf.in b/matahari-broker.sysconf.in index 9b1c2b5..4473610 100644 --- a/matahari-broker.sysconf.in +++ b/matahari-broker.sysconf.in @@ -11,3 +11,11 @@ fi
QPIDD_OPTIONS="--config @sysconfdir@/matahari-broker.conf --port $MATAHARI_PORT"
+# Federated Broker configuration +# Takes the following formats: +# <fqdn>:<port> +# DNS SRV record format "_matahari-broker._tcp" is REQUIRED +# _matahari-broker._tcp.<fqdn> +# +# A mixture of the above is acceptable. +# FEDERATED_BROKERS=("broker1.example.com:49000" "_matahari-broker._tcp.example.com")