Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thechrisoshow/61356 to your computer and use it in GitHub Desktop.
Save thechrisoshow/61356 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'smqueue'
# This script shows how posting to separate queues with the same client id blows up
def default_config
# Change host to whatever activemq host you want to use
{:adapter => "StompAdapter", :host => "localhost", :reliable => false}
end
def spawn_up_listeners
["first", "second"].each do |queue_name_prefix|
Thread.new {
SMQueue.new(default_config.merge(:client_id => "#{queue_name_prefix}_test_queue_listen", :name => "/queue/#{queue_name_prefix}_test_queue")).get {|m|}
}
end
end
spawn_up_listeners
first_queue = SMQueue.new(default_config.merge(:client_id => "test_queue", :name => "/queue/first_test_queue"))
second_queue = SMQueue.new(default_config.merge(:client_id => "test_queue", :name => "/queue/second_test_queue"))
loop do
first_queue.put "a message"
second_queue.put "another message"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment