Class: TorqueBox::Messaging::Dispatcher
- Inherits:
-
Object
- Object
- TorqueBox::Messaging::Dispatcher
- Defined in:
- lib/torquebox/messaging/dispatcher.rb
Overview
A service that may be configured with mappings of message consumers to destinations
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ Dispatcher
constructor
A new instance of Dispatcher.
-
#map(consumer, destination, options = {}) ⇒ Object
Option keys are :filter and :config, either as symbol or string.
- #processors ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ Dispatcher
Returns a new instance of Dispatcher.
30 31 32 33 |
# File 'lib/torquebox/messaging/dispatcher.rb', line 30 def initialize( = {}, &block) = instance_eval &block if block_given? end |
Instance Method Details
#map(consumer, destination, options = {}) ⇒ Object
Option keys are :filter and :config, either as symbol or string
36 37 38 39 40 41 |
# File 'lib/torquebox/messaging/dispatcher.rb', line 36 def map consumer, destination, = {} = .inject({}) {|h,(k,v)| h[k.to_s]=v; h} # jruby won't convert symbols to strings processor = org.torquebox.messaging.deployers::MessagingYamlParsingDeployer::Parser.subscribe(consumer.to_s, destination.to_s, ) processor.ruby_require_path = nil if consumer.is_a? Class processors << processor end |
#processors ⇒ Object
63 64 65 |
# File 'lib/torquebox/messaging/dispatcher.rb', line 63 def processors @processors ||= [] end |
#start ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/torquebox/messaging/dispatcher.rb', line 43 def start container.start @deployment = container.deploy( object_id.to_s ) unit = container.deployment_unit( @deployment.name ) processors.each do |processor| org.torquebox.mc::AttachmentUtils.multipleAttach( unit, processor, processor.name ) end = org.torquebox.base.metadata::RubyApplicationMetaData.new .setApplicationName( "none" ) .setEnvironmentName( ENV['TORQUEBOX_ENV'] || 'development' ) .setRoot( org.jboss.vfs::VFS.getChild( Dir.pwd ) ) unit.addAttachment( org.torquebox.base.metadata::RubyApplicationMetaData.java_class, ) container.process_deployments(true) end |
#stop ⇒ Object
58 59 60 61 |
# File 'lib/torquebox/messaging/dispatcher.rb', line 58 def stop container.undeploy( @deployment ) container.stop end |