Class: Publish11Example1

### Home Classes Methods

### In Files

- examples/put11conn_ex1.rb

### Parent

Object

### Methods

- ::new
- #run

### Files

- CHANGELOG.rdoc
- LICENSE

### Class/Module Index

Quicksearch

- Stomp
- Stomp::Client
- Stomp::Connection
- Stomp::Error
- Stomp::Error::ConnectReadTimeout
- Stomp::Error::DuplicateSubscription
- Stomp::Error::InvalidFormat
- Stomp::Error::InvalidHeartBeatHeaderError
- Stomp::Error::InvalidMessageLength
- Stomp::Error::InvalidServerCommand
- Stomp::Error::LoggerConnectionError
- Stomp::Error::MalformedFailoverOptionsError
- Stomp::Error::MaxReconnectAttempts
- Stomp::Error::MessageIDRequiredError
- Stomp::Error::NilMessageError
- Stomp::Error::NoCurrentConnection
- Stomp::Error::PacketParsingTimeout
- Stomp::Error::ProtocolError11p
- Stomp::Error::ProtocolErrorConnect
- Stomp::Error::SSLClientParamsError
- Stomp::Error::SSLNoCertFileError
- Stomp::Error::SSLNoKeyFileError
- Stomp::Error::SSLNoTruststoreFileError
- Stomp::Error::SSLUnreadableCertFileError
- Stomp::Error::SSLUnreadableKeyFileError
- Stomp::Error::SSLUnreadableTruststoreFileError
- Stomp::Error::SocketOpenTimeout
- Stomp::Error::StompServerError
- Stomp::Error::SubscriptionRequiredError
- Stomp::Error::UTF8ValidationError
- Stomp::Error::UnsupportedProtocolError
- Stomp::HeaderCodec
- Stomp::Message
- Stomp::SSLParams
- Client11Example1
- Client11PutGet1
- Connection11Example1
- Connection11Example2
- ExampleConsumer
- ExamplePublisher
- ExampleRubyCiphers
- ExampleSSL1
- ExampleSSL1C
- ExampleSSL2
- ExampleSSL2C
- ExampleSSL3
- ExampleSSL3C
- ExampleSSL4
- ExampleSSL4C
- ExampleTopicConsumer
- ExampleTopicPublisher
- Hash
- HeartBeatExample1
- LoggerExample
- Object
- Publish11Example1
- Receive11Example1
- Receive11Example2
- RepeatedHeadersExample
- SSLLoggerExample
- Slogger
- Stomp11Common
- TestBase
- TestClient
- TestConnection
- TestConnection1P
- TestMessage
- TestSSL
- TestURLLogins
- Tlogger

No matching classes.

# 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.