Sha256: 9a466d187116ffaaa1ee0b15c61d15da0b592fad2fdcd0fb4d5a03a4c37c0267

Contents?: true

Size: 1.26 KB

Versions: 28

Compression:

Stored size: 1.26 KB

Contents

# -*- encoding: utf-8 -*-

#
# The current require dance for different Ruby versions.
# Change this to suit your requirements.
#
if Kernel.respond_to?(:require_relative)
  require_relative("./stomp11_common")
else
  $LOAD_PATH << File.dirname(__FILE__)
  require "stomp11_common"
end
include Stomp11Common

#
# == Stomp 1.1 Publish Example
#
# Purpose: to demonstrate sending messages using Stomp 1.1.
#
class Publish11Example1
  # Initialize.
  def initialize
  end
  # Run example.
  def run
    conn = get_connection() # Use helper method to obtain a Stomp#connection
    raise "Unexpected protocol level" if conn.protocol != Stomp::SPL_11
    #
    # Publishing simple data is as it was with Stomp 1.0.
    #
    # Note: Stomp 1.1 brokers seem to prefer using '.' as delimiters in queue
    # name spaces. Hence, the queue name used here.
    #
    qname = "/queue/nodea.nodeb.nodec"
    data = "message payload"
    headers = {}
    #
    # The 'data' and 'headers' may be omitted, as with Stomp 1.0
    #
    puts "Writing #{nmsgs()} messages."
    1.upto(nmsgs()) do |i|
      msg = "#{data}: #{i}"
      conn.publish qname, msg , headers
      puts "Sent data: #{msg}"
    end
    #
    # And finally, disconnect.
    #
    conn.disconnect
  end
end
#
e = Publish11Example1.new
e.run


Version data entries

28 entries across 26 versions & 2 rubygems

Version Path
stomp-1.4.4 examples/put11conn_ex1.rb
stomp-1.4.3 examples/put11conn_ex1.rb
stomp-1.4.2 examples/put11conn_ex1.rb
stomp-1.4.1 examples/put11conn_ex1.rb
stomp-1.4.0 examples/put11conn_ex1.rb
stomp-1.3.5 examples/put11conn_ex1.rb
stomp-1.3.4 examples/put11conn_ex1.rb
stomp-1.3.3 examples/put11conn_ex1.rb
stomp-1.3.2 examples/put11conn_ex1.rb
stomp-1.3.1 examples/put11conn_ex1.rb
stomp-1.3.0 examples/put11conn_ex1.rb
stomp-1.2.16 examples/put11conn_ex1.rb
stomp-1.2.14 examples/put11conn_ex1.rb
stomp-1.2.13 examples/put11conn_ex1.rb
stomp-1.2.12 examples/put11conn_ex1.rb
torquebox-console-0.3.0 vendor/bundle/jruby/1.9/gems/stomp-1.2.8/examples/put11conn_ex1.rb
stomp-1.2.11 examples/put11conn_ex1.rb
stomp-1.2.10 examples/put11conn_ex1.rb
torquebox-console-0.2.5 vendor/bundle/ruby/1.8/gems/stomp-1.2.8/examples/put11conn_ex1.rb
torquebox-console-0.2.5 vendor/bundle/jruby/1.9/gems/stomp-1.2.8/examples/put11conn_ex1.rb