Created
September 15, 2012 10:59
-
-
Save Fivell/3727344 to your computer and use it in GitHub Desktop.
ruby stomp subscriber example with durable topics
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'stomp' | |
client_id = "client-id" | |
subscription_name = "subName" | |
topic_name = "topicName" | |
stomp_params = { | |
:hosts => [ | |
{ :host => "localhost", :port => 61613}, | |
], | |
:connect_headers => {'client-id' => client_id}, | |
} | |
client = Stomp::Client.new stomp_params | |
client.subscribe "/topic/#{topic_name}", { "ack" => "client", "activemq.subscriptionName" => subscription_name} do |msg| | |
puts "--------------body----------------" | |
p msg.body | |
puts "--------------headers----------------" | |
p msg.headers | |
puts "-----end-----" | |
client.acknowledge msg | |
end | |
client.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment