You can open as many subscriptions per STOMP session as you like,
and you would never want to send two CONNECT frames over the same
wire-level connection, which is why there is an
@exclusive wrapper around the
connect() method. If you want to run more than one STOMP session,
then you'll have to instantiate a dedicated
async.Stomp connection for each STOMP
session.
I strongly recommend the
@inlineCallbacks
style which lets you write code in a pseudo-synchronous style. I think that a good start is the transformer example (which does receive
and send frames):
@defer.inlineCallbacks
def run(self):
client = yield Stomp(self.config).connect()
headers = {
StompSpec.ACK_HEADER: StompSpec.ACK_CLIENT_INDIVIDUAL,
'activemq.prefetchSize': '100',
}
client.subscribe(self.IN_QUEUE, headers, listener=SubscriptionListener(self.addOne, errorDestination=self.ERROR_QUEUE))
def addOne(self, client, frame):
data = json.loads(frame.body)
data['count'] += 1
client.send(self.OUT_QUEUE, json.dumps(data))