Dimitrios Mavrommatis | c53923a | 2017-12-03 19:48:48 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | # coding: utf8 |
| 3 | #Copyright © 2016 - 2017 Copyright (c) Sprint, Inc. and others. All rights reserved. |
| 4 | # |
| 5 | #This program and the accompanying materials are made available under the |
| 6 | #terms of the Eclipse Public License v1.0 which accompanies this distribution, |
| 7 | #and is available at http://www.eclipse.org/legal/epl-v10.html |
| 8 | |
| 9 | import zmq |
| 10 | |
| 11 | def main(): |
| 12 | |
| 13 | try: |
| 14 | context = zmq.Context(1) |
| 15 | |
| 16 | # Socket facing clients |
| 17 | frontend = context.socket(zmq.SUB) |
Dimitrios Mavrommatis | 6d4d5ce | 2017-12-13 11:35:55 -0800 | [diff] [blame^] | 18 | frontend.bind("tcp://*:5555") |
Dimitrios Mavrommatis | c53923a | 2017-12-03 19:48:48 -0800 | [diff] [blame] | 19 | |
| 20 | frontend.setsockopt(zmq.SUBSCRIBE, "") |
| 21 | |
| 22 | # Socket facing services |
| 23 | backend = context.socket(zmq.PUB) |
Dimitrios Mavrommatis | 6d4d5ce | 2017-12-13 11:35:55 -0800 | [diff] [blame^] | 24 | backend.bind("tcp://*:5556") |
Dimitrios Mavrommatis | c53923a | 2017-12-03 19:48:48 -0800 | [diff] [blame] | 25 | |
| 26 | |
| 27 | zmq.device(zmq.FORWARDER, frontend, backend) |
| 28 | except Exception, e: |
| 29 | print e |
| 30 | print "bringing down zmq device" |
| 31 | finally: |
| 32 | pass |
| 33 | frontend.close() |
| 34 | backend.close() |
| 35 | context.term() |
| 36 | |
| 37 | if __name__ == "__main__": |
| 38 | main() |