Class: RServiceBus::EndpointMapping
- Inherits:
-
Object
- Object
- RServiceBus::EndpointMapping
- Defined in:
- lib/rservicebus/EndpointMapping.rb
Overview
Marshals data for message end points
Expected format; <msg mame 1>:<end point 1>;<msg mame 2>:<end point 2>
Instance Method Summary collapse
- #Configure(localQueueName = nil) ⇒ Object
- #configureMapping(mapping) ⇒ Object
- #get(msgName) ⇒ Object
- #getSubscriptionEndpoints ⇒ Object
- #getValue(name) ⇒ Object
-
#initialize ⇒ EndpointMapping
constructor
A new instance of EndpointMapping.
- #log(string, ver = false) ⇒ Object
Constructor Details
#initialize ⇒ EndpointMapping
Returns a new instance of EndpointMapping.
60 61 62 |
# File 'lib/rservicebus/EndpointMapping.rb', line 60 def initialize @endpoints=Hash.new end |
Instance Method Details
#Configure(localQueueName = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rservicebus/EndpointMapping.rb', line 39 def Configure( localQueueName=nil ) self.log('EndpointMapping.Configure') @queueNameList = [] @queueNameList << localQueueName unless localQueueName.nil? unless self.getValue('MESSAGE_ENDPOINT_MAPPING').nil? then log('*** MESSAGE_ENDPOINT_MAPPING environment variable was detected') log("*** You may have intended MESSAGE_ENDPOINT_MAPPINGS, note the 'S' on the end") end mappings = self.getValue('MESSAGE_ENDPOINT_MAPPINGS') return self if mappings.nil? mappings.split(';').each do |mapping| self.configureMapping( mapping ) end return self end |
#configureMapping(mapping) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/rservicebus/EndpointMapping.rb', line 17 def configureMapping( mapping ) match = mapping.match( /(.+):(.+)/ ) if match.nil? then log 'Mapping string provided is invalid' log "The entire mapping string is: #{mapping}" log "*** Could not find ':' in mapping entry, #{line}" exit() end RServiceBus.rlog "EndpointMapping.configureMapping: #{match[1]}, #{match[2]}" @endpoints[match[1]] = match[2] @queueNameList.each do |q| if q != match[2] && q.downcase == match[2].downcase then log('*** Two queues specified with only case sensitive difference.') log( "*** #{q} != #{match[2]}" ) log('*** If you meant these queues to be the same, please match case and restart the bus.') end end @queueNameList << match[2] end |
#get(msgName) ⇒ Object
64 65 66 67 68 69 70 |
# File 'lib/rservicebus/EndpointMapping.rb', line 64 def get( msgName ) if @endpoints.has_key?( msgName ) then return @endpoints[msgName] end return nil; end |
#getSubscriptionEndpoints ⇒ Object
72 73 74 |
# File 'lib/rservicebus/EndpointMapping.rb', line 72 def getSubscriptionEndpoints return @endpoints.keys.select { |el| el.end_with?('Event') } end |
#getValue(name) ⇒ Object
9 10 11 |
# File 'lib/rservicebus/EndpointMapping.rb', line 9 def getValue( name ) return RServiceBus.getValue( name ) end |
#log(string, ver = false) ⇒ Object
13 14 15 |
# File 'lib/rservicebus/EndpointMapping.rb', line 13 def log( string, ver=false ) RServiceBus.log( string ) end |