def publish(msg)
msg.base64_encode! if @base64
target = target_for(msg)
if msg.type == :direct_request
msg.discovered_hosts.each do |node|
target[:headers] = headers_for(msg, node)
Log.debug("Sending a direct message to ActiveMQ target '#{target[:name]}' with headers '#{target[:headers].inspect}'")
@connection.publish(target[:name], msg.payload, target[:headers])
end
else
target[:headers].merge!(headers_for(msg))
Log.debug("Sending a broadcast message to ActiveMQ target '#{target[:name]}' with headers '#{target[:headers].inspect}'")
@connection.publish(target[:name], msg.payload, target[:headers])
end
end