Class: TorqueBox::Stomp::JmsStomplet::MessageListener Private
- Inherits:
-
Object
- Object
- TorqueBox::Stomp::JmsStomplet::MessageListener
- Defined in:
- lib/torquebox/stomp/jms_stomplet.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(subscriber, options = {}) ⇒ MessageListener
constructor
private
A new instance of MessageListener.
- #onMessage(jms_message) ⇒ Object private
Constructor Details
#initialize(subscriber, options = {}) ⇒ MessageListener
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of MessageListener.
110 111 112 113 |
# File 'lib/torquebox/stomp/jms_stomplet.rb', line 110 def initialize(subscriber, ={}) @subscriber = subscriber @encoding = [:encoding] end |
Instance Method Details
#onMessage(jms_message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/torquebox/stomp/jms_stomplet.rb', line 115 def onMessage() content = TorqueBox::Messaging::Message.new( ).decode ( content = TorqueBox::Codecs.encode( content, @encoding ) ) if @encoding = TorqueBox::Stomp::Message.new( content ) .property_names.each do |name| value = .getObjectProperty( name ).to_s .headers.put( name.to_s.to_java( java.lang.String ), value.to_java( java.lang.String) ) if value end if ( .headers[ 'content-type' ] == nil ) if ( @encoding == :json ) .headers.put( "content-type", "application/json" ) else .headers.put( "content-type", "text/plain" ) end end @subscriber.send( ) end |