Package coilmq :: Module topic :: Class TopicManager
[frames] | no frames]

Class TopicManager

object --+
         |
        TopicManager

Class that manages distribution of messages to topic subscribers.

This class uses threading.RLock to guard the public methods. This is probably a bit excessive, given 1) the actomic nature of basic dict read/write operations and 2) the fact that most of the internal data structures are keying off of the STOMP connection, which is going to be thread-isolated. That said, this seems like the technically correct approach and should increase the chance of this code being portable to non-GIL systems.

Instance Methods
 
__init__(self)
x.__init__(...) initializes x; see help(type(x)) for signature
 
close(self)
Closes all resources associated with this topic manager.
 
subscribe(self, connection, destination)
Subscribes a connection to the specified topic destination.
 
unsubscribe(self, connection, destination)
Unsubscribes a connection from the specified topic destination.
 
disconnect(self, connection)
Removes a subscriber connection.
 
send(self, message)
Sends a message to all subscribers of destination.

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self)
(Constructor)

 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

close(self)

 

Closes all resources associated with this topic manager.

(Currently this is simply here for API conformity w/ coilmq.queue.QueueManager.)

Decorators:
  • @synchronized

subscribe(self, connection, destination)

 

Subscribes a connection to the specified topic destination.

Parameters:
Decorators:
  • @synchronized

unsubscribe(self, connection, destination)

 

Unsubscribes a connection from the specified topic destination.

Parameters:
  • connection (coilmq.server.StompConnection) - The client connection to unsubscribe.
  • destination (str) - The topic destination (e.g. '/topic/foo')
Decorators:
  • @synchronized

disconnect(self, connection)

 

Removes a subscriber connection.

Parameters:
Decorators:
  • @synchronized

send(self, message)

 

Sends a message to all subscribers of destination.

Parameters:
  • message (stompclient.frame.Frame) - The message frame. (The frame will be modified to set command to MESSAGE and set a message id.)
Decorators:
  • @synchronized