-
Notifications
You must be signed in to change notification settings - Fork 2
/
emitter.rb
executable file
·42 lines (26 loc) · 951 Bytes
/
emitter.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env ruby
ENV['RABBIT_URL'] = 'amqp://guest:guest@localhost:5672'
ENV['RABBIT_EVENT_BUS_APP_NAME'] = 'EventBusExampleApp'
ENV['RABBIT_EVENT_BUS_VHOST'] = 'event_bus'
ENV['RABBIT_EVENT_BUS_TOPIC_NAME'] = 'event_bus'
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
require 'rubygems'
require 'bundler'
Bundler.require(:default, 'development')
require 'event_bus'
events = []
event_name = 'resource.custom.pay'
body = { amount: 1500, name: 'John' }
events.push(EventBus::Event.new(event_name, body))
event_name = 'resource.custom.receive'
body = { amount: 300, name: 'George' }
events.push(EventBus::Event.new(event_name, body))
event_name = 'resource.origin.action'
body = { bo: 'dy' }
schemaVersion = 4.2
event = EventBus::Event.new(event_name, body, schemaVersion)
p 'Sending messsages.'
EventBus::Emitter.trigger(event)
EventBus::Emitter.trigger(events)
p 'Mesages sent!'
EventBus::Config.broker.close_connection