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

  • SEARCH
  • Home
  • 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 8217205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:23:09+00:00 2026-06-07T12:23:09+00:00

I am currently building an architechture with a rails process and multiple worker processes

  • 0

I am currently building an architechture with a rails process and multiple worker processes which need to be informed of certain events (like the creation of an object).

Rails
  |         API   Worker  
  +----------o------o--------o------ - - -
                        Some other
                          daemon

I’d like to do the following

class Article
  after_creation do
    MessageBus.send type: "article-created", id: self.id
  end
end

While the processes (API, Worker, Daemons, …) just subscribe to the message bus and a block is called when a message comes in.

MessageBus.subscribe do |msg|
  if msg['type'] == 'article-created'
    # if this is my websocket daemon, I would push the article to the browser
    # if this is my indexing daemon, I would reindex the full-text search
    # if this is ... you get the deal.
  end
end

Currently I am using a local unix domain socket where I push JSON in with UNIXSocket and get it with EventMachine.start_unix_domain_server. But that allows only two-way communication. I also thought about using resque, but this is more a message queue while I need a bus. And it depends on redis. I am quite sure there must be a gem, that implements some message bus in ruby, but googling did not lead to any result

  • 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-07T12:23:10+00:00Added an answer on June 7, 2026 at 12:23 pm

    Finally I hacked a quick own solution using Eventmachine Channels.

    This is my server. Basically a clients connect to /tmp/messagebus.sock and send data. Everything that is pushed into the socket is sent to all other clients.

    require 'rubygems'
    require 'eventmachine'
    
    module Messagebus
      class Server
        attr_accessor :connections
        attr_accessor :channel
    
        def initialize
          @connections = []
          @channel = EventMachine::Channel.new
        end
    
        def start
          @signature = EventMachine.start_unix_domain_server '/tmp/messagebus.sock', Connection do |conn|
            conn.server = self
          end
        end
    
        def stop
          EventMachine.stop_server(@signature)
    
          unless wait_for_connections_and_stop
            EventMachine.add_periodic_timer(1) { wait_for_connections_and_stop }
          end
        end
    
        def wait_for_connections_and_stop
          if @connections.empty?
            EventMachine.stop
            true
          else
            puts "Waiting for #{@connections.size} connection(s) to finish ..."
            false
          end
        end
      end
    
      class Connection < EventMachine::Connection
        attr_accessor :server
    
        def post_init
          log "Connection opened"
        end
    
        def server=(server)
          @server = server
    
          @subscription = server.channel.subscribe do |data|
            self.log "Sending #{data}"
            self.send_data data 
          end
        end
    
        def receive_data(data)
          log "Received #{data}"
          server.channel.push data
        end
    
        def unbind
          server.channel.unsubscribe @subscription
          server.connections.delete(self)
          log "Connection closed"
        end
    
        def log(msg)
          puts "[#{self.object_id}] #{msg}"
        end
      end
    end
    
    EventMachine::run {
      s = Messagebus::Server.new
      s.start
      puts "New server listening"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're currently building multiple copies of our Chrome CRX, one for each of our
I am currently building a Rails 3.2 application that uses the gem sunspot to
I am currently building an API which will be used by a webservice. I
I'm currently building a multiple-document interface application, but I'm having a problem when the
I am building a Facebook survey, in which there are multiple questions per a
I´m currently building an Android app, which tracks the user´s location. My aim is
Im currently building an app to list all the background processes in the iPhone
Im currently building a controller from my Zend MVC application which would only be
Currently building an app that runs on mobile phones not related to the issue
I'm currently building a reporting service (WCF) - filled reports are produced using an

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.