InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

InfoQ Article: Introduction to ActiveMessaging

Posted by Obie Fernandez on Feb 28, 2007

Sections
Development,
Architecture & Design
Topics
Programming ,
Ruby ,
Ruby on Rails
Tags
Stomp ,
JMS ,
ActiveMessaging
Andrew Kuklewicz, the maintainer of the ActiveMessaging (also called a13g for short) project gives a comprehensive and informative introduction to his open-source framework, which enables enterprise messaging technologies to be easily integrated with Ruby on Rails applications. ActiveMessaging is getting support from noted industry leaders such as James Strachan and Jon Tirsen.

ActiveMessaging is especially interesting to Rails developers in the enterprise, because through its support for Stomp and StompConnect it allows easy interoperability with Apache's ActiveMQ messaging server and any other enterprise messaging server that supports JMS.

Our easy-to-follow introductory article assumes basic knowledge of Ruby on Rails and messaging concepts, and has code samples and all the instructions you need to get started using ActiveMessaging.

Read InfoQ's Introduction to ActiveMessaging today.

19 comments

Watch Thread Reply

Great article! by James Strachan Posted
Performance/Throughput? by Stefan Tilkov Posted
Re: Performance/Throughput? by Andrew Kuklewicz Posted
Now, we can only push the messages to the views by hemant kumar Posted
Re: Now, we can only push the messages to the views by Andrew Kuklewicz Posted
Re: Now, we can only push the messages to the views by hemant kumar Posted
Re: Now, we can only push the messages to the views by Alex MacCaw Posted
Re: Now, we can only push the messages to the views by Alex MacCaw Posted
Re: Now, we can only push the messages to the views by James Strachan Posted
Re: Now, we can only push the messages to the views by hemant kumar Posted
Re: Now, we can only push the messages to the views by James Cook Posted
Re: Now, we can only push the messages to the views by Chong Francis Posted
Excellent! by Lee Zieke Posted
Re: Excellent! by Andrew Kuklewicz Posted
Re: Excellent! by Lee Zieke Posted
Errors by Denis Labelle Posted
Re: Errors by Denis Labelle Posted
Re: Errors by Ajay Nayak Posted
Ghost consumers lingering after script/poller stop? by Brian Balser Posted
  1. Back to top

    Great article!

    by James Strachan

    Thanks for a great article Andrew! ActiveMessaging really rocks (as does Rails, Stomp and ActiveMQ :). Keep up the good work!

    James
    LogicBlaze
    Open Source SOA

  2. Back to top

    Performance/Throughput?

    by Stefan Tilkov

    Excellent article. Are there any benchmarks/performance figures yet?

  3. Back to top

    Re: Performance/Throughput?

    by Andrew Kuklewicz

    good question - the straight answer is I haven't seen or or run any such test myself. If anyone else has, I would be very curious to hear about it.

    So I don't know exactly what the a13g overhead is, or how it scales. I have a feeling this may depend much more on your message broker, and then what you do in the message processor. These kind of tests are a bit tricky as you are testing the network, the broker, the box, etc.

    That said, it would be good to design a benchmark, perhaps based off the work done at ActiveMQ.

    I can say that anecdotally, I find the processing of the message to take longer than the overhead in dispatch - we even do synchronous messages from our java app to our rails app and back.

    One other nice thing is that you can run multiple instances of the poller process, so with N number of pollers all listening to the same queue, you in theory have as much scalability as you have processing power, and depending on the efficiency of the broker dispatch.

    Cheers,
    Andrew Kuklewicz

  4. Back to top

    Now, we can only push the messages to the views

    by hemant kumar

    This work is awesome, and all we need is a way to push these messages to the browser, so that browser doesn't poll for it. any ideas on this?

  5. Back to top

    Re: Now, we can only push the messages to the views

    by Andrew Kuklewicz

    I only know one non-polling based way to push to the browser, and that is the Juggernaut project.

    Personally I am very tempted to mess with the juggernaut juggernaut.rubyforge.org/ solution, I just haven't had an excuse.

    From what I understand it involves a separate "push server" that sits between a rails server app, and the flash apps on the browser. I see no reason a processor in a13g couldn't send a message to the juggernaut push server that would then get pushed up to the browser - if you give it a try let me know - it looks awful cool.

  6. Back to top

    Re: Now, we can only push the messages to the views

    by James Strachan

    This work is awesome, and all we need is a way to push these messages to the browser, so that browser doesn't poll for it. any ideas on this?


    We've had that part solved for a while using a cometd style integration using ActiveMQ and Jetty...

    activemq.apache.org/ajax.html

    In benchmarks for customers we've had a single process handling 14,000 concurrent users

    James
    LogicBlaze
    Open Source SOA

  7. Back to top

    Re: Now, we can only push the messages to the views

    by hemant kumar

    Well Andrew, I have checked out Juggernaut inside out and actually have implemented by own push server.But the problem is, it can't bypass firewalls and worst of it NATs. This is a big hurdle in my opinion. Without solving above issues Juggernaut won't get mass adoptation.

  8. Back to top

    Re: Now, we can only push the messages to the views

    by hemant kumar

    Are we talking Java?

  9. Back to top

    Excellent!

    by Lee Zieke

    Would you please take a look at the table messages, I have got
    mysql> select * from messages;
    +----+--------------+---------------------+
    | id | body | received_date |
    +----+--------------+---------------------+
    | 1 | Hello World | 0000-00-00 00:00:00 |
    | 2 | testDateTime | 0000-00-00 00:00:00 |
    +----+--------------+---------------------+

    FIELD received_date, it supposed to be DateTime at which message were generated.

    Please take a look at on_message

  10. Back to top

    Re: Now, we can only push the messages to the views

    by James Cook

    James, is that "cometd style" or api/protocol compliant cometd?

  11. Back to top

    Re: Excellent!

    by Andrew Kuklewicz

    Yeah, there is a one letter typo, I sent in a fix for this before the article was published, but guess it didn't make it into the article.


    def on_message(message)
    logger.debug "PersistMessageProcessor received: " + message
    my_message = Message.create(:body=>message, :received_date=>DateTime.new)
    end


    should be
    :received_date=>DateTime.now
    not
    :received_date=>DateTime.new

    Cheers,

    -Andrew Kuklewicz

  12. Back to top

    Re: Excellent!

    by Lee Zieke

    perfect, a toast !

  13. Back to top

    Errors

    by Denis Labelle

    Hello all,

    I followed along with the example, however when posting the message from the view, the server outputs the following message (infinitely, it would appear):


    transmit failed: undefined method `length' for #<Message:0x45f89b8>
    transmit failed: undefined method `length' for #<Message:0x45f89b8>
    transmit failed: undefined method `length' for #<Message:0x45f89b8>
    ...


    My poller runs fine:

    Loading D:/dev/ruby/Mess/app/processors/application.rb
    Loading D:/dev/ruby/Mess/app/processors/persist_message_processor.rb
    => Subscribing to /queue/PersistMessage (processed by
    PersistMessageProcessor)


    I don't see a message in either the poller console, or the activemq console.
    I changed the broker.yml configuration to look at denis:61613 instead of localhost because when activemq starts, it states:

    ...
    INFO TransportServerThreadSupport - Listening for connections at: tcp://denis:61616
    INFO TransportConnector - Connector openwire Started
    INFO TransportServerThreadSupport - Listening for connections at: ssl://denis:61617
    INFO TransportConnector - Connector ssl Started
    INFO TransportServerThreadSupport - Listening for connections at: stomp://denis:61613
    INFO TransportConnector - Connector stomp Started
    INFO TransportServerThreadSupport - Listening for connections at: xmpp://denis:61222
    INFO TransportConnector - Connector xmpp Started
    ...


    Any ideas?

    Thx,
    dl

  14. Back to top

    Re: Errors

    by Denis Labelle

    er, nevermind I overlooked 1 line in my controller, rather than
    def new
    @message = params[:message]
    ...
    end

    was
    def new
    @message = Message.new(params[:message])
    ...
    end

  15. Back to top

    Re: Now, we can only push the messages to the views

    by Chong Francis

    For pushing message in COMET style, you may use AjaxMessaging code.google.com/p/ajaxmessaging/

  16. Back to top

    Re: Now, we can only push the messages to the views

    by Alex MacCaw

    Hemant:
    Not true, Juggernaut can use port 443 which is open on most firewall (used for https).

  17. Back to top

    Re: Now, we can only push the messages to the views

    by Alex MacCaw

    Juggernaut can bypass firewalls in that it can use ports commonly open on a firewall, such as 443. I'm not sure how NAT poses a problem, the port just gets forwarded to a internal server.

  18. Back to top

    Ghost consumers lingering after script/poller stop?

    by Brian Balser

    I've noticed that when using the poller, there are occasional consumers lingering around which AMQ sends the msg, and hence dropped, any idea if I'm not using the poller correctly? I have a run_poller script that does:

    script/poller start
    sleep 30
    script/poller stop

  19. Back to top

    Re: Errors

    by Ajay Nayak

    Hi Author of this Article,

    I have followed all your steps to config to code.
    But when i am running "script/poller run"
    I am not getting desirable log in console.

    Only getting as :
    ^C^[[Aajay-dhandes-imac:MessageMonster mrunalini$ script/poller run
    /Users/mrunalini/.gem/ruby/1.8/gems/stomp-1.1.3/lib/stomp/connection.rb:156: warning: parenthesize argument(s) for future version
    ActiveMessaging: adapter wmq not loaded: no such file to load -- wmq/wmq
    "/Users/mrunalini/code/MessageMonster"
    "/Users/mrunalini/code/MessageMonster/config/messaging.rb"
    ActiveMessaging: Loading /Users/mrunalini/code/MessageMonster/app/processors/application.rb
    ActiveMessaging: Loading /Users/mrunalini/code/MessageMonster/app/processors/persist_message_processor.rb
    Missing the Rails 2.3.3 gem. Please `gem install -v=2.3.3 rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.


    My development environment is Mac OSX Leapord.

    Please post suitable solutions for me.

    Thanks,
    Ajay nayak

Educational Content

New-age Transactional Systems - Not Your Grandpa's OLTP

John Hugg discusses high volume transaction processing applications with high and low frequency profiles, and how VoltDB can be used for that purpose.

Cool Code

Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.

Collaboration: At the Extremities of Extreme

Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.

Yesod Web Framework

Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).

Transactions without Transactions

Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.

Attila Szegedi on JVM and GC Performance Tuning at Twitter

Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.