import sys
sys.path.append('../../')  # NOQA
import pulsar

from n0core.lib.n0mq import N0MQ
from n0core.lib.proto import CreateVMRequest


client = N0MQ('pulsar://localhost:6650')
consumer = client.subscribe('persistent://sample/standalone/compute/handle')


@consumer.on('CreateVMRequest')
def create_VM_request(message, auto_ack=False):
    print('create vm request')
    print(message.data)
    consumer.ack(message)

    
if __name__ == '__main__':
    client.listen()
=======
from mqhandler import MQHandler

mqhandler = MQHandler('pulsar://localhost:6550',
                      'persistent://sample/standalone/volumer/114514',
                      subscription_name='compute')


@mqhandler.handle('CreateVMRequest')
def create_VM_handler(inner_msg, messenger):
    print('create vm')
    print(inner_msg)


@mqhandler.handle('DeleteVMRequest')
def delete_vm_handler(inner_msg, messenger):
    print('delete vm')
    print(inner_msg)


if __name__ == '__main__':
    mqhandler.listen()

@@ -130,17 +130,25 @@
 MRequest
+  # NOQA
 %0A
-
 %0A%0Aclient
@@ -451,24 +451,24 @@
 '__main__':%0A
+
     client.l
@@ -479,524 +479,4 @@
 n()%0A
-=======%0Afrom mqhandler import MQHandler%0A%0Amqhandler = MQHandler('pulsar://localhost:6550',%0A                      'persistent://sample/standalone/volumer/114514',%0A                      subscription_name='compute')%0A%0A%0A@mqhandler.handle('CreateVMRequest')%0Adef create_VM_handler(inner_msg, messenger):%0A    print('create vm')%0A    print(inner_msg)%0A%0A%0A@mqhandler.handle('DeleteVMRequest')%0Adef delete_vm_handler(inner_msg, messenger):%0A    print('delete vm')%0A    print(inner_msg)%0A%0A%0Aif __name__ == '__main__':%0A    mqhandler.listen()%0A

fix main