Skip to content

Instantly share code, notes, and snippets.

@bobbytables
Created October 14, 2018 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bobbytables/d960e40a82d2cb01854ae774cb0aac24 to your computer and use it in GitHub Desktop.
Save bobbytables/d960e40a82d2cb01854ae774cb0aac24 to your computer and use it in GitHub Desktop.
config = Rails.application.config.x.gcloud
pubsub = Google::Cloud::Pubsub.new project_id: config["project_id"], credentials: config["pubsub"]["keyfile"]
topic = pubsub.topic "incident-events"
sub = topic.subscription "hello-world"
subscriber = sub.listen do |received_message|
puts "sub 1"
puts received_message.message.data
received_message.acknowledge!
end
subscriber.start
sub2 = topic.subscription "hello-world"
subscriber2 = sub2.listen do |received_message|
puts "sub 2"
puts received_message.message.data
received_message.acknowledge!
end
subscriber2.start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment