Class: Client11PutGet1

### Home Classes Methods

### In Files

- examples/client11_putget1.rb

### Parent

Object

### Methods

- ::new
- #run

### Files

- CHANGELOG.rdoc
- LICENSE

### Class/Module Index

Quicksearch

- Stomp
- Stomp::Client
- Stomp::Connection
- Stomp::Error
- Stomp::Error::BrokerException
- 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::ProducerFlowControlException
- Stomp::Error::ProtocolError11p
- Stomp::Error::ProtocolErrorConnect
- Stomp::Error::ProtocolErrorEmptyHeaderKey
- Stomp::Error::ProtocolErrorEmptyHeaderValue
- Stomp::Error::ProtocolException
- Stomp::Error::ReadReceiptTimeoutException
- 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::StartTimeoutException
- Stomp::Error::StompException
- Stomp::Error::StompServerError
- Stomp::Error::SubscriptionRequiredError
- Stomp::Error::UTF8ValidationError
- Stomp::Error::UnsupportedProtocolError
- Stomp::HeaderCodec
- Stomp::Message
- Stomp::NullLogger
- Stomp::SSLParams
- Client11Example1
- Client11PutGet1
- Connection11Example1
- Connection11Example2
- ExampleConsumer
- ExamplePublisher
- ExampleRubyCiphers
- ExampleSSL1
- ExampleSSL1C
- ExampleSSL2
- ExampleSSL2C
- ExampleSSL3
- ExampleSSL3C
- ExampleSSL4
- ExampleSSL4C
- ExampleSSLCtxOptions
- ExampleSSLNewParm
- ExampleTopicConsumer
- ExampleTopicPublisher
- Hash
- HeartBeatExample1
- LoggerExample
- Object
- Publish11Example1
- Receive11Example1
- Receive11Example2
- RepeatedHeadersExample
- SSLLoggerExample
- Slogger
- Stomp11Common
- TestAnonymous
- TestBase
- TestClient
- TestConnection
- TestConnection1P
- TestMessage
- TestSSL
- TestURLLogins
- Tlogger

No matching classes.

# Client11PutGet1

## Stomp 1.1 Client Putter/Getter Example 1

This is much like sending and receiving with a Stomp::Connection.

### Public Class Methods

new() click to toggle source

Initialize.

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

### Public Instance Methods

run() click to toggle source

Run example.

    # File examples/client11_putget1.rb, line 24
    def run
      #
      client_hdrs = {"accept-version" => "1.1",    # Demand a 1.1 connection (use a CSV list if you will consider multiple versions)
        "host" => virt_host,                 # The 1.1 vhost (could be different than connection host)
      }                                      # No heartbeats here:  there will be none for this connection
      #
      client_hash = { :hosts => [
          {:login => login, :passcode => passcode, :host => host, :port => port},
        ],
        :connect_headers => client_hdrs,
      }
      #
      client = Stomp::Client.new(client_hash)
      puts "Client Connect complete"
      #
      raise "Unexpected protocol level" if client.protocol() != Stomp::SPL_11
      #
      qname = "/queue/client.nodea.nodeb.nodec"
      data = "message payload: #{Time.now.to_f}"
      headers = {}
      # Send it
      client.publish qname, data
      puts "Publish complete"
      # Receive
      uuid = client.uuid() # uuid for Stomp::Client is a public method
      message = nil
      # Clients must pass a receive block.  This is business as usual, required for 1.0.
      # For 1.1, a unique subscription id is required.
      client.subscribe(qname, {'id' => uuid}) {|m|
      message = m
      }
      sleep 0.1 until message # Wait for completion
      puts "Subscribe and receive complete"
      # Unsubscribe, with the unique id
      client.unsubscribe qname,  {'id' => uuid}
      # Sanity checks for this example ....
      raise "Unexpected data" if data != message.body
      raise "Bad subscription header" if uuid != message.headers['subscription']
      #
      client.close   # Business as usual, just like 1.0
      puts "Client close complete"
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.