torquebox / torquespec

Integration testing with TorqueBox
Apache License 2.0
17 stars 10 forks source link

Issues with queues #11

Open Kitton opened 10 years ago

Kitton commented 10 years ago

Good day, I have some problems with the queues.

require 'torquespec'
require 'torquebox-core'
require 'torquebox-messaging'
require 'spec_helper'
require 'capybara'

app = <<-END.gsub(/^ {4}/,'')
    application:
      root:  #{File.dirname(__FILE__)}/../../../app
      env: test
    queues:
      /queues/async_mails_manual:
END

describe 'inside torquebox' do
  deploy(app)

  it "should send" do
    #Have tried with TorqueBox.fetch here before, didnt work either
    queue = TorqueBox::Messaging::Queue.new '/queues/async_mails_manual'
    p queue
    p queue.count_messages
    queue.publish("message_test")
    p queue.count_messages
  end
end

The output:

/home/gaf/.rvm/gems/jruby-1.7.9/gems/simplecov-0.7.1/lib/simplecov.rb:34 warning: tracing (e.g. set_trace_func) will not capture all events without --debug flag
The signal KILL is in use by the JVM and will not work correctly on this platform
"/usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java" -Xms512m -Xmx3000m -XX:MaxPermSize=512m -Dorg.jboss.resolver.warning=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Dorg.jboss.boot.log.file="/home/gaf/Work/etc/torquebox-3.0.2/jboss/standalone/log/boot.log" -Dlogging.configuration=file:"/home/gaf/Work/etc/torquebox-3.0.2/jboss/standalone/configuration/logging.properties" -jar "/home/gaf/Work/etc/torquebox-3.0.2/jboss/jboss-modules.jar" -mp "/home/gaf/Work/etc/torquebox-3.0.2/jboss/modules" -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -Djboss.home.dir="/home/gaf/Work/etc/torquebox-3.0.2/jboss"
pid=17088
Waiting up to 120s for JBoss to boot

JBoss started in 9s
deploy /home/gaf/Work/d/api/.torquespec/inside_torquebox-knob.yml in 0s
#<TorqueBox::Messaging::Queue:0x63ee09a8 @name="/queues/async_mails_manual", @enumerable_options={}, @connect_options={}, @connection_factory=#<TorqueBox::Messaging::ConnectionFactory:0x20bc27d9 @tm=nil, @internal_connection_factory=nil>>
nil
nil

So instead of 0 I'm getting nil here and the message isn't published. Have used an advice from here http://stackoverflow.com/questions/17057616/torquebox-torquespec-testing-queues-cant-be-fetched-in-remote-describe-block , but still cant make it work. Any ideas?

bbrowning commented 10 years ago

If you change your code to publish the message then receive a message, do you receive your published message? I'm wondering if it's just an issue with queue.count_messages not working properly outside the running TorqueBox.

The code in your "should send" block doesn't actually run inside TorqueBox. It's still running in your RSpec process, but should be able to connect to the running TorqueBox. If you want this code to actually run inside TorqueBox, you'd need to change your "describe" block to "remote_describe".

Kitton commented 10 years ago

Confirm your assumption - "receive" method works, but in my code "count_messages" is used a lot :( About remote_describe, it seems that Rails.root doesn't work there - I have got a lot of error in requires, like this one

    "failure-description" : {"JBAS014671: Failed services" : {"jboss.deployment.unit.\"inside_torquebox-knob.yml\".service.TorqueSpec::Daemon.create" : "org.jboss.msc.service.StartException in service jboss.deployment.unit.\"inside_torquebox-knob.yml\".service.TorqueSpec::Daemon.create: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- lib/queues/abstract_queue\n    Caused by: org.jruby.exceptions.RaiseException: (LoadError) no such file to load -- lib/queues/abstract_queue"}},