SOA / Web Services / Java

A Technology Blog

Ruby: Writing message to ActiveMQ

Posted by Vivek on June 10, 2015

The following piece of code can be used to write a message to ActiveMQ queue

require ‘rubygems’
require ‘jms’

config = {
:factory => ‘org.apache.activemq.ActiveMQConnectionFactory’,
:broker_url => ‘tcp://localhost:61616’,
:require_jars => [“~/Applications/apache-activemq-5.4.2/activemq-all-5.4.2.jar”]
}

JMS::Connection.session(config) do |session|
session.producer(:q_name => ‘myQueue’) do |producer|
producer.send(session.message(“Helloworld”))
end
end

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: