Parent

Methods

Class/Module Index [+]

Quicksearch

Publish11Example1

Stomp 1.1 Publish Example

Purpose: to demonstrate sending messages using Stomp 1.1.

Public Class Methods

new() click to toggle source

Initialize.

# File examples/put11conn_ex1.rb, line 21
def initialize
end

Public Instance Methods

run() click to toggle source

Run example.

# File examples/put11conn_ex1.rb, line 24
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

[Validate]

Generated with the Darkfish Rdoc Generator 2.