Details

      Description

      I created a setup, where I neeed a delayed job worker to add events onto a queue.

      I used the following yaml specification:

      torquebox.yml
      queues:
        /queues/my_queue:
      topics:
        /topics/launcher:
        /topics/report_processor:
      messaging:
        /topics/launcher:
          JenkinsLauncher:
            config:
              server:   '127.0.0.1'
              port:     8080
              user:     jenkins_user
              password: jenkins_password
      jobs:
        github.scanner:
          job: GithubScanner
          # run this shit every 30 minutes
          #cron: '0 */30 * * * ?'
          cron: '*/5 * * * * ?'
          # 6 minute timeout?
          timeout: 500000 ms
          description: scan github for pull requests that need to be tested, add ready prs to the launcher queue
          config:
            project_names:
              - cinder
              - nova
              - glance
              - openstack
              - keystone
              - horizon
            admin_users:
              - bodepd
            github_login: puppet-openstack-ci-user
            github_password: PASSWORD
            test_message: schedule_for_testing
      

      and the following jobs file:

      app/jobs/git_scanner.rb
      require 'torquebox-cache'
      #
      # this class scans github for pull requests that have been approved
      #
      class GithubScanner
      
          include PullRequestTester
          include TorqueBox::Injectors
      
          # optional, only needed if you pass config options to the job
          def initialize(options = {})
      
            @project_names   = options["project_names"]
            @admin_users     = options["admin_users"]
            @github_login    = options["github_login"]
            @github_password = options["github_password"]
            @test_message    = options["test_message"] || 'schedule_for_testing'
      
            puts 'fetching stuff'
            @queue = fetch('/topics/launcher')
            puts @queue
            puts '@@@@@@@done fetching stuff'
      
            @cache = TorqueBox::Infinispan::Cache.new(
              :name    => 'github_events',
              # do not persist while I am testing
              #:persist => '/data/treasure'
            )
      
          end
          def run
          ...
          end
      end
      

      I deploy using the following script:

      #!/bin/bash
      torquebox deploy
      torquebox run -p 8282
      

      at first, when the jobs executed, it could not find the queue (it always returned nil instead)

      then, I tried initializing the queue from a basic sinatra app:

      class SinatraSession < Sinatra::Base
        # enable via infinispan
        use TorqueBox::Session::ServletStore
        include TorqueBox::Injectors
      
        get '/foo' do
          topic = TorqueBox::Messaging::Topic.new('/topics/launcher')
          topic.publish('foo')
          session[:message] = 'test'
          redirect to "bar"
        end
      
        get '/bar' do
          session[:message]
        end
      end
      

      after invoking this url (127.0.0.1:8282/foo)

      I noticed that the print statements from the previous job started working, they started returning:

      11:31:10,521 INFO [stdout] (JobScheduler$sinatra_session-knob.yml_Worker-3) fetching stuff
      11:31:10,522 INFO [stdout] (JobScheduler$sinatra_session-knob.yml_Worker-3) [Topic: HornetQTopic[/topics/launcher]]
      11:31:10,522 INFO [stdout] (JobScheduler$sinatra_session-knob.yml_Worker-3) @@@@@@@done fetching stuff

      the strange thing, is that even when I restarted the webserver, the job still accessed the queue (even if I didn't call the foo url)

      I was confused, so I removed all calls to the topic constructor, and even manually undeployed, deployed the app, now the job can access the queue without any constructor call.

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                goldmann Marek Goldmann
                Reporter:
                bodepd Dan Bode
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: