lib/bbk/amqp/publisher.rb
# Send amqp message and save meta information for processing
# @param exchange [String] exchange name
# @param routing_key [String] message routing key
# @param payload [Object] message payload. Converted to json calling to_json method
# @param options [Hash] amqp message properties
# @return [Concurrent::Promises::ResolvableFuture] future for checking success publishing
Send amqp message and save meta information for processing
Send amqp message and save meta information for processing
def send_message(exchange, routing_key, payload, options)
          configure_exchange(exchange)
          channel.synchronize do
            ack_id = channel.next_publish_seq_no
            options[:message_id] ||= SecureRandom.uuid
            ack_map[ack_id] = options[:message_id].to_s
            future = sended_messages[ack_id] = Concurrent::Promises.resolvable_future
            logger.debug "Publish message #{options[:message_id]} with ack: #{ack_id} to #{exchange}##{routing_key}"
            data = if payload.is_a?(String)
              payload
            else
              Oj.generate(payload)
            end
            channel.basic_publish(data, exchange, routing_key, options)
            future
          end
        end
def send_message ( exchange , routing_key , payload , options ) configure_exchange ( exchange ) channel . synchronize do ack_id = channel . next_publish_seq_no options [ :message_id ] ||= SecureRandom . uuid ack_map [ ack_id ] = options [ :message_id ] . to_s future = sended_messages [ ack_id ] = Concurrent :: Promises . resolvable_future logger . debug "Publish message #{options[:message_id]} with ack: #{ack_id} to #{exchange}##{routing_key}" data = if payload . is_a? ( String ) payload else Oj . generate ( payload ) end channel . basic_publish ( data , exchange , routing_key , options ) future end end
Send amqp message and save meta information for processing
Send amqp message and save meta information for processing
# в случае укаказанного message_id в качестве числа, on_return вернет message_id в качестве строки
future for checking success publishing
future for checking success publishing
Concurrent::Promises::ResolvableFuture
exchange
None
routing_key
message routing key
message routing key
payload
message payload. Converted to json calling to_json method
message payload . Converted to json calling to_json method
options
amqp message properties
amqp message properties