Skip to content
This repository has been archived by the owner on Apr 19, 2023. It is now read-only.

Commit

Permalink
[TORQUE-1090] Improper assigning of the name instance variable in Tor…
Browse files Browse the repository at this point in the history
…queBox::Messaging::Queue and Topic when using the javax.jms.Destination as the destination

Fixes the issue where TorqueBox.fetch sends javax.jms.Destination object
as the first argument of the constructor in TorqueBox::Messaging::Queue
(and Topic) class. The TorqueBox::Messaging::Queue class stores
thisobject in @java_destination instance variable instead of messing the @name
variable.
  • Loading branch information
goldmann committed May 9, 2013
1 parent e2eda43 commit 6843029
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
22 changes: 18 additions & 4 deletions gems/messaging/lib/torquebox/messaging/destination.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Destination

attr_reader :connection_factory
attr_reader :name
attr_reader :java_destination
attr_accessor :enumerable_options
attr_accessor :connect_options

Expand All @@ -38,9 +39,8 @@ class Destination
:critical => 9
}

def _dump(depth)
return self.name.queue_name if self.name.respond_to?( :queue_name )
self.name.to_s
def _dump(level)
to_s
end

def self._load(str)
Expand All @@ -63,7 +63,21 @@ def initialize(destination, connection_factory_or_options = nil)
@connection_factory = ConnectionFactory.new( connection_factory_or_options )
@connect_options = {}
end
@name = destination


if destination.is_a?(javax.jms.Destination )
if destination.is_a?(javax.jms.Queue)
@name = destination.queue_name
else
@name = destination.topic_name
end

@java_destination = destination
else
@name = destination
end


@enumerable_options = {}
end

Expand Down
2 changes: 1 addition & 1 deletion gems/messaging/lib/torquebox/messaging/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ def to_s
# queue.
def with_queue_control
TorqueBox::ServiceRegistry.lookup("jboss.messaging.default") do |server|
yield server.management_service.get_resource("jms.queue.#{_dump(nil)}")
yield server.management_service.get_resource("jms.queue.#{@name}")
end
end
end
Expand Down
11 changes: 3 additions & 8 deletions gems/messaging/lib/torquebox/messaging/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,9 @@ def create_browser(*args)
end

def java_destination(destination)
java_destination = destination.name

unless java_destination.is_a?( javax.jms.Destination )
meth = destination.is_a?( Queue ) ? :create_queue : :create_topic
java_destination = @jms_session.send( meth, java_destination )
end

java_destination
return destination.java_destination unless destination.java_destination.nil?
meth = destination.is_a?( Queue ) ? :create_queue : :create_topic
@jms_session.send( meth, destination.name )
end

def self.canonical_ack_mode(ack_mode)
Expand Down

0 comments on commit 6843029

Please sign in to comment.