Created
February 10, 2009 11:34
-
-
Save thechrisoshow/61356 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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