Module: ActiveMessaging::MessageSender

Included in:
Filter, Processor, TraceFilter
Defined in:
lib/activemessaging/message_sender.rb,
lib/activemessaging/test_helper.rb

Overview

This is a module so that we can send messages from (for example) web page controllers, or can receive a single message

Constant Summary collapse

@@__a13g_initialized__ =
false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(included_by) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/activemessaging/message_sender.rb', line 8

def self.included(included_by)
  class << included_by
    def publishes_to destination_name
      ActiveMessaging::Gateway.find_destination(destination_name)
    end

    def receives_from destination_name
      ActiveMessaging::Gateway.find_destination(destination_name)
    end
  end
end

Instance Method Details

#publish(destination_name, message, headers = {}, timeout = 10) ⇒ Object



20
21
22
# File 'lib/activemessaging/message_sender.rb', line 20

def publish destination_name, message, headers={}, timeout=10
  ActiveMessaging::Gateway.publish(destination_name, message, self.class, headers, timeout)
end

#publish_with_reset(destination_name, message, headers = {}, timeout = 10) ⇒ Object



32
33
34
35
36
37
38
# File 'lib/activemessaging/test_helper.rb', line 32

def publish_with_reset(destination_name, message, headers={}, timeout=10)
  unless @@__a13g_initialized__
    ActiveMessaging.reload_activemessaging
    @@__a13g_initialized__ = true
  end
  publish_without_reset(destination_name, message, headers, timeout)
end

#receive(destination_name, headers = {}, timeout = 10) ⇒ Object



24
25
26
# File 'lib/activemessaging/message_sender.rb', line 24

def receive destination_name, headers={}, timeout=10
  ActiveMessaging::Gateway.receive(destination_name, self.class, headers, timeout)
end