rservicebus 0.1.18 → 0.1.19
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rservicebus.rb +1 -0
- data/lib/rservicebus/Audit.rb +35 -0
- data/lib/rservicebus/Host.rb +1 -1
- data/lib/rservicebus/helper_functions.rb +31 -4
- metadata +3 -2
data/lib/rservicebus.rb
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
module RServiceBus
|
2
|
+
|
3
|
+
class Audit
|
4
|
+
|
5
|
+
def initialize( mq )
|
6
|
+
@mq = mq
|
7
|
+
auditQueueName = RServiceBus.getValue( "AUDIT_QUEUE_NAME" )
|
8
|
+
if auditQueueName.nil? then
|
9
|
+
@forwardSentMessagesTo = RServiceBus.getValue( "FORWARD_SENT_MESSAGES_TO" )
|
10
|
+
@forwardReceivedMessagesTo = RServiceBus.getValue( "FORWARD_RECEIVED_MESSAGES_TO" )
|
11
|
+
else
|
12
|
+
@forwardSentMessagesTo = auditQueueName
|
13
|
+
@forwardReceivedMessagesTo = auditQueueName
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def auditToQueue( obj )
|
18
|
+
@mq.sendMsg(obj, @forwardSentMessagesTo)
|
19
|
+
end
|
20
|
+
|
21
|
+
def auditOutgoing( obj )
|
22
|
+
if !@forwardSentMessagesTo.nil? then
|
23
|
+
self.auditToQueue( obj )
|
24
|
+
end
|
25
|
+
end
|
26
|
+
def auditIncoming( obj )
|
27
|
+
if !@forwardReceivedMessagesTo.nil? then
|
28
|
+
self.auditToQueue( obj )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
data/lib/rservicebus/Host.rb
CHANGED
@@ -373,7 +373,7 @@ module RServiceBus
|
|
373
373
|
serialized_object = YAML::dump(rMsg)
|
374
374
|
self._SendAlreadyWrappedAndSerialised( serialized_object, q )
|
375
375
|
end
|
376
|
-
|
376
|
+
|
377
377
|
def sendQueuedMsgs
|
378
378
|
@queueForMsgsToBeSentOnComplete.each do |row|
|
379
379
|
self._SendNeedsWrapping( row["msg"], row["queueName"] )
|
@@ -21,7 +21,7 @@ module RServiceBus
|
|
21
21
|
puts "[#{type}] #{timestamp} :: #{string}"
|
22
22
|
# end
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def RServiceBus.createAnonymousClass( name_for_class )
|
26
26
|
newAnonymousClass = Class.new(Object)
|
27
27
|
Object.const_set( name_for_class, newAnonymousClass )
|
@@ -38,11 +38,12 @@ module RServiceBus
|
|
38
38
|
require "rservicebus/EndpointMapping"
|
39
39
|
endpointMapping = EndpointMapping.new
|
40
40
|
endpointMapping.Configure
|
41
|
-
queueName = endpointMapping.get( msg.class.name )
|
41
|
+
queueName = endpointMapping.get( msg.class.name )
|
42
42
|
|
43
|
-
agent = RServiceBus::Agent.new.getAgent( URI.parse( "beanstalk://127.0.0.1:11300" ) )
|
43
|
+
agent = RServiceBus::Agent.new.getAgent( URI.parse( "beanstalk://127.0.0.1:11300" ) )
|
44
|
+
Audit.new( agent ).audit( msg )
|
44
45
|
agent.sendMsg(msg, queueName, responseQueue)
|
45
|
-
|
46
|
+
|
46
47
|
rescue QueueNotFoundForMsg=>e
|
47
48
|
msg = "\n"
|
48
49
|
msg = "#{msg}*** Queue not found for, #{e.message}\n"
|
@@ -51,4 +52,30 @@ module RServiceBus
|
|
51
52
|
raise StandardError.new( msg )
|
52
53
|
end
|
53
54
|
|
55
|
+
def RServiceBus.sendMsg( msg, responseQueue="agent" )
|
56
|
+
require "rservicebus/EndpointMapping"
|
57
|
+
endpointMapping = EndpointMapping.new
|
58
|
+
endpointMapping.Configure
|
59
|
+
queueName = endpointMapping.get( msg.class.name )
|
60
|
+
|
61
|
+
agent = RServiceBus::Agent.new.getAgent( URI.parse( "beanstalk://127.0.0.1:11300" ) )
|
62
|
+
Audit.new( agent ).auditOutgoing( msg )
|
63
|
+
agent.sendMsg(msg, queueName, responseQueue)
|
64
|
+
|
65
|
+
rescue QueueNotFoundForMsg=>e
|
66
|
+
msg = "\n"
|
67
|
+
msg = "#{msg}*** Queue not found for, #{e.message}\n"
|
68
|
+
msg = "#{msg}*** Ensure you have an environment variable set for this Message Type, eg, \n"
|
69
|
+
msg = "#{msg}*** MESSAGE_ENDPOINT_MAPPINGS=#{e.message}:<QueueName>\n"
|
70
|
+
raise StandardError.new( msg )
|
71
|
+
end
|
72
|
+
|
73
|
+
def RServiceBus.checkForReply( queueName )
|
74
|
+
agent = RServiceBus::Agent.new.getAgent( URI.parse( "beanstalk://127.0.0.1:11300" ) )
|
75
|
+
msg = agent.checkForReply( queueName )
|
76
|
+
Audit.new( agent ).auditIncoming( msg )
|
77
|
+
|
78
|
+
return msg
|
79
|
+
end
|
80
|
+
|
54
81
|
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.1.
|
4
|
+
version: 0.1.19
|
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-09-
|
12
|
+
date: 2013-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby interpretation of NServiceBus
|
15
15
|
email: guy@guyirvine.com
|
@@ -38,6 +38,7 @@ files:
|
|
38
38
|
- lib/rservicebus/AppResource/Smb.rb
|
39
39
|
- lib/rservicebus/AppResource/State.rb
|
40
40
|
- lib/rservicebus/AppResource.rb
|
41
|
+
- lib/rservicebus/Audit.rb
|
41
42
|
- lib/rservicebus/Config.rb
|
42
43
|
- lib/rservicebus/ConfigureAppResource.rb
|
43
44
|
- lib/rservicebus/ConfigureMonitor.rb
|