Beispiel #1
0
 def create_connection_obj(self,
                           version='1.0',
                           vhost='/',
                           heartbeats=(0, 0)):
     if version == '1.0':
         conn = stomp.StompConnection10(
             host_and_ports=[('localhost', int(os.environ["STOMP_PORT"]))])
         self.ack_id_source_header = 'message-id'
         self.ack_id_header = 'message-id'
     elif version == '1.1':
         conn = stomp.StompConnection11(host_and_ports=[
             ('localhost', int(os.environ["STOMP_PORT"]))
         ],
                                        vhost=vhost,
                                        heartbeats=heartbeats)
         self.ack_id_source_header = 'message-id'
         self.ack_id_header = 'message-id'
     elif version == '1.2':
         conn = stomp.StompConnection12(host_and_ports=[
             ('localhost', int(os.environ["STOMP_PORT"]))
         ],
                                        vhost=vhost,
                                        heartbeats=heartbeats)
         self.ack_id_source_header = 'ack'
         self.ack_id_header = 'id'
     else:
         conn = stomp.StompConnection12(host_and_ports=[
             ('localhost', int(os.environ["STOMP_PORT"]))
         ],
                                        vhost=vhost,
                                        heartbeats=heartbeats)
         conn.version = version
     return conn
Beispiel #2
0
 def create_connection_obj(self, version='1.2', vhost='/', heartbeats=(0, 0)):
     conn = stomp.StompConnection12(host_and_ports=[('localhost', int(os.environ["STOMP_PORT"]))],
                                    vhost=vhost,
                                    heartbeats=heartbeats)
     self.ack_id_source_header = 'ack'
     self.ack_id_header = 'id'
     return conn
 def create_connection_obj(self,
                           version='1.2',
                           vhost='/',
                           heartbeats=(0, 0)):
     conn = stomp.StompConnection12(vhost=vhost, heartbeats=heartbeats)
     self.ack_id_source_header = 'ack'
     self.ack_id_header = 'id'
     return conn
Beispiel #4
0
 def create_connection_obj(self,
                           version='1.0',
                           vhost='/',
                           heartbeats=(0, 0)):
     if version == '1.0':
         conn = stomp.StompConnection10()
         self.ack_id_source_header = 'message-id'
         self.ack_id_header = 'message-id'
     elif version == '1.1':
         conn = stomp.StompConnection11(vhost=vhost, heartbeats=heartbeats)
         self.ack_id_source_header = 'message-id'
         self.ack_id_header = 'message-id'
     elif version == '1.2':
         conn = stomp.StompConnection12(vhost=vhost, heartbeats=heartbeats)
         self.ack_id_source_header = 'ack'
         self.ack_id_header = 'id'
     else:
         conn = stomp.StompConnection12(vhost=vhost, heartbeats=heartbeats)
         conn.version = version
     return conn
Beispiel #5
0
def main(args):
    hosts = [(args.broker, args.port)]
    conn = stomp.StompConnection12(host_and_ports=hosts,
                                   use_ssl=True,
                                   ssl_key_file=args.ssl_key_file,
                                   ssl_cert_file=args.ssl_cert_file)
    conn.connect(wait=True)

    msg = {
        "cki_pipeline_id":
        args.pipeline_id,
        "summarized_result":
        "PASS",
        "team_email":
        "*****@*****.**",
        "team_name":
        "Virt-QE-S1",
        "results": [{
            "test_name":
            "LTP_Lite",
            "test_description":
            "Cloud platform - {}".format(args.cloud),
            "test_arch":
            args.arch,
            "test_result":
            args.result,
            "test_log_url": [args.log_url],
            "test_waived":
            "True"
        }]
    }
    msg_json = json.dumps(msg)
    print(msg_json)
    conn.send("/topic/VirtualTopic.eng.cki.results",
              body=msg_json,
              headers={"topic": "VirtualTopic.eng.cki.results"})
    conn.disconnect()
Beispiel #6
0
    print('Connection Established!')


class MyListener(stomp.ConnectionListener):
    def __init__(self, conn):
        self.conn = conn
        self.start = time.time()

    def on_error(self, headers, message):
        print('Received an Error %s' % message)

    def on_message(self, headers, message):
        print("Received Message: %s" % message)
        webhook_notify()

    def on_disconnected(self):
        print('disconnected')
        connect_and_subscribe(self.conn)


#conn = stomp.Connection(host_and_ports = [(host, port)], hearbeats=(4000, 4000))
conn = stomp.StompConnection12(host_and_ports=[(host, port)],
                               heartbeats=(5000, 5000),
                               reconnect_attempts_max=5)

conn.set_listener('', MyListener(conn))
connect_and_subscribe(conn)
print("Waiting for messages...")
while 1:
    time.sleep(10)