rservicebus 0.0.01 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README.md +48 -0
- data/bin/{rservicebus2 → rservicebus} +2 -1
- data/lib/rservicebus.rb +15 -54
- data/lib/rservicebus/Agent.rb +21 -0
- data/lib/rservicebus/Config.rb +125 -0
- data/lib/rservicebus/ErrorMessage.rb +14 -0
- data/lib/rservicebus/HandlerLoader.rb +100 -0
- data/lib/rservicebus/Host.rb +340 -0
- data/lib/rservicebus/Message.rb +29 -0
- data/lib/rservicebus/Subscription.rb +13 -0
- data/lib/rservicebus/helper_functions.rb +8 -81
- metadata +23 -150
- checksums.yaml +0 -7
- data/bin/return_messages_to_source_queue +0 -114
- data/bin/rsb_ctl +0 -38
- data/bin/rservicebus2-create +0 -107
- data/bin/rservicebus2-init +0 -104
- data/bin/rservicebus2-transport +0 -16
- data/bin/send_empty_message +0 -15
- data/lib/rservicebus/agent.rb +0 -54
- data/lib/rservicebus/appresource.rb +0 -65
- data/lib/rservicebus/appresource/dir.rb +0 -29
- data/lib/rservicebus/appresource/file.rb +0 -8
- data/lib/rservicebus/appresource/fluiddb.rb +0 -24
- data/lib/rservicebus/appresource_configure.rb +0 -33
- data/lib/rservicebus/audit.rb +0 -28
- data/lib/rservicebus/circuitbreaker.rb +0 -79
- data/lib/rservicebus/config.rb +0 -168
- data/lib/rservicebus/cron_manager.rb +0 -76
- data/lib/rservicebus/endpointmapping.rb +0 -72
- data/lib/rservicebus/errormessage.rb +0 -14
- data/lib/rservicebus/handler_loader.rb +0 -162
- data/lib/rservicebus/handler_manager.rb +0 -131
- data/lib/rservicebus/host.rb +0 -487
- data/lib/rservicebus/message.rb +0 -78
- data/lib/rservicebus/message/statisticoutput.rb +0 -7
- data/lib/rservicebus/message/subscription.rb +0 -10
- data/lib/rservicebus/message/verboseoutput.rb +0 -7
- data/lib/rservicebus/monitor.rb +0 -61
- data/lib/rservicebus/monitor/csvdir.rb +0 -52
- data/lib/rservicebus/monitor/dir.rb +0 -139
- data/lib/rservicebus/monitor/dirnotifier.rb +0 -101
- data/lib/rservicebus/monitor/message.rb +0 -11
- data/lib/rservicebus/monitor/xmldir.rb +0 -11
- data/lib/rservicebus/monitor_configure.rb +0 -71
- data/lib/rservicebus/mq.rb +0 -98
- data/lib/rservicebus/mq/beanstalk.rb +0 -72
- data/lib/rservicebus/resource_manager.rb +0 -69
- data/lib/rservicebus/saga/base.rb +0 -17
- data/lib/rservicebus/saga/data.rb +0 -20
- data/lib/rservicebus/saga/manager.rb +0 -128
- data/lib/rservicebus/saga_loader.rb +0 -118
- data/lib/rservicebus/saga_storage.rb +0 -18
- data/lib/rservicebus/saga_storage/dir.rb +0 -87
- data/lib/rservicebus/saga_storage/inmemory.rb +0 -37
- data/lib/rservicebus/sendat_manager.rb +0 -33
- data/lib/rservicebus/sendat_storage.rb +0 -20
- data/lib/rservicebus/sendat_storage/file.rb +0 -37
- data/lib/rservicebus/sendat_storage/inmemory.rb +0 -20
- data/lib/rservicebus/state_manager.rb +0 -30
- data/lib/rservicebus/state_storage.rb +0 -18
- data/lib/rservicebus/state_storage/dir.rb +0 -66
- data/lib/rservicebus/state_storage/inmemory.rb +0 -25
- data/lib/rservicebus/statistic_manager.rb +0 -86
- data/lib/rservicebus/stats.rb +0 -68
- data/lib/rservicebus/subscription_manager.rb +0 -31
- data/lib/rservicebus/subscription_storage.rb +0 -39
- data/lib/rservicebus/subscription_storage/file.rb +0 -42
- data/lib/rservicebus/subscription_storage/redis.rb +0 -69
- data/lib/rservicebus/subscription_storage_configure.rb +0 -19
- data/lib/rservicebus/test.rb +0 -2
- data/lib/rservicebus/test/bus.rb +0 -32
- data/lib/rservicebus/transporter.rb +0 -142
- data/lib/rservicebus/usermessage/withpayload.rb +0 -10
data/bin/rsb_ctl
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# The application 'rservicebus' is installed as part of a gem, and
|
4
|
-
# this file is here to facilitate running it.
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rservicebus'
|
9
|
-
require 'rservicebus/Agent'
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
if ARGV.length == 3 then
|
14
|
-
queue_name = ARGV[0]
|
15
|
-
switch_name = ARGV[1].upcase
|
16
|
-
switch_state = ARGV[2].upcase == 'TRUE' || ARGV[2].upcase == 'ON'
|
17
|
-
else
|
18
|
-
puts 'Usage: rsb_ctl <queue name> <switch> <switch state>'
|
19
|
-
puts 'Valid switchs: Stats, Verbose'
|
20
|
-
puts 'Valid switch states: On, Off'
|
21
|
-
abort()
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
agent = RServiceBus::Agent.new.getAgent( URI.parse('beanstalk://localhost') )
|
26
|
-
obj = nil
|
27
|
-
case switch_name
|
28
|
-
when switch_name = 'STATS'
|
29
|
-
obj = switch_state == true ? RServiceBus::Message_StatisticOutputOn.new : RServiceBus::Message_StatisticOutputOff.new
|
30
|
-
when switch_name = 'VERBOSE'
|
31
|
-
obj = switch_state == true ? RServiceBus::Message_VerboseOutputOn.new : RServiceBus::Message_VerboseOutputOff.new
|
32
|
-
else
|
33
|
-
puts "Switch name, #{ARGV[0]}, not recognized"
|
34
|
-
puts 'Valid switchs: Stats, Verbose'
|
35
|
-
abort()
|
36
|
-
end
|
37
|
-
|
38
|
-
agent.sendMsg(obj, queue_name, "#{queue_name}Response")
|
data/bin/rservicebus2-create
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
#################################
|
4
|
-
# Contract
|
5
|
-
def contract(name)
|
6
|
-
content = '
|
7
|
-
class First
|
8
|
-
end
|
9
|
-
'
|
10
|
-
|
11
|
-
File.write("#{name}/Contract.rb", content)
|
12
|
-
end
|
13
|
-
|
14
|
-
#################################
|
15
|
-
# Rakefile
|
16
|
-
def rakefile(name)
|
17
|
-
content = %{
|
18
|
-
require 'rake/testtask'
|
19
|
-
|
20
|
-
Rake::TestTask.new do |t|
|
21
|
-
t.libs << 'test'
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "Run tests"
|
25
|
-
task :default => :test
|
26
|
-
|
27
|
-
}
|
28
|
-
|
29
|
-
File.write("#{name}/Rakefile", content)
|
30
|
-
end
|
31
|
-
|
32
|
-
#################################
|
33
|
-
# Procfile
|
34
|
-
def procfile(name)
|
35
|
-
content = %{
|
36
|
-
#{name}: env APPNAME=#{name.capitalize} VERBOSE=true MAX_RETRIES=0 WORKING_DIR=#{Dir.pwd}/#{name} rservicebus
|
37
|
-
|
38
|
-
}
|
39
|
-
|
40
|
-
File.write("#{name}/Procfile", content)
|
41
|
-
end
|
42
|
-
|
43
|
-
#################################
|
44
|
-
# MessageHandler
|
45
|
-
def messagehandler(name)
|
46
|
-
content = '
|
47
|
-
class MessageHandler_First
|
48
|
-
|
49
|
-
def handle( msg )
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
end
|
54
|
-
'
|
55
|
-
|
56
|
-
Dir.mkdir("#{name}/MessageHandler")
|
57
|
-
File.write("#{name}/MessageHandler/First.rb", content)
|
58
|
-
end
|
59
|
-
|
60
|
-
#################################
|
61
|
-
# Test
|
62
|
-
def test(name)
|
63
|
-
content = %{
|
64
|
-
require 'test/unit'
|
65
|
-
require './Contract'
|
66
|
-
require './MessageHandler/First'
|
67
|
-
|
68
|
-
|
69
|
-
class Test_MessageHandler_First<MessageHandler_First
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
end
|
74
|
-
|
75
|
-
class FirstTest < Test::Unit::TestCase
|
76
|
-
|
77
|
-
def setup
|
78
|
-
@handler = Test_MessageHandler_First.new
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_Basic
|
82
|
-
@handler.Handle( First.new )
|
83
|
-
|
84
|
-
assert_equal false, @handler.nil?
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
}
|
89
|
-
|
90
|
-
Dir.mkdir("#{name}/test")
|
91
|
-
File.write("#{name}/test/test_First.rb", content)
|
92
|
-
end
|
93
|
-
|
94
|
-
################################################################
|
95
|
-
|
96
|
-
abort "usage: #{File.basename($0)} <name>" if ARGV.length != 1
|
97
|
-
|
98
|
-
#################################
|
99
|
-
name = ARGV[0].downcase
|
100
|
-
|
101
|
-
#################################
|
102
|
-
Dir.mkdir(name)
|
103
|
-
contract(name)
|
104
|
-
rakefile(name)
|
105
|
-
procfile(name)
|
106
|
-
messagehandler(name)
|
107
|
-
test(name)
|
data/bin/rservicebus2-init
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
############################################
|
6
|
-
ContentReadMe = StringIO.new( <<"END_DATA" )
|
7
|
-
#Req
|
8
|
-
|
9
|
-
##What
|
10
|
-
This is the starting point for RServiceBus
|
11
|
-
|
12
|
-
A single client, using the agent to send a message
|
13
|
-
|
14
|
-
A single message handler, running inside rservicebus which receives
|
15
|
-
the message and sends a reply
|
16
|
-
|
17
|
-
The client then picks up the reply
|
18
|
-
|
19
|
-
##How
|
20
|
-
make sure beanstalk is running, then
|
21
|
-
|
22
|
-
run the
|
23
|
-
./run
|
24
|
-
|
25
|
-
command in one terminal
|
26
|
-
|
27
|
-
in a second terminal, run
|
28
|
-
ruby Client.rb
|
29
|
-
END_DATA
|
30
|
-
|
31
|
-
|
32
|
-
############################################
|
33
|
-
ContentClient = StringIO.new( <<"END_DATA" )
|
34
|
-
require "rservicebus"
|
35
|
-
require "rservicebus/Agent"
|
36
|
-
require "./Contract"
|
37
|
-
|
38
|
-
agent = RServiceBus::Agent.new.getAgent( URI.parse( "beanstalk://localhost" ) )
|
39
|
-
|
40
|
-
1.upto(2) do |request_nbr|
|
41
|
-
agent.sendMsg(HelloWorld.new( "Hello World! " + request_nbr.to_s ), "HelloWorld", "helloResponse")
|
42
|
-
end
|
43
|
-
|
44
|
-
msg = agent.checkForReply( "helloResponse" )
|
45
|
-
puts msg
|
46
|
-
msg = agent.checkForReply( "helloResponse" )
|
47
|
-
puts msg
|
48
|
-
END_DATA
|
49
|
-
|
50
|
-
|
51
|
-
############################################
|
52
|
-
ContentRun = StringIO.new( <<"END_DATA" )
|
53
|
-
APPNAME=HelloWorld \
|
54
|
-
ERROR_QUEUE_NAME=error \
|
55
|
-
MAX_RETRIES=2 \
|
56
|
-
VERBOSE=true \
|
57
|
-
WORKING_DIR=./ \
|
58
|
-
rservicebus
|
59
|
-
END_DATA
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
############################################
|
64
|
-
ContentContract = StringIO.new( <<"END_DATA" )
|
65
|
-
class HelloWorld
|
66
|
-
attr_reader :name
|
67
|
-
def initialize( name )
|
68
|
-
@name = name
|
69
|
-
end
|
70
|
-
end
|
71
|
-
END_DATA
|
72
|
-
|
73
|
-
|
74
|
-
############################################
|
75
|
-
ContentMessageHandler = StringIO.new( <<"END_DATA" )
|
76
|
-
class MessageHandler_HelloWorld
|
77
|
-
|
78
|
-
attr_accessor :Bus
|
79
|
-
|
80
|
-
def Handle( msg )
|
81
|
-
#raise "Manually generated error for testng"
|
82
|
-
puts "Handling Hello World: " + msg.name
|
83
|
-
@Bus.Reply( "Hey. " + msg.name )
|
84
|
-
end
|
85
|
-
end
|
86
|
-
END_DATA
|
87
|
-
|
88
|
-
################################################################################################
|
89
|
-
class Init
|
90
|
-
|
91
|
-
def Run
|
92
|
-
IO.write( 'README.md', ContentReadMe.string );
|
93
|
-
IO.write( 'Client.rb', ContentClient.string );
|
94
|
-
IO.write( 'Contract.rb', ContentContract.string );
|
95
|
-
IO.write( 'run', ContentRun.string );
|
96
|
-
|
97
|
-
Dir.mkdir('./MessageHandler') unless Dir.exists? './MessageHandler'
|
98
|
-
;
|
99
|
-
IO.write( 'MessageHandler/HelloWorld.rb', ContentMessageHandler.string );
|
100
|
-
end
|
101
|
-
|
102
|
-
end
|
103
|
-
|
104
|
-
Init.new.Run
|
data/bin/rservicebus2-transport
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# The application 'rservicebus-transport' is installed as part of a gem, and
|
4
|
-
# this file is here to facilitate running it.
|
5
|
-
#
|
6
|
-
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rservicebus'
|
9
|
-
require 'rservicebus/Transporter'
|
10
|
-
|
11
|
-
def run_rservicebus_transport()
|
12
|
-
RServiceBus::Transporter.new().Run()
|
13
|
-
end
|
14
|
-
|
15
|
-
run_rservicebus_transport
|
16
|
-
|
data/bin/send_empty_message
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'rservicebus'
|
4
|
-
require 'rservicebus/Agent'
|
5
|
-
|
6
|
-
|
7
|
-
abort( "Usage: #{File.basename($0)} <Msg Name> <Queue Name> [Response Queue Name] [Beanstalk Host]" ) unless ARGV.length >=2 && ARGV.length <=4
|
8
|
-
msg_name = ARGV[0]
|
9
|
-
queue_name = ARGV[1]
|
10
|
-
response_queue_name = "#{queue_name}Response" if ARGV.length >= 3
|
11
|
-
beanstalkHost = 'beanstalk://localhost' if ARGV.length <= 4
|
12
|
-
|
13
|
-
agent = RServiceBus::Agent.new.getAgent( URI.parse( beanstalkHost) )
|
14
|
-
msg = RServiceBus.createAnonymousClass( msg_name )
|
15
|
-
agent.sendMsg(msg, queue_name, response_queue_name)
|
data/lib/rservicebus/agent.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
module RServiceBus
|
2
|
-
class QueueNotFoundForMsg < StandardError
|
3
|
-
end
|
4
|
-
|
5
|
-
# A means for a stand-alone process to interact with the bus, without being
|
6
|
-
# a full rservicebus application
|
7
|
-
class Agent
|
8
|
-
def get_agent(uri)
|
9
|
-
ENV['RSBMQ'] = uri.to_s
|
10
|
-
|
11
|
-
RServiceBus.rlog '*** Agent.getAgent has been deprecated. Set the
|
12
|
-
environment variable, RSBMQ, and simply create the class'
|
13
|
-
Agent.new
|
14
|
-
end
|
15
|
-
|
16
|
-
def initialize
|
17
|
-
@mq = MQ.get
|
18
|
-
end
|
19
|
-
|
20
|
-
# Put a msg on the bus
|
21
|
-
#
|
22
|
-
# @param [Object] messageObj The msg to be sent
|
23
|
-
# @param [String] queueName the name of the queue to be send the msg to
|
24
|
-
# @param [String] returnAddress the name of a queue to send replies to
|
25
|
-
def send_msg(message_obj, queue_name, return_address = nil)
|
26
|
-
fail QueueNotFoundForMsg, message_obj.class.name if queue_name.nil?
|
27
|
-
|
28
|
-
msg = RServiceBus::Message.new(message_obj, return_address)
|
29
|
-
if queue_name.index('@').nil?
|
30
|
-
q = queue_name
|
31
|
-
else
|
32
|
-
parts = queueName.split('@')
|
33
|
-
msg.set_remote_queue_name(parts[0])
|
34
|
-
msg.set_remote_host_name(parts[1])
|
35
|
-
q = 'transport-out'
|
36
|
-
end
|
37
|
-
|
38
|
-
serialized_object = YAML.dump(msg)
|
39
|
-
|
40
|
-
@mq.send(q, serialized_object)
|
41
|
-
end
|
42
|
-
|
43
|
-
# Gives an agent the means to receive a reply
|
44
|
-
#
|
45
|
-
# @param [String] queueName the name of the queue to monitor for messages
|
46
|
-
def check_for_reply(queue_name)
|
47
|
-
@mq.subscribe(queue_name)
|
48
|
-
body = @mq.pop
|
49
|
-
@msg = YAML.load(body)
|
50
|
-
@mq.ack
|
51
|
-
@msg.msg
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
require 'uri'
|
2
|
-
|
3
|
-
module RServiceBus
|
4
|
-
# Wrapper base class for resources used by applications, allowing rservicebus
|
5
|
-
# to configure the resource - dependency injection.
|
6
|
-
class AppResource
|
7
|
-
attr_reader :connection
|
8
|
-
|
9
|
-
# The method which actually connects to the resource.
|
10
|
-
def connect(_uri)
|
11
|
-
fail 'Method, connect, needs to be implemented for resource'
|
12
|
-
end
|
13
|
-
|
14
|
-
def _connect
|
15
|
-
@connection = connect(@uri)
|
16
|
-
RServiceBus.rlog "#{self.class.name}. Connected to, #{@uri}"
|
17
|
-
end
|
18
|
-
|
19
|
-
def get_resource
|
20
|
-
@connection
|
21
|
-
end
|
22
|
-
|
23
|
-
# Resources are attached, and can be specified using the URI syntax.
|
24
|
-
# @param [String] uri a location for the resource to which we will attach,
|
25
|
-
# eg redis://127.0.0.1/foo
|
26
|
-
def initialize(host, uri)
|
27
|
-
@host = host
|
28
|
-
@uri = uri
|
29
|
-
# Do a connect / disconnect loop on startup to validate the connection
|
30
|
-
_connect
|
31
|
-
finished
|
32
|
-
end
|
33
|
-
|
34
|
-
# A notification that ocurs after getResource, to allow cleanup
|
35
|
-
def finished
|
36
|
-
@connection.close
|
37
|
-
end
|
38
|
-
|
39
|
-
# At least called in the Host rescue block, to ensure all network links are
|
40
|
-
# healthy
|
41
|
-
def reconnect
|
42
|
-
begin
|
43
|
-
finished
|
44
|
-
rescue StandardError => e
|
45
|
-
puts '** AppResource. An error was raised while closing connection
|
46
|
-
to, ' + @uri
|
47
|
-
puts 'Message: ' + e.message
|
48
|
-
puts e.backtrace
|
49
|
-
end
|
50
|
-
_connect
|
51
|
-
end
|
52
|
-
|
53
|
-
# Transaction Semantics
|
54
|
-
def begin
|
55
|
-
end
|
56
|
-
|
57
|
-
# Transaction Semantics
|
58
|
-
def commit
|
59
|
-
end
|
60
|
-
|
61
|
-
# Transaction Semantics
|
62
|
-
def rollback
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module RServiceBus
|
2
|
-
# AppResourceDir
|
3
|
-
class AppResourceDir < AppResource
|
4
|
-
def connect(uri)
|
5
|
-
begin
|
6
|
-
input_dir = Dir.new(uri.path)
|
7
|
-
unless File.writable?(uri.path)
|
8
|
-
puts "*** Warning. Directory is not writable, #{uri.path}."
|
9
|
-
puts "*** Warning. Make the directory, #{uri.path}, writable and try
|
10
|
-
again."
|
11
|
-
end
|
12
|
-
rescue Errno::ENOENT
|
13
|
-
puts "***** Directory does not exist, #{uri.path}."
|
14
|
-
puts "***** Create the directory, #{uri.path}, and try again."
|
15
|
-
puts "***** eg, mkdir #{uri.path}"
|
16
|
-
abort
|
17
|
-
rescue Errno::ENOTDIR
|
18
|
-
puts "***** The specified path does not point to a directory,
|
19
|
-
#{uri.path}."
|
20
|
-
puts "***** Either repoint path to a directory, or remove, #{uri.path},
|
21
|
-
and create it as a directory."
|
22
|
-
puts "***** eg, rm #{uri.path} && mkdir #{uri.path}"
|
23
|
-
abort
|
24
|
-
end
|
25
|
-
|
26
|
-
input_dir
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|