Skip to content

Commit

Permalink
Merge pull request #244 from zoufou/v0.6-beta
Browse files Browse the repository at this point in the history
v0.6b35
  • Loading branch information
farirat committed Jul 7, 2015
2 parents f8bcfeb + e793c4a commit 0eb1382
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ python:
# Command to install dependencies
install:
- python setup.py sdist
- sudo pip install dist/jasmin-0.6b34.tar.gz
- sudo pip install dist/jasmin-0.6b35.tar.gz
- sudo cp misc/config/init-script/jasmind-ubuntu /etc/init.d/jasmind
- sudo update-rc.d jasmind defaults
# Commands to run tests:
Expand Down
2 changes: 1 addition & 1 deletion jasmin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

MAJOR = 0
MINOR = 6
PATCH = 34
PATCH = 35
META = 'b'

def get_version():
Expand Down
28 changes: 18 additions & 10 deletions jasmin/managers/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ def perspective_connector_start(self, cid):
try:
# Using the same consumerTag will prevent getting multiple consumers on the same queue
# This can resolve the dark hole issue #234

# Stop the queue consumer if any
if connector['consumer_tag'] is not None:
self.log.debug('Stopping submit_sm_q consumer in connector [%s]', cid)
yield self.amqpBroker.chan.basic_cancel(consumer_tag = connector['consumer_tag'])

# Start a new consumer
yield self.amqpBroker.chan.basic_consume(queue = submit_sm_queue,
no_ack = False,
consumer_tag = consumerTag)
Expand Down Expand Up @@ -372,6 +379,17 @@ def perspective_connector_stop(self, cid, delQueues = False):
if connector is None:
self.log.error('Trying to stop a connector with an unknown cid: %s', cid)
defer.returnValue(False)

# Stop the queue consumer
if connector['consumer_tag'] is not None:
self.log.debug('Stopping submit_sm_q consumer in connector [%s]', cid)
yield self.amqpBroker.chan.basic_cancel(consumer_tag = connector['consumer_tag'])

# Cleaning
self.log.debug('Cleaning objects in connector [%s]', cid)
connector['submit_sm_q'] = None
connector['consumer_tag'] = None

if connector['service'].running == 0:
self.log.error('Connector [%s] is already stopped.', cid)
defer.returnValue(False)
Expand All @@ -397,17 +415,7 @@ def perspective_connector_stop(self, cid, delQueues = False):
# Stop timers in message listeners
self.log.debug('Clearing sm_listener timers in connector [%s]', cid)
connector['sm_listener'].clearAllTimers()

# Stop the queue consumer
if connector['consumer_tag'] is not None:
self.log.debug('Stopping submit_sm_q consumer in connector [%s]', cid)
yield self.amqpBroker.chan.basic_cancel(consumer_tag = connector['consumer_tag'])

# Cleaning
self.log.debug('Cleaning objects in connector [%s]', cid)
connector['sm_listener'].submit_sm_q = None
connector['submit_sm_q'] = None
connector['consumer_tag'] = None

# Stop SMPP connector
connector['service'].stopService()
Expand Down
5 changes: 3 additions & 2 deletions jasmin/managers/test/test_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ def test_start_sameconnector_twice_with_reconnecting_on_failure(self):
def test_start_sameconnector_twice_with_noreconnecting_on_failure(self):
"""It was discovered that starting the connector twice would lead
to a multiple consumers on same queue, as of now, starting connector
twice is no more permitted
twice will cancel current consumer and reconsume again
Related to #234"""

yield self.connect('127.0.0.1', self.pbPort)
Expand All @@ -475,7 +475,7 @@ def test_start_sameconnector_twice_with_noreconnecting_on_failure(self):
yield self.start(localConfig.id)
startRet = yield self.start(localConfig.id)

self.assertEqual(False, startRet)
self.assertEqual(True, startRet)

yield self.stopall()

Expand Down Expand Up @@ -983,6 +983,7 @@ def test_deliverSm(self):
# Bind to deliver.sm.CID
routingKey = 'deliver.sm.%s' % self.defaultConfig.id
queueName = 'test_deliverSm'
yield self.amqpBroker.chan.exchange_declare(exchange='messaging', type='topic')
yield self.amqpBroker.named_queue_declare(queue=queueName, exclusive = True, auto_delete = True)
yield self.amqpBroker.chan.queue_bind(queue=queueName, exchange="messaging", routing_key=routingKey)

Expand Down
4 changes: 3 additions & 1 deletion jasmin/protocols/cli/test/test_smppccm.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,9 @@ def test_remove_started_connector(self):
yield self._test(r'jcli : ', commands)

# Remove
commands = [{'command': 'smppccm -r %s' % cid, 'expect': r'Successfully removed connector id\:%s' % cid}]
commands = [{'command': 'smppccm -r %s' % cid,
'expect': r'Successfully removed connector id\:%s' % cid,
'wait': 0.6}]
yield self._test(r'jcli : ', commands)

@defer.inlineCallbacks
Expand Down

0 comments on commit 0eb1382

Please sign in to comment.