Hi ALL, There is a grogram to consume messages from queue; according to the message, the program will READ a row and then UPDATE the row; BUT, sometimes, the UPDATE statement is fail, the result of READ statement is also the old content before UDPATE. Any suggestions from you are appreciated. The following are my program and the result.
---READ---- from cassandra.query import SimpleStatement from cassandra import ConsistencyLevel self.interval_data_get_simple = SimpleStatement("""SELECT TRADETIME, OPENPRICE, HIGHPRICE, \ LOWPRICE, CLOSEPRICE, CHANGE, CHANGERATIO, VOLUME, AMOUNT,SECURITYNAME, \ SECURITYID from {} WHERE SYMBOL = '{}' AND TRADETIME = '{}';\ """.format(self.cassandra_table, symbol, \ interval_trade_time.strftime(u'%Y-%m-%d %H:%M:%S')), \ consistency_level=ConsistencyLevel.ALL) cur_interval_future = self.cassandra_session.execute_async(self.interval_data_get_simple) -----UPDATE-------- from cassandra.query import SimpleStatement from cassandra import ConsistencyLevel data_set_simple = SimpleStatement("""UPDATE {} SET OPENPRICE = {}, HIGHPRICE = {}, LOWPRICE = {},\ CLOSEPRICE = {}, VOLUME = {}, AMOUNT = {}, MARKET = {}, SECURITYID = {} WHERE \ SYMBOL = '{}' AND TRADETIME = '{}';""".format(self.cassandra_table, insert_data_list[0], \ insert_data_list[1], insert_data_list[2], insert_data_list[3], \ insert_data_list[4], insert_data_list[5], insert_data_list[6], \ insert_data_list[7], insert_data_list[8], insert_data_list[9]), \ consistency_level=ConsistencyLevel.ALL) update_future = self.cassandra_session.execute(data_set_simple) ------------test result---------- #CQL UPDATE statement UPDATE GTA_HFDCS_SSEL2.SSEL2_TRDMIN01_20141127 SET OPENPRICE = 8.460, HIGHPRICE = 8.460, LOWPRICE = 8.460, CLOSEPRICE = 8.460, VOLUME = 1500, AMOUNT = 12240.000, MARKET = 1, SECURITYID = 201000003592 WHERE SYMBOL = '600256' AND TRADETIME = '2014-11-27 10:00:00'; #the result of READ [Row(tradetime=datetime.datetime(2014, 11, 27, 2, 0), openprice=Decimal('8.460'), highprice=Decimal('8.460'), lowprice=Decimal('8.460'), closeprice=Decimal('8.460'), change=None, changeratio=None, volume=1500, amount=Decimal('12240.000'), securityname=None, securityid=201000003592)] #CQL UPDATE statement UPDATE GTA_HFDCS_SSEL2.SSEL2_TRDMIN01_20141127 SET OPENPRICE = 8.460, HIGHPRICE = 8.460, LOWPRICE = 8.160, CLOSEPRICE = 8.160, VOLUME = 3500, AMOUNT = 28560.000, MARKET = 1, SECURITYID = 201000003592 WHERE SYMBOL = '600256' AND TRADETIME = '2014-11-27 10:00:00'; #the result of READ [Row(tradetime=datetime.datetime(2014, 11, 27, 2, 0), openprice=Decimal('8.460'), highprice=Decimal('8.460'), lowprice=Decimal('8.460'), closeprice=Decimal('8.460'), change=None, changeratio=None, volume=1500, amount=Decimal('12240.000'), securityname=None, securityid=201000003592)] Thanks & Regards, 鄢来琼 / Peter YAN, Staff Software Engineer, A3 Dept., GTA Information Technology Co., Ltd. ========================================= Mobile: 18620306659 E-Mail: laiqiong....@gtafe.com Website: http://www.gtafe.com/ =========================================