[STRATOS-940] - Reconnect when connection fails until forever.
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/2efcb97f Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/2efcb97f Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/2efcb97f Branch: refs/heads/master Commit: 2efcb97f96b3fe9195fece4d4a5eb5e41ef0ae0c Parents: a131468 Author: Chamila de Alwis <[email protected]> Authored: Wed Nov 12 15:37:48 2014 +0530 Committer: Chamila de Alwis <[email protected]> Committed: Wed Nov 12 15:37:48 2014 +0530 ---------------------------------------------------------------------- .../cartridgeagent/modules/databridge/agent.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/2efcb97f/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/databridge/agent.py ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/databridge/agent.py b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/databridge/agent.py index 0de3086..8674ab3 100644 --- a/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/databridge/agent.py +++ b/components/org.apache.stratos.python.cartridge.agent/cartridgeagent/cartridgeagent/modules/databridge/agent.py @@ -161,6 +161,7 @@ class ThriftPublisher: try: self.__publisher.publish(event_bundle) + self.log.debug("Published event to thrift stream [%r]" % self.stream_id) except ThriftSessionExpiredException as ex: self.log.debug("ThriftSession expired. Reconnecting") self.__publisher.connect(self.username, self.password) @@ -168,9 +169,12 @@ class ThriftPublisher: self.publish(event) except Exception as ex: - self.log.error("Couldn't publish event. Connection to CEP receiver dropped.") - - self.log.debug("Published event to thrift stream [%r]" % self.stream_id) + self.log.error("Couldn't publish event. Connection to CEP receiver dropped. Reconnecting...") + try: + self.__publisher.connect(self.username, self.password) + except Exception as ex: + if "Connection refused" in ex: + self.log.error("CEP Offline") def create_event_bundle(self, event): """
