lib/propono/services/publisher.rb in propono-0.8.0 vs lib/propono/services/publisher.rb in propono-0.8.2
- old
+ new
@@ -1,7 +1,6 @@
require 'socket'
-require 'thread/future'
module Propono
class PublisherError < ProponoError
end
@@ -22,19 +21,24 @@
@message = message
@protocol = options.fetch(:protocol, :sns).to_sym
end
def publish
+ Propono.config.logger.info "Propono: Publishing #{message} to #{topic_id} via #{protocol}"
send("publish_via_#{protocol}")
end
private
def publish_via_sns
topic = TopicCreator.find_or_create(topic_id)
msg = message.is_a?(String) ? message : message.to_json
- Thread.future(WORKER_POOL) do
- sns.publish(topic.arn, msg)
+ Thread.new do
+ begin
+ sns.publish(topic.arn, msg)
+ rescue => e
+ Propono.config.logger.error "Propono failed to send via sns : #{e}"
+ end
end
end
def publish_via_udp
payload = {topic: topic_id, message: message}.to_json