0
내 rSpec 테스트에서 AMQP에 연결하는 데 문제가 있습니다. 나는 RSpec에 실행할 때메시지를 보내려면 AMQP에 두 번 연결할 수 없습니다.
Module Rabbit
Class Client
def start
EventMachine.run do
connection = AMQP.connect(Settings_object) #it holds host, username and password information
channel = AMQP::Channel.new(connection)
channel.queue("queue_name", :durable => true)
channel.default_exchange.publish("A test message", :routing_key => "queue_name")
end
end
end
Module Esper
Class Server
def start
EventMachine.run do
connection = AMQP.connect(Settings_object) #it holds host, username and password information
=begin
Some code to subscribe to queues
=end
end
end
end
내 문제는 다음과 같습니다 : 나는 다음과 같은 코드가 첫 번째 클라이언트에서
@client = Rabbit::Client.new
@server = Esper::Server.new
Thread.new do
@client.start
end
Thread.new do
@server.start
end
는 AMQP에 연결할 수 있으며, 서버는하지 않습니다,하지만 난 때 두 번째로 실행하면 클라이언트가 서버에 연결할 수 없습니다. 나는이 문제를 극복하기 위해 볼 수 없다. 클라이언트가 두 번째 실행시 연결을 중지하는 이유가 표시되지 않습니까?