質問

I'm using Iron.io for our messaging platform. It works great once everything is pushed to their servers. However sometimes (very rare) we get issues adding a message to the queue. Usually it is a 400 error probably due to some weird web timing issue. What is the best way to guarantee the message will get put on their Queue? Code is attached, failure happens in the message_queue.post.

class Bus

  def self.send(message, queue, callback_url)
    message_queue = IRONMQ.queue(queue)
    add_subscribers(callback_url, message_queue)
    result = message_queue.post(message.to_json)
    puts "put the message : #{message.inspect} on the bus with result #{result.inspect}"
  end

  def self.add_subscribers(callback_url, message_queue)
    if callback_url.kind_of?(Array)
      callback_url.each { |url| message_queue.add_subscriber({url: format_callback_url(url)}) }
    else
      message_queue.add_subscriber({url: format_callback_url(callback_url)})
    end
  end
役に立ちましたか?

解決 3

I ended up just moving to use Sidekiq to handle photo uploading. It has retry logic built into it and is easy to configure.

他のヒント

handle the 400 errorcode and have it rerun the post again after a backoff period.

HTTP 400 response code means application sent wrong data. Possibly, JSON-ified message is greater than 64kB.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top