Sha256: 426cff51f0b82c70c3ada38e51bcae5fc5c4870db349d46f28638ad406595296

Contents?: true

Size: 983 Bytes

Versions: 7

Compression:

Stored size: 983 Bytes

Contents

# -*- encoding: utf-8 -*-
$:.unshift(File.expand_path('../../lib', __FILE__))
require 'stomper'

$stdout.puts "Starting demo"
$stdout.puts "----------------------------"

client = Stomper::Connection.new("stomp://localhost")
client.start

$stdout.puts "Connected to broker using protocol #{client.version}"

client.subscribe("/queue/stomper/test") do |message|
  $stdout.puts "Received: #{message.body}"
  if message.body == 'finished'
    client.stop
  end
end

client.send("/queue/stomper/test", "hello world")
client.send("/queue/stomper/test", "this is a simple demo of stomper")
client.send("/queue/stomper/test", "finished")

Thread.pass while client.running?
$stdout.puts "----------------------------"
$stdout.puts "End of demo"

# Example output:
#
#
# Starting demo
# ----------------------------
# Connected to broker using protocol 1.0
# Received: hello world
# Received: this is a simple demo of stomper
# Received: finished
# ----------------------------
# End of demo

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stomper-2.0.6 examples/basic.rb
stomper-2.0.5 examples/basic.rb
stomper-2.0.4 examples/basic.rb
stomper-2.0.3 examples/basic.rb
stomper-2.0.2 examples/basic.rb
stomper-2.0.1 examples/basic.rb
stomper-2.0.0 examples/basic.rb