rservicebus 0.0.58 → 0.0.59
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/SendEmptyMessage +1 -7
- data/lib/rservicebus/Host.rb +26 -4
- data/lib/rservicebus/Message.rb +7 -0
- data/lib/rservicebus/helper_functions.rb +6 -0
- metadata +2 -2
data/bin/SendEmptyMessage
CHANGED
@@ -3,12 +3,6 @@
|
|
3
3
|
require "rservicebus"
|
4
4
|
require "rservicebus/Agent"
|
5
5
|
|
6
|
-
def CreateAnonymousClass( name_for_class )
|
7
|
-
newAnonymousClass = Class.new(Object)
|
8
|
-
Object.const_set( name_for_class, newAnonymousClass )
|
9
|
-
return Object.const_get( name_for_class ).new
|
10
|
-
end
|
11
|
-
|
12
6
|
|
13
7
|
abort( "Usage: #{File.basename($0)} <Msg Name> <Queue Name> [Response Queue Name] [Beanstalk Host]" ) unless ARGV.length >=2 && ARGV.length <=4
|
14
8
|
msg_name = ARGV[0]
|
@@ -17,5 +11,5 @@ response_queue_name = "#{queue_name}Response" if ARGV.length >= 3
|
|
17
11
|
beanstalkHost = "beanstalk://localhost" if ARGV.length == 4
|
18
12
|
|
19
13
|
agent = RServiceBus::Agent.new.getAgent( URI.parse( "beanstalk://localhost" ) )
|
20
|
-
msg =
|
14
|
+
msg = RServiceBus.createAnonymousClass( msg_name )
|
21
15
|
agent.sendMsg(msg, queue_name, response_queue_name)
|
data/lib/rservicebus/Host.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
module RServiceBus
|
2
2
|
|
3
3
|
|
4
|
+
class NoHandlerFound<StandardError
|
5
|
+
end
|
6
|
+
class ClassNotFoundForMsg<StandardError
|
7
|
+
end
|
4
8
|
class NoMsgToProcess<StandardError
|
5
9
|
end
|
6
10
|
|
@@ -212,6 +216,22 @@ $:.unshift path
|
|
212
216
|
end
|
213
217
|
end
|
214
218
|
@mq.ack
|
219
|
+
rescue ClassNotFoundForMsg => e
|
220
|
+
puts "*** Class not found for msg, #{e.message}"
|
221
|
+
puts "*** Ensure, #{e.message}, is defined in Contract.rb, most likely as 'Class #{e.message} end"
|
222
|
+
|
223
|
+
@msg.addErrorMsg( @config.localQueueName, e.message )
|
224
|
+
serialized_object = YAML::dump(@msg)
|
225
|
+
self._SendAlreadyWrappedAndSerialised(serialized_object, @config.errorQueueName)
|
226
|
+
@mq.ack
|
227
|
+
rescue NoHandlerFound => e
|
228
|
+
puts "*** Handler not found for msg, #{e.message}"
|
229
|
+
puts "*** Ensure a handler named, #{e.message}, is present in the MessageHandler directory."
|
230
|
+
|
231
|
+
@msg.addErrorMsg( @config.localQueueName, e.message )
|
232
|
+
serialized_object = YAML::dump(@msg)
|
233
|
+
self._SendAlreadyWrappedAndSerialised(serialized_object, @config.errorQueueName)
|
234
|
+
@mq.ack
|
215
235
|
rescue Exception => e
|
216
236
|
sleep 0.5
|
217
237
|
|
@@ -222,6 +242,11 @@ $:.unshift path
|
|
222
242
|
|
223
243
|
tempHandlerList = Hash.new
|
224
244
|
tempResourceList = Hash.new
|
245
|
+
puts @msg.to_s
|
246
|
+
puts @msg.msg.to_s
|
247
|
+
puts @msg.msg.class.to_s
|
248
|
+
puts @msg.msg.class.name
|
249
|
+
|
225
250
|
@handlerList[@msg.msg.class.name].each do |handler|
|
226
251
|
tempHandlerList[handler.class.name] = handler
|
227
252
|
@resourceByHandlerNameList[handler.class.name].each do |resource|
|
@@ -293,10 +318,7 @@ $:.unshift path
|
|
293
318
|
handlerList = @handlerList[msgName]
|
294
319
|
|
295
320
|
if handlerList == nil then
|
296
|
-
|
297
|
-
# puts "No handler found for: " + msgName
|
298
|
-
# puts YAML::dump(@msg)
|
299
|
-
raise "No Handler Found"
|
321
|
+
raise NoHandlerFound.new( msgName )
|
300
322
|
|
301
323
|
else
|
302
324
|
log "Handler found for: " + msgName, true
|
data/lib/rservicebus/Message.rb
CHANGED
@@ -41,6 +41,13 @@ class Message
|
|
41
41
|
# @return [Object] The msg to be sent
|
42
42
|
def msg
|
43
43
|
return YAML::load( @_msg )
|
44
|
+
rescue ArgumentError => e
|
45
|
+
raise e if e.message.index( "undefined class/module " ).nil?
|
46
|
+
|
47
|
+
puts e.message
|
48
|
+
msg_name = e.message.sub( "undefined class/module ", "" )
|
49
|
+
|
50
|
+
raise ClassNotFoundForMsg.new( msg_name )
|
44
51
|
end
|
45
52
|
|
46
53
|
end
|
@@ -21,4 +21,10 @@ module RServiceBus
|
|
21
21
|
# end
|
22
22
|
end
|
23
23
|
|
24
|
+
def RServiceBus.createAnonymousClass( name_for_class )
|
25
|
+
newAnonymousClass = Class.new(Object)
|
26
|
+
Object.const_set( name_for_class, newAnonymousClass )
|
27
|
+
return Object.const_get( name_for_class ).new
|
28
|
+
end
|
29
|
+
|
24
30
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rservicebus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.59
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby interpretation of NServiceBus
|
15
15
|
email: guy@guyirvine.com
|