# File lib/stomp/client.rb, line 178 def subscribe(destination, headers = {}) raise Stomp::Error::NoListenerGiven unless block_given? headers = headers.symbolize_keys raise Stomp::Error::DestinationRequired unless destination # use subscription id to correlate messages to subscription. As described in # the SUBSCRIPTION section of the protocol: http://stomp.github.com/. # If no subscription id is provided, generate one. headers = headers.merge(:id => build_subscription_id(destination, headers)) if @listeners[headers[:id]] raise Stomp::Error::DuplicateSubscription end @listeners[headers[:id]] = lambda {|msg| yield msg} @connection.subscribe(destination, headers) end