Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8553715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:43:00+00:00 2026-06-11T14:43:00+00:00

So, i’m building a small application using Rails. I need to use XMPP proto

  • 0

So, i’m building a small application using Rails. I need to use XMPP proto for notification of users with a bit of commands to change user status.

Previous version was an application using plain Python(pretty ugly app) with plain SQL request into DB. There was a table "jabber_queue", so in separated script, bot was checking each second for any rows, processing it(sending message), deleting. It was simple and stupid, but it was ok.

Now i see, i need to integrate this bot functionality into Rails(at least to work with RSpec).

This is my few versions of how it can be done:

  1. Use separated async queue solution. For example, Resque. Use separated Ruby script and push events into Resque, pop events in application(not dependent on DB, so easily fit with RSpec tests and test DB). But it makes my application a bit bloated – i need to use second DB with a lot of memory and CPU additional requirements – it will be overhead for my problem. Also, i don’t want to support additional "thing" for this application, i know, it can be done a lot easier way.

  2. Use delayed_job(queue solution using current AR DB). But i don’t know how to get current AR DB of Rails application in separated script. Anyway, it’s a dirty and ugly way.

  3. Launch XMPP bot WITHIN Rails application, as background worker. So worker will get access to "current" AR(in case of testing, to test-DB). But i simply don’t know how to do it. I’ve found a Navvy, but i need to put somewhere at Rails start a string like a "Navvy::Job.enqueue(Cow, :speak)", i don’t know where will be best place for this, to start it with RSpec testing and "rails server". Also, there is a BackgrounDRb, but this project is similar to Navvy and inactive too. Using search on stackoverflow, i’ve found similar problem to mine, but solution leads me to background_job, which can just anything in background, but i still don’t know how to get current AR DB access in separated script.

I’m so sorry for this amount of words in my problem, it’s just a brainstream. I see some solutions, but i really need advices and some words from more experienced developers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:43:01+00:00Added an answer on June 11, 2026 at 2:43 pm

    So, this was solved using yes, third way.

    1. I’ve created a class for dealing with bot commands and AR models – awesomo.rb. Nothing special, really. I put this in /lib/ of Rails project. Secondly,

    2. Created configuration file for easy setting of password and JID – config/awesomo.yml

      development:
        xmpp_jid: ...
        xmpp_password: ...
      
    3. I’ve created a daemon for my bot – awesomo_daemon.rb. Same, in /lib/. This is what it contains:

      #preload rails environment
      require File.expand_path(File.join(File.dirname(__FILE__),
           '..', 'config', 'environment'))
      
      #load xmpp bot class
      require 'awesomo_daemon'
      
      #load xmpp bot configuration file for current environment
      AWESOMO_CONFIG = YAML.load_file(File.join(File.dirname(__FILE__),
          '..', 'config', 'awesomo.yml'))[Rails.env]
      
      #apply configuration before singleton will be initiated
      Awesomo.setup AWESOMO_CONFIG['xmpp_jid'], AWESOMO_CONFIG['xmpp_password']
      
      loop {
        Awesomo.instance.idle
        sleep 1
      }
      
    4. Created daemon script starter- script/awesomo.

      #!/usr/bin/env ruby
      require 'rubygems'
      require 'daemons'
      Daemons.run "lib/awesomo_daemon.rb", dir_mode: :normal,
          dir: File.join(File.dirname(__FILE__), '..', 'tmp', 'pids')
      
    5. Simply run it with command script/awesomo start.

    And I can use any my models within awesomo.rb! Also, for queue, i’m using little model – XMPPJob with fields jtype(for example, “xmpp_message”), body(“hey!”), to(“john@jabber.com”). Fetching it within awesomo.rb idle function of bot class with limit(5).each do |job| case jtype ....

    To post any new job for my “awesomo”, i’m using function send_message:

    def self.send_message to, body
      xmppjob = XmppJob.new :jtype => "xmpp_message", :body => body, :to => to
      xmppjob.save
    end
    

    Everything works perfectly, except XMPP library(xmpp4r-simple) itself, but I’ll rewrite it soon using just xmpp4r.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I want use html5's new tag to play a wav file (currently only supported
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.