Class: StompPublisher

Inherits:
Object
  • Object
show all
Defined in:
lib/stomp_publisher.rb,
lib/stomp_publisher/frame.rb,
lib/stomp_publisher/header.rb,
lib/stomp_publisher/version.rb,
lib/stomp_publisher/connection_error.rb

Defined Under Namespace

Classes: ConnectionError, Frame, Header

Constant Summary collapse

FRAME_READ_SIZE =
8192
MAX_FRAME_SIZE =
65536
VERSION =
"0.9.1"

Instance Method Summary collapse

Constructor Details

#initialize(host: "localhost", port: 61613, login: nil, passcode: nil, vhost: host, **socket_args) ⇒ StompPublisher

Returns a new instance of StompPublisher.



12
13
14
15
16
17
18
19
# File 'lib/stomp_publisher.rb', line 12

def initialize(host: "localhost", port: 61613, login: nil, passcode: nil, vhost: host, **socket_args)
  @host = host
  @port = port
  @login =  or raise ArgumentError.new("missing argument login")
  @passcode = passcode or raise ArgumentError.new("missing argument passcode")
  @vhost = vhost
  @socket_args = socket_args
end

Instance Method Details

#publish(queue, message, **properties) ⇒ Object



21
22
23
24
25
# File 'lib/stomp_publisher.rb', line 21

def publish(queue, message, **properties)
  socket = TCPTimeout::TCPSocket.new(@host, @port, **@socket_args)
  connect(socket, @login, @passcode, @vhost)
  send(socket, message, properties.merge(destination: "/queue/#{queue}"))
end