本文整理汇总了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)