本文整理匯總了Python中Message.getAntiMessage方法的典型用法代碼示例。如果您正苦於以下問題:Python Message.getAntiMessage方法的具體用法?Python Message.getAntiMessage怎麽用?Python Message.getAntiMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Message
的用法示例。
在下文中一共展示了Message.getAntiMessage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: run
# 需要導入模塊: import Message [as 別名]
# 或者: from Message import getAntiMessage [as 別名]
def run(self):
print('Producer Client Running')
# Get the message queue objects from Pyro
nameserver = Pyro4.locateNS()
stublpInQ_uri = nameserver.lookup('inputqueue.stublp')
stublpInQ = Pyro4.Proxy(stublpInQ_uri)
#
# Messaging Tests: Uncomment one by one and run
#
#Test 1 - single message
#stublpInQ.addMessage(Message(2, 'Data', 'Test Message Generator', LogicalProcess.STUBLP_ID, 5))
#Test 2 - multiple messages
#stublpInQ.addMessage(Message(2, 'Data1', 'Test Message Generator', LogicalProcess.STUBLP_ID, 1))
#stublpInQ.addMessage(Message(2, 'Data2', 'Test Message Generator', LogicalProcess.STUBLP_ID, 2))
#stublpInQ.addMessage(Message(2, 'Data3', 'Test Message Generator', LogicalProcess.STUBLP_ID, 3))
#stublpInQ.addMessage(Message(2, 'Data4', 'Test Message Generator', LogicalProcess.STUBLP_ID, 4))
#Test 3 - an AntiMessage first (expect annihilation)
#msg = Message(2, 'Data1', 'Test Message Generator', LogicalProcess.STUBLP_ID, 1)
#am = msg.getAntiMessage()
#stublpInQ.addMessage(am)
#stublpInQ.addMessage(msg)
#Test 4 - message for antimessage is already in the queue (expect annihilation)
#msg = Message(2, 'Data1', 'Test Message Generator', LogicalProcess.STUBLP_ID, 1)
#am = msg.getAntiMessage()
#stublpInQ.addMessage(msg)
#stublpInQ.addMessage(am)
#Test 5 - lots of antimessages
#am = Message(2, 'Data1', 'Test Message Generator', LogicalProcess.STUBLP_ID, 1)
#am.isAnti = 1
#am1 = Message(2, 'Data2', 'Test Message Generator', LogicalProcess.STUBLP_ID, 2)
#am1.isAnti = 1
#am2 = Message(2, 'Data3', 'Test Message Generator', LogicalProcess.STUBLP_ID, 3)
#am2.isAnti = 1
#am3 = Message(2, 'Data4', 'Test Message Generator', LogicalProcess.STUBLP_ID, 4)
#am3.isAnti = 1
#stublpInQ.addMessage(am)
#stublpInQ.addMessage(am1)
#stublpInQ.addMessage(am2)
#stublpInQ.addMessage(am3)
#stublpInQ.addMessage(Message(2, 'Data5', 'Test Message Generator', LogicalProcess.STUBLP_ID, 5))
#Test 6 - Anti-message for message already processed
#msg1 = Message(2, 'Data1', 'Test Message Generator', LogicalProcess.STUBLP_ID, 1)
#am = msg1.getAntiMessage()
#stublpInQ.addMessage(msg1)
#time.sleep(2)
#stublpInQ.addMessage(am)
#Test 7 - Message for anti-message already in queue
#msg1 = Message(2, 'Data1', 'Test Message Generator', LogicalProcess.STUBLP_ID, 1)
#am = msg1.getAntiMessage()
#stublpInQ.addMessage(msg1)
#stublpInQ.addMessage(am)
#Test 8 = Rollback caused by straggler message
#msg3 = Message(2, 'Data3', 'Test Message Generator', LogicalProcess.STUBLP_ID, 3)
#msg4 = Message(2, 'Data4', 'Test Message Generator', LogicalProcess.STUBLP_ID, 4)
#msg7 = Message(2, 'Data7', 'Test Message Generator', LogicalProcess.STUBLP_ID, 7)
#stublpInQ.addMessage(msg4)
#stublpInQ.addMessage(msg7)
#time.sleep(5)
#stublpInQ.addMessage(msg3)
#Test 9 - Rollback caused by anti-message
msg3 = Message(2, ['Data3'], 'Test Message Generator', LogicalProcess.STUBLP_ID, 3)
msg7 = Message(2, ['Data7'], 'Test Message Generator', LogicalProcess.STUBLP_ID, 7)
am3 = msg3.getAntiMessage()
stublpInQ.addMessage(msg3)
stublpInQ.addMessage(msg7)
time.sleep(5)
stublpInQ.addMessage(am3)