CN114691732A - Method, device, non-volatile storage medium and processor for locating abnormal transactions - Google Patents

Method, device, non-volatile storage medium and processor for locating abnormal transactions Download PDF

Info

Publication number
CN114691732A
CN114691732A CN202210234282.6A CN202210234282A CN114691732A CN 114691732 A CN114691732 A CN 114691732A CN 202210234282 A CN202210234282 A CN 202210234282A CN 114691732 A CN114691732 A CN 114691732A
Authority
CN
China
Prior art keywords
transaction
abnormal
serial number
calling
current
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202210234282.6A
Other languages
Chinese (zh)
Other versions
CN114691732B (en
Inventor
邓萍
余洋
吴鹏
高运凯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Postal Savings Bank of China Ltd
Original Assignee
Postal Savings Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Postal Savings Bank of China Ltd filed Critical Postal Savings Bank of China Ltd
Priority to CN202210234282.6A priority Critical patent/CN114691732B/en
Publication of CN114691732A publication Critical patent/CN114691732A/en
Application granted granted Critical
Publication of CN114691732B publication Critical patent/CN114691732B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/903Querying
    • G06F16/90335Query processing
    • G06F16/90344Query processing by using string matching techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • Accounting & Taxation (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Finance (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明公开了一种定位异常交易的方法、装置、非易失性存储介质与处理器。该发明包括:在检测到多个交易中存在异常交易的情况下,获取异常交易对应的目标流水号;根据目标流水号对异常交易进行定位,确定异常交易的信息以及发生异常时对应的调用系统,调用系统包括交易调用的发起方系统以及被调用系统。该方法中,获取到异常交易的目标流水号具有唯一性,可以唯一定位一笔交易,并且可以描述交易链路的调用的各个系统,所以根据该目标流水号可以定位到异常交易的信息以及发生异常时的调用系统,从而实现根据目标流水号就可以定位到发生异常的系统,进而解决了相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的技术问题。

Figure 202210234282

The invention discloses a method, a device, a non-volatile storage medium and a processor for locating abnormal transactions. The invention includes: when it is detected that there are abnormal transactions in multiple transactions, acquiring the target serial number corresponding to the abnormal transaction; locating the abnormal transaction according to the target serial number, determining the information of the abnormal transaction and the corresponding calling system when the abnormality occurs , the calling system includes the initiator system of the transaction call and the called system. In this method, the target serial number of the abnormal transaction is unique, which can uniquely locate a transaction and describe the various systems of the transaction link. Therefore, according to the target serial number, the information and occurrence of the abnormal transaction can be located. The system is called when abnormal, so that the abnormal system can be located according to the target serial number, thereby solving the technical problem that the transaction serial number in the related technology is difficult to locate the abnormal system when the transaction is abnormal. .

Figure 202210234282

Description

定位异常交易的方法、装置、非易失性存储介质与处理器Method, device, non-volatile storage medium and processor for locating abnormal transactions

技术领域technical field

本发明涉及计算机领域,具体而言,涉及一种定位异常交易的方法、装置、非易失性存储介质与处理器。The present invention relates to the field of computers, and in particular, to a method, a device, a non-volatile storage medium and a processor for locating abnormal transactions.

背景技术Background technique

目前,银行的业务种类繁多、业务场景丰富,每天会处理成千上万笔交易,而一笔交易往往会涉及到多个系统,当交易发生异常时一是需要定位到发生异常的交易,二是需要知道该笔交易中异常发生在哪次系统调用的过程,因此交易定位、交易链路追踪在银行交易中尤其重要。At present, banks have a wide variety of businesses and rich business scenarios. Thousands of transactions are processed every day, and a transaction often involves multiple systems. When an abnormal transaction occurs, one needs to locate the abnormal transaction, and two It is the process of knowing which system call the exception occurred in the transaction. Therefore, transaction location and transaction link tracking are especially important in bank transactions.

在现有的银行业务中,通常使用流水号来记录和追踪一笔交易,目前的技术已经能够实现生成全局唯一的流水号,当前比较成熟的方案有snowflake雪花算法。这种方案是一种以划分命名空间来生成ID的一种算法,它使用二进制来表示,共64-bit,分别划分成多段,分开来标示机器、时间等。它第一部分为1-bit,表示符号位;第二部分为41-bit用来记录时间戳,毫秒级,可表示69年的时间;第三部分为10-bit表示机器id,用来记录工作机器编号;第四部分为12-bit表示序列号,用来记录同毫秒内产生的不同id。In the existing banking business, the serial number is usually used to record and track a transaction. The current technology has been able to generate a globally unique serial number. The current mature solution is the snowflake algorithm. This scheme is an algorithm for generating IDs by dividing namespaces. It is represented by binary, with a total of 64-bits, which are divided into multiple segments, which are separated to indicate machines, time, and so on. Its first part is 1-bit, which means the sign bit; the second part is 41-bit, which is used to record the timestamp, in milliseconds, which can represent the time of 69 years; the third part is 10-bit, which means the machine id, which is used to record the work Machine number; the fourth part is a 12-bit serial number, which is used to record different ids generated within the same millisecond.

虽然流水号可以唯一定位一笔交易,但它缺少这笔交易中所涉及的系统的具体描述,一旦交易发生异常,对于运维人员来说,只根据流水号去定位到发生异常的系统将十分困难。Although the serial number can uniquely locate a transaction, it lacks the specific description of the system involved in the transaction. Once the transaction is abnormal, it will be very difficult for the operation and maintenance personnel to locate the abnormal system only based on the serial number. difficulty.

另外,对于现有的可以描述交易链路信息的编码,其只能描述简单的系统调用关系,如“A->B->C”,而银行业务中的许多交易涉及的链路复杂,调用关系往往会存在多个子分支,对于这样的链路结构仍需要准确和清晰的编码方式来表达。In addition, for existing codes that can describe transaction link information, they can only describe simple system call relationships, such as "A->B->C", while many transactions in banking involve complex links, calling Relationships often have multiple sub-branches, and such a link structure still needs an accurate and clear coding method to express.

针对相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的问题,目前尚未提出有效的解决方案。Aiming at the problem of the transaction serial number in the related art, it is difficult to locate the abnormal system when the transaction is abnormal, and an effective solution has not yet been proposed.

发明内容SUMMARY OF THE INVENTION

本发明的主要目的在于提供一种定位异常交易的方法、装置、非易失性存储介质与处理器,以解决相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的问题。The main purpose of the present invention is to provide a method, a device, a non-volatile storage medium and a processor for locating an abnormal transaction, so as to solve the problem that the transaction serial number in the related art is difficult to locate when the abnormal transaction occurs. system problems.

为了实现上述目的,根据本发明的一个方面,提供了一种定位异常交易的方法。该发明包括:在检测到多个交易中存在异常交易的情况下,获取所述异常交易对应的目标流水号;依据所述目标流水号对所述异常交易进行定位,以确定所述异常交易的信息以及所述异常交易在交易链路中发生异常时对应的调用系统,所述调用系统包括交易的调用发起方系统。In order to achieve the above object, according to one aspect of the present invention, a method for locating abnormal transactions is provided. The invention includes: in the case of detecting that there are abnormal transactions in a plurality of transactions, obtaining the target serial number corresponding to the abnormal transaction; locating the abnormal transaction according to the target serial number to determine the abnormal transaction information and a corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, the calling system includes the calling initiator system of the transaction.

进一步地,在检测到多个交易中存在异常交易的情况下,获取所述异常交易对应的目标流水号,包括:在检测到多个交易中存在异常交易的情况下,获取所述异常交易在交易过程中生成的当前报文;获取所述报文中包含的所述目标流水号,其中,所述目标流水号包括所述异常交易对应的全局业务跟踪号以及所述异常交易对应的子交易序号,所述全局业务跟踪号贯穿所述异常交易对应的整个交易过程。Further, in the case of detecting that there are abnormal transactions in multiple transactions, acquiring the target serial number corresponding to the abnormal transactions includes: in the case of detecting that there are abnormal transactions in the multiple transactions, acquiring the abnormal transactions in the abnormal transactions. The current message generated in the transaction process; obtain the target serial number contained in the message, wherein the target serial number includes the global business tracking number corresponding to the abnormal transaction and the sub-transaction corresponding to the abnormal transaction Serial number, the global business tracking number runs through the entire transaction process corresponding to the abnormal transaction.

进一步地,依据所述目标流水号对所述异常交易进行定位,以确定所述异常交易的信息,包括:对所述全局业务跟踪号进行解析,并获得第一解析结果,其中,所述第一解析结果至少包括时间戳、第一系统号、第一交易实例序号以及序列号,所述时间戳为所述异常交易在交易发起时对应的时间戳,所述第一系统号所述异常交易的原始发起方系统对应的标识码,所述第一交易实例序号为所述异常交易对应的交易实例所在机器的标识码,所述序列号为所述异常交易在发起时,所述原始发起方系统生成的循环递增的序列号;依据所述第一解析结果,确定所述异常交易的信息。Further, locating the abnormal transaction according to the target serial number to determine the information of the abnormal transaction includes: analyzing the global business tracking number, and obtaining a first analysis result, wherein the first A parsing result at least includes a time stamp, a first system number, a first transaction instance serial number and a serial number, the time stamp is the time stamp corresponding to the abnormal transaction when the transaction is initiated, the first system number is the abnormal transaction The identification code corresponding to the original initiator system of the first transaction instance, the serial number of the first transaction instance is the identification code of the machine where the transaction instance corresponding to the abnormal transaction is located, and the serial number is the original initiator when the abnormal transaction is initiated. The cyclically incremented serial number generated by the system; according to the first analysis result, the information of the abnormal transaction is determined.

进一步地,在依据所述目标流水号对所述异常交易进行定位,以确定所述异常交易的信息之前,所述方法还包括:获取所述异常交易对应的原始交易实例所在机器对应的MAC地址;计算所述MAC地址对应的hash值,并对所述hash值进行取模运算以得到取模结果;对所述取模结果进行补零操作以得到所述第一交易实例序号。Further, before locating the abnormal transaction according to the target serial number to determine the information of the abnormal transaction, the method further includes: acquiring the MAC address corresponding to the machine where the original transaction instance corresponding to the abnormal transaction is located ; Calculate the hash value corresponding to the MAC address, and perform a modulo operation on the hash value to obtain a modulo result; perform a zero-fill operation on the modulo result to obtain the first transaction instance serial number.

进一步地,依据所述目标流水号对所述异常交易进行定位,以确定所述异常交易在交易链路中发生异常时对应的调用系统,包括:获取所述目标流水号中包含的目标子交易序号,其中,所述目标子交易序号为所述异常交易在交易过程中生成的当前子交易序号;对所述目标子交易序号进行解析,并获得第二解析结果,其中,所述第二解析结果至少包括第二系统号、第二交易实例序号以及最新交易编排号,所述第二系统号为所述异常交易对应的所述当前调用发起方系统对应的标识码、所述第二交易实例序号为所述当前调用发起方系统对应的交易实例所在的机器的标识码,所述最新交易编排号从横向以及纵向两个维度表示当前调用过程中对系统的调用链路;依据所述第二解析结果,确定所述异常交易在交易链路中发生异常时对应的调用系统。Further, locating the abnormal transaction according to the target serial number to determine the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, including: acquiring the target sub-transaction contained in the target serial number serial number, wherein the target sub-transaction serial number is the current sub-transaction serial number generated by the abnormal transaction during the transaction process; analyze the target sub-transaction serial number, and obtain a second analysis result, wherein the second analysis The result includes at least the second system number, the second transaction instance serial number, and the latest transaction arrangement number, where the second system number is the identification code corresponding to the current calling originator system corresponding to the abnormal transaction, the second transaction instance The serial number is the identification code of the machine where the transaction instance corresponding to the current invocation initiator system is located, and the latest transaction arrangement number represents the invocation link to the system in the current invocation process from the horizontal and vertical dimensions; according to the second Analyze the result to determine the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link.

进一步地,在依据所述目标流水号对所述异常交易进行定位,以确定所述异常交易在交易链路中发生异常时对应的调用系统之前,所述方法包括:获取所述异常交易在所述交易链路中对应的当前系统调用信息,所述当前系统调用信息至少包括所述异常交易对应的所述当前调用发起方系统的信息以及所述当前被调用系统的信息;依据所述当前系统调用信息,生成所述目标子交易序号。Further, before locating the abnormal transaction according to the target serial number to determine the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, the method includes: obtaining the abnormal transaction in the transaction chain. The corresponding current system call information in the transaction link, the current system call information at least includes the information of the current call originator system and the current called system information corresponding to the abnormal transaction; according to the current system Call the information to generate the sequence number of the target sub-transaction.

进一步地,依据所述当前系统调用信息,生成所述目标子交易序号,包括:获取所述当前调用发起方系统对应的标识码,并将所述标识码确定为所述目标子交易序号的前缀;确定当前系统所处的所述交易链路的层级,并确定所述交易链路的层级对应的编号;将所述前缀、所述编号依次排列,并确定除所述前缀以及所述层级号以外的字符为0,以生成所述目标子交易序号对应的基准序号;获取所述当前调用发起方系统调用所述当前被调用系统的调用情况,并依据所述调用情况对所述基准序号调整;将调整后的所述基准序号,确定为所述目标子交易序号。Further, generating the target sub-transaction sequence number according to the current system invocation information includes: acquiring an identification code corresponding to the current invocation initiator system, and determining the identification code as a prefix of the target sub-transaction sequence number ; Determine the level of the transaction link where the current system is located, and determine the number corresponding to the level of the transaction link; arrange the prefix and the number in sequence, and determine the prefix and the level number except the number Other characters are 0 to generate the reference sequence number corresponding to the target sub-transaction sequence number; obtain the calling situation of the current calling originator system calling the current called system, and adjust the reference sequence number according to the calling situation ; Determine the adjusted reference sequence number as the target sub-transaction sequence number.

进一步地,获取所述当前调用发起方系统调用所述当前被调用系统的调用情况,并依据所述调用情况对所述基准序号调整,包括:判断所述当前调用发起方系统在调用所述当前被调用系统时,所述当前调用发起方系统是否为首次调用外系统;在所述当前调用发起方系统为首次调用所述外系统的情况下,对所述基准序号进行升层处理以使所述基准序号中第一位为0的字符转换为1;在所述当前调用发起方系统为非首次调用所述外系统的情况下,对所述基准序号进行升次处理以调整所述基准序号中的层级号加1。Further, acquiring the calling situation of the current calling originator system calling the currently called system, and adjusting the reference sequence number according to the calling situation includes: judging that the current calling originator system is calling the current calling system. When the system is called, whether the current call initiator system is the first time to call the external system; in the case that the current call initiator system is the first time to call the external system, the reference sequence number is upgraded to make all The character whose first digit is 0 in the reference sequence number is converted to 1; in the case that the current call initiator system is not the first time to call the external system, the reference sequence number is ascended to adjust the reference sequence number Increment the level number by 1.

为了实现上述目的,根据本发明的另一方面,提供了一种定位异常交易的装置。该装置包括:获取单元,用于在检测到多个交易中存在异常交易的情况下,获取所述异常交易对应的目标流水号;定位单元,用于依据所述目标流水号对所述异常交易进行定位,以确定所述异常交易的信息以及所述异常交易在交易链路中发生异常时对应的调用系统,所述调用系统包括交易的调用发起方系统。In order to achieve the above object, according to another aspect of the present invention, a device for locating abnormal transactions is provided. The device includes: an acquiring unit, configured to acquire a target serial number corresponding to the abnormal transaction when an abnormal transaction is detected in a plurality of transactions; a positioning unit, configured to analyze the abnormal transaction according to the target serial number Positioning is performed to determine the information of the abnormal transaction and the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, and the calling system includes the calling initiator system of the transaction.

为了实现上述目的,根据本发明的又一方面,提供了一种非易失性存储介质,所述非易失性存储介质包括存储的程序,其中,在所述程序运行时控制所述非易失性存储介质所在设备执行任意一种所述的方法。In order to achieve the above object, according to yet another aspect of the present invention, a non-volatile storage medium is provided, the non-volatile storage medium includes a stored program, wherein when the program runs, the non-volatile storage medium is controlled The device where the volatile storage medium is located executes any one of the methods.

为了实现上述目的,根据本发明的再一方面,提供了一种处理器,所述处理器用于运行程序,其中,所述程序运行时执行任意一种所述的方法。In order to achieve the above object, according to another aspect of the present invention, a processor is provided, and the processor is used for running a program, wherein any one of the methods is executed when the program is running.

通过本发明,首先,在检测到多个交易中存在异常交易的情况下,获取异常交易对应的目标流水号,然后,根据目标流水号对异常交易进行定位,确定异常交易的信息以及发生异常时对应的调用系统,调用系统包括交易调用的发起方系统以及被调用系统。该方法中,获取到异常交易的目标流水号具有唯一性,可以唯一定位一笔交易,并且可以描述交易链路的调用的各个系统,所以根据该目标流水号可以定位到异常交易的信息以及发生异常时的调用系统,从而实现根据目标流水号就可以定位到发生异常的系统,进而解决了相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的技术问题。Through the present invention, firstly, in the case of detecting that there are abnormal transactions in multiple transactions, the target serial number corresponding to the abnormal transaction is obtained, and then the abnormal transaction is located according to the target serial number, and the information of the abnormal transaction and the occurrence of the abnormality are determined. The corresponding calling system, the calling system includes the initiator system of the transaction call and the called system. In this method, the target serial number of the abnormal transaction is unique, which can uniquely locate a transaction and describe the various systems of the transaction link. Therefore, according to the target serial number, the information and occurrence of abnormal transactions can be located. The system is called when an exception occurs, so that the abnormal system can be located according to the target serial number, thereby solving the technical problem that the transaction serial number in the related technology is difficult to locate the abnormal system when the transaction occurs. .

附图说明Description of drawings

构成本发明的一部分的附图用来提供对本发明的进一步理解,本发明的示意性实施例及其说明用于解释本发明,并不构成对本发明的不当限定。在附图中:The accompanying drawings constituting a part of the present invention are used to provide further understanding of the present invention, and the exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the attached image:

图1是根据本发明实施例提供的定位异常交易的方法的流程图;1 is a flowchart of a method for locating abnormal transactions provided according to an embodiment of the present invention;

图2是根据本发明实施例提供的定位异常交易的装置的示意图;2 is a schematic diagram of an apparatus for locating abnormal transactions provided according to an embodiment of the present invention;

图3是根据本发明实施例提供的交易实例序号生成的流程图;Fig. 3 is the flow chart of transaction instance serial number generation provided according to the embodiment of the present invention;

图4是根据本发明实施例提供的序列号生成的流程图;4 is a flow chart of serial number generation provided according to an embodiment of the present invention;

图5是根据本发明实施例提供的交易链路的示意图;5 is a schematic diagram of a transaction link provided according to an embodiment of the present invention;

图6是根据本发明实施例提供的交易实例序号生成的流程图;FIG. 6 is a flowchart of transaction instance serial number generation provided according to an embodiment of the present invention;

图7是根据本发明实施例提供的交易链路的示意图;7 is a schematic diagram of a transaction link provided according to an embodiment of the present invention;

图8是根据本发明实施例提供的升层逻辑的流程图;FIG. 8 is a flowchart of an upgrade logic provided according to an embodiment of the present invention;

图9是根据本发明实施例提供的升次逻辑的流程图。FIG. 9 is a flowchart of an ascending logic provided according to an embodiment of the present invention.

具体实施方式Detailed ways

需要说明的是,在不冲突的情况下,本发明中的实施例及实施例中的特征可以相互组合。下面将参考附图并结合实施例来详细说明本发明。It should be noted that the embodiments of the present invention and the features of the embodiments may be combined with each other under the condition of no conflict. The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with the embodiments.

为了使本技术领域的人员更好地理解本发明方案,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分的实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本发明保护的范围。In order to make those skilled in the art better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only Embodiments are part of the present invention, but not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本发明的实施例。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second" and the like in the description and claims of the present invention and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances for the embodiments of the invention described herein. Furthermore, the terms "comprising" and "having" and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed Rather, those steps or units may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.

正如背景技术中所说的,相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统,为了解决上述问题,本申请的一种典型的实施方式中,提供了一种定位异常交易的方法、装置、非易失性存储介质与处理器。As mentioned in the background art, when the transaction serial number in the related art is abnormal, it is difficult to locate the abnormal system. In order to solve the above problem, a typical implementation of the present application provides A method, device, non-volatile storage medium and processor for locating abnormal transactions.

根据本发明的实施例,提供了一种定位异常交易的方法。According to an embodiment of the present invention, a method for locating abnormal transactions is provided.

图1是根据本发明实施例的定位异常交易的方法的流程图。如图1所示,该发明包括以下步骤:FIG. 1 is a flowchart of a method for locating abnormal transactions according to an embodiment of the present invention. As shown in Figure 1, the invention includes the following steps:

步骤S101,在检测到多个交易中存在异常交易的情况下,获取上述异常交易对应的目标流水号;Step S101, in the case of detecting that an abnormal transaction exists in the plurality of transactions, obtain the target serial number corresponding to the abnormal transaction;

步骤S102,依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易的信息以及上述异常交易在交易链路中发生异常时对应的调用系统,上述调用系统包括交易的调用发起方系统。Step S102, locate the abnormal transaction according to the target serial number to determine the information of the abnormal transaction and the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, and the calling system includes the calling initiator system of the transaction.

上述的方法中,首先,在检测到多个交易中存在异常交易的情况下,获取异常交易对应的目标流水号,然后,根据目标流水号对异常交易进行定位,确定异常交易的信息以及发生异常时对应的调用系统,调用系统包括交易调用的发起方系统以及被调用系统。该方法中,获取到异常交易的目标流水号具有唯一性,可以唯一定位一笔交易,并且可以描述交易链路的调用的各个系统,所以根据该目标流水号可以定位到异常交易的信息以及发生异常时的调用系统,从而实现根据目标流水号就可以定位到发生异常的系统,进而解决了相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的技术问题。In the above method, first, in the case of detecting that there are abnormal transactions in multiple transactions, the target serial number corresponding to the abnormal transaction is obtained, and then, the abnormal transaction is located according to the target serial number, and the information of the abnormal transaction and the occurrence of the abnormality are determined. The corresponding calling system at the time of transaction, the calling system includes the initiator system of the transaction call and the called system. In this method, the target serial number of the abnormal transaction is unique, which can uniquely locate a transaction and describe the various systems of the transaction link. Therefore, according to the target serial number, the information and occurrence of abnormal transactions can be located. The system is called when an exception occurs, so that the abnormal system can be located according to the target serial number, thereby solving the technical problem that the transaction serial number in the related technology is difficult to locate the abnormal system when the transaction occurs. .

需要说明的是,在附图的流程图示出的步骤可以在诸如一组计算机可执行指令的计算机系统中执行,并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。It should be noted that the steps shown in the flowcharts of the accompanying drawings may be executed in a computer system, such as a set of computer-executable instructions, and, although a logical sequence is shown in the flowcharts, in some cases, Steps shown or described may be performed in an order different from that herein.

本申请的一种实施例中,在检测到多个交易中存在异常交易的情况下,获取上述异常交易对应的目标流水号,包括:在检测到多个交易中存在异常交易的情况下,获取上述异常交易在交易过程中生成的当前报文;获取上述报文中包含的上述目标流水号,其中,上述目标流水号包括上述异常交易对应的全局业务跟踪号以及上述异常交易对应的子交易序号,上述全局业务跟踪号贯穿上述异常交易对应的整个交易过程。进行跨系统调用时,会使用标准的公共报文来记录交易所需的关键字段,目标流水号属于需要记录的关键字段,所以可以从当前报文中,获取上述目标流水号,上述目标流水号包括贯穿上述异常交易的整个交易过程的全局业务跟踪号和子交易序号,本实施例并不需要生成新的目标流水号,直接从当前报文中获取,从而实现快速定位交易异常的系统。In an embodiment of the present application, obtaining the target serial number corresponding to the abnormal transaction in the case of detecting that there is an abnormal transaction in the plurality of transactions includes: in the case of detecting that there is an abnormal transaction in the plurality of transactions, obtaining The current message generated by the above-mentioned abnormal transaction during the transaction process; obtain the above-mentioned target serial number contained in the above-mentioned message, wherein the above-mentioned target serial number includes the global business tracking number corresponding to the above-mentioned abnormal transaction and the sub-transaction sequence number corresponding to the above-mentioned abnormal transaction , the above-mentioned global business tracking number runs through the entire transaction process corresponding to the above-mentioned abnormal transaction. When making a cross-system call, the standard public message will be used to record the key fields required for the transaction. The target serial number belongs to the key field that needs to be recorded. Therefore, the above target serial number can be obtained from the current message. The above target serial number The serial number includes the global business tracking number and sub-transaction serial number throughout the entire transaction process of the abnormal transaction. This embodiment does not need to generate a new target serial number and is directly obtained from the current message, thereby realizing a system for quickly locating transaction abnormality.

为了得到准确的异常交易的信息,本申请的再一种实施例中,依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易的信息,包括:对上述全局业务跟踪号进行解析,并获得第一解析结果,其中,上述第一解析结果至少包括时间戳、第一系统号、第一交易实例序号以及序列号,上述时间戳为上述异常交易在交易发起时对应的时间戳,上述第一系统号上述异常交易的原始发起方系统对应的标识码,上述第一交易实例序号为上述异常交易对应的交易实例所在机器的标识码,上述序列号为上述异常交易在发起时,为上述原始发起方系统生成的循环递增的序列号;依据上述第一解析结果,确定上述异常交易的信息。全局业务跟踪号由触发点生成,一致持续到时间完整结束,所以全局业务跟踪号中记录了上述异常交易的信息,所以,本实施例中,需要先对全局业务跟踪号进行解析,得到第一解析结果,根据第一解析结果就可以得到全局业务跟踪号中所记录的异常交易的信息。In order to obtain accurate abnormal transaction information, in yet another embodiment of the present application, locating the above abnormal transaction according to the above target serial number to determine the above abnormal transaction information includes: analyzing the above global business tracking number, and obtain a first analysis result, wherein the first analysis result includes at least a time stamp, a first system number, a first transaction instance serial number and a serial number, and the above time stamp is the time stamp corresponding to the abnormal transaction when the transaction is initiated, and the above The first system number is the identification code corresponding to the system of the original initiator of the above abnormal transaction, the above first transaction instance serial number is the identification code of the machine where the transaction instance corresponding to the above abnormal transaction is located, and the above serial number is the above abnormal transaction when the above abnormal transaction is initiated. The cyclically incremented serial number generated by the original initiator's system; according to the above-mentioned first analysis result, the information of the above-mentioned abnormal transaction is determined. The global business tracking number is generated by the trigger point, and lasts consistently until the time completes. Therefore, the information about the above abnormal transaction is recorded in the global business tracking number. Therefore, in this embodiment, the global business tracking number needs to be parsed first to obtain the first According to the analysis result, the abnormal transaction information recorded in the global business tracking number can be obtained according to the first analysis result.

上述全局业务跟踪号在系统中有可能作为数据库主键来进行使用,对于数据库的主键来说,要求主键长度不能过长,另外考虑到全局业务跟踪号组成部分较多,本申请的一种具体的实施例中将上述全局业务跟踪号设置为32位。上述全局业务跟踪号的组成如表一所示:The above-mentioned global business tracking number may be used as the primary key of the database in the system. For the primary key of the database, the length of the primary key should not be too long. In addition, considering that there are many components of the global business tracking number, a specific In the embodiment, the above-mentioned global service tracking number is set to 32 bits. The composition of the above global service tracking number is shown in Table 1:

表一Table I

Figure BDA0003539528190000081
Figure BDA0003539528190000081

上述时间戳:通过获取本地系统时间来生成,属于技术字段。The above timestamp: generated by obtaining the local system time, which belongs to the technical field.

上述系统号:对所有系统按照业务职能的划分进行编排,是具有业务属性的编码,该部分组成为7位,它是来源于统一的标准。例如,存款系统使用“1111111”,汇款系统使用“2222222”。使用、全局业务跟踪号中的系统号由交易发起方生成。The above system number: All systems are arranged according to the division of business functions. It is a code with business attributes. This part consists of 7 digits, which is derived from a unified standard. For example, the deposit system uses "1111111" and the remittance system uses "2222222". Used, the system number in the global business tracking number is generated by the transaction initiator.

上述交易实例序号:该组成部分属于技术字段。生成流程如图3所示,发起交易实例序号获取时,首先从本地的环境变量中获取,上述环境变量为服务器里配置的一个环境参数,如果存在则直接返回,如果不存在则从系统的启动参数中获取,如果启动参数中存在交易实例序号的配置则直接返回,如果不存在则通过本地默认实现的算法来生成。全局业务跟踪号中的交易实例序号由交易发起方生成。The above transaction instance serial number: This component belongs to the technical field. The generation process is shown in Figure 3. When initiating the acquisition of the transaction instance serial number, it is first obtained from the local environment variable. The above environment variable is an environment parameter configured in the server. If it exists, it will return directly. If it does not exist, it will be obtained from the system startup. If the configuration of the transaction instance serial number exists in the startup parameters, it will be returned directly. If it does not exist, it will be generated by the local default algorithm. The transaction instance serial number in the global business tracking number is generated by the transaction initiator.

上述序列号的生成:在本申请中,序列号循环使用,其生成的流程如图4所示。序列号采用Java原生的AtomicInteger来进行自增,自增后得到的结果判断是否大于999999,如果大于则将序列号置为1并进行字符串格式化,如果不大于999999就将得到的结果进行字符串格式,生成最终的序列号。Generation of the above-mentioned serial number: In this application, the serial number is used cyclically, and the flow of its generation is shown in FIG. 4 . The serial number is self-incremented using Java's native AtomicInteger. The result obtained after self-increment is judged whether it is greater than 999999. If it is greater than 1, the serial number is set to 1 and the string is formatted. If it is not greater than 999999, the obtained result is character string format to generate the final serial number.

将以上生成的14位时间戳、7位系统编码、5位发起交易实例序号和6位序列号拼接,即得到生成的全局业务跟踪号。如图5所示,假设有一笔交易,其交易链路如下图所示。系统A作为交易发起方,则由系统A来生成此笔交易的全局业务跟踪号,系统B和系统C不会再生成全局业务跟踪号。交易中每次系统间的调用都会将全局业务跟踪号发送至下游系统。The generated global business tracking number is obtained by splicing the 14-digit timestamp, 7-digit system code, 5-digit transaction instance serial number and 6-digit serial number generated above. As shown in Figure 5, suppose there is a transaction, and its transaction link is shown in the figure below. If system A is the transaction initiator, system A will generate the global business tracking number for this transaction, and system B and system C will not generate the global business tracking number again. Each inter-system call in the transaction sends the global business tracking number to the downstream system.

本申请的又一种实施例中,如图6所示,在依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易的信息之前,上述方法还包括:获取上述异常交易对应的原始交易实例所在机器对应的MAC地址;计算上述MAC地址对应的hash值,并对上述hash值进行取模运算以得到取模结果;对上述取模结果进行补零操作以得到上述第一交易实例序号。本实施例中,通过原始交易实例所在机器的MAC地址,计算hash值,然后对hash值进行取模运算,最后对取模运算的结果进行补零操作,从而得到准确的第一交易实施例序号。In another embodiment of the present application, as shown in FIG. 6 , before locating the abnormal transaction according to the target serial number to determine the information of the abnormal transaction, the method further includes: acquiring the original data corresponding to the abnormal transaction. MAC address corresponding to the machine where the transaction instance is located; calculate the hash value corresponding to the above MAC address, and perform a modulo operation on the above hash value to obtain a modulo result; perform a zero-fill operation on the above modulo result to obtain the above-mentioned first transaction instance serial number . In this embodiment, the hash value is calculated based on the MAC address of the machine where the original transaction instance is located, then a modulo operation is performed on the hash value, and a zero-fill operation is performed on the result of the modulo operation, thereby obtaining an accurate first transaction embodiment serial number .

例如,若交易实例序号为5位,则对99999(5个9)取模,若交易实例序号为6位,则对999999(6个9)进行取模。最后,对取模结果进行字符串格式化(即补零操作)完成交易实例序号的生成。For example, if the transaction instance serial number is 5 digits, then modulo 99999 (five 9s), if the transaction instance serial number is 6 digits, then take the modulo 999999 (six 9s). Finally, string formatting (that is, zero-filling operation) is performed on the modulo result to complete the generation of the transaction instance serial number.

另外,上述第一交易实例序号的确定方法还包括从服务启动的配置参数获取和从环境变量配置中获取。In addition, the above-mentioned method for determining the serial number of the first transaction instance further includes acquiring from a configuration parameter activated by the service and acquiring from an environment variable configuration.

本申请的另一种实施例中,依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易在交易链路中发生异常时对应的调用系统,包括:获取上述目标流水号中包含的多个上述子交易序号中的目标子交易序号,其中,上述目标子交易序号为上述异常交易在交易过程中生成的当前子交易序号;对上述目标子交易序号进行解析,并获得第二解析结果,其中,上述第二解析结果至少包括第二系统号、第二交易实例序号以及最新交易编排号,上述第二系统号为上述异常交易对应的上述当前调用发起方系统对应的标识码、上述第二交易实例序号为上述当前调用发起方系统生成的上述异常交易对应的交易实例所在机器的标识码,上述最新交易编排号从横向以及纵向两个维度表示当前调用过程中对系统的调用链路;依据上述第二解析结果,确定上述异常交易在交易链路中发生异常时对应的调用系统。本实施例中,需要先对上述目标子交易序号,得到第二系统号、第二交易实例序号以及最新交易编排号,通过上述第二系统号、上述第二交易实例序号以及上述最新交易编排号就可以定位异常交易的调用发起系统以及调用过程的交易链路,从而实现对复杂链路中的发生异常的调用系统快速定位。In another embodiment of the present application, locating the above-mentioned abnormal transaction according to the above-mentioned target serial number, so as to determine the corresponding calling system when the above-mentioned abnormal transaction occurs abnormally in the transaction link, includes: obtaining the information contained in the above-mentioned target serial number. The target sub-transaction sequence number in the plurality of sub-transaction sequence numbers, wherein the target sub-transaction sequence number is the current sub-transaction sequence number generated during the transaction process of the abnormal transaction; analyze the target sub-transaction sequence number, and obtain a second analysis result , wherein the second analysis result at least includes the second system number, the second transaction instance serial number and the latest transaction arrangement number, and the second system number is the identification code corresponding to the current calling initiator system corresponding to the abnormal transaction, the first 2. The transaction instance serial number is the identification code of the machine where the transaction instance corresponding to the above abnormal transaction generated by the above-mentioned current invocation originator system is located, and the above-mentioned latest transaction arrangement number represents the invocation link to the system in the current invocation process from the horizontal and vertical dimensions; According to the second analysis result, the calling system corresponding to the abnormal transaction in the transaction link is determined. In this embodiment, it is necessary to obtain the second system number, the second transaction instance serial number and the latest transaction arrangement number from the above-mentioned target sub-transaction serial numbers. The call initiation system of the abnormal transaction and the transaction link of the call process can be located, thereby realizing the rapid location of the abnormal call system in the complex link.

上述目标子交易序号包括第二系统号、第二交易实例序号和最新交易编排号。上述目标子交易序号主要用于标识一笔交易的各个调用子分支。上述目标子交易序号的组成如表二所示:The above-mentioned target sub-transaction sequence number includes the second system number, the second transaction instance sequence number and the latest transaction arrangement number. The above target sub-transaction sequence number is mainly used to identify each calling sub-branch of a transaction. The composition of the above target sub-transaction serial numbers is shown in Table 2:

表二Table II

Figure BDA0003539528190000101
Figure BDA0003539528190000101

上述第二系统号与上述全局业务跟踪号中的系统号不一样的地方在于上述第二系统号由当前调用发起方系统生成。The difference between the second system number and the system number in the global service tracking number is that the second system number is generated by the current calling initiator system.

上述交易实例序号的生成方法与上述全局业务跟踪号的方法一致,但不同点是交易实例序号由调用发起方系统生成。The method for generating the transaction instance serial number is the same as the method for generating the global business tracking number above, but the difference is that the transaction instance serial number is generated by the calling initiator system.

上述最新交易编排号由字母和数字组成。最新交易编排号一共20位,表示交易层级号最大支持20层,最新交易编排号中每一位的字符取值范围为“1-9,A-Z”,表示同层级交易实例数最大支持35个。最新交易编排号从横向、纵向两个维度表示交易的调用链路,最新交易编排号沿交易链路往后传递。最新交易编排号初始值全为0,交易链路上每发生一次系统调用,最新交易编排号将会进行升层或升次的逻辑。The latest transaction number listed above consists of letters and numbers. The latest transaction sequence number has a total of 20 digits, indicating that the transaction level number supports a maximum of 20 layers. The character value range of each digit in the latest transaction sequence number is "1-9, A-Z", indicating that the maximum number of transaction instances at the same level supports 35. The latest transaction arrangement number represents the call link of the transaction from the horizontal and vertical dimensions, and the latest transaction arrangement number is passed along the transaction link. The initial value of the latest transaction arrangement number is all 0. Every time a system call occurs on the transaction link, the latest transaction arrangement number will be upgraded or upgraded.

本申请的再一种实施例中,在依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易在交易链路中发生异常时对应的调用系统之前,上述方法包括:获取上述异常交易在上述交易链路中对应的当前系统调用信息,上述当前系统调用信息至少包括上述异常交易对应的上述当前调用发起方系统的信息以及上述当前被调用系统的信息;依据上述当前系统调用信息,生成上述目标子交易序号。本实施例中,上述目标子交易序号是根据当前系统的调用信息生成的,所以后续根据上述目标子交易序号,就可以定位到发生异常交易的系统,从而更加快速地定位发生异常的调用系统。In yet another embodiment of the present application, before locating the abnormal transaction according to the target serial number to determine the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, the method includes: acquiring the abnormal transaction The current system call information corresponding to the transaction link, the current system call information includes at least the information of the current call originator system corresponding to the abnormal transaction and the information of the current called system; according to the current system call information, generate The sequence number of the above target sub-transaction. In this embodiment, the above-mentioned target sub-transaction sequence number is generated according to the calling information of the current system, so the system in which the abnormal transaction occurs can be located according to the above-mentioned target sub-transaction sequence number, thereby locating the abnormal invocation system more quickly.

本申请的一种具体的实施例中,在接收到上游系统传输的报文后,会将报文中的子交易序号存储到自定义的上下文中,自定义的上下文使用JAVA原生的ThreadLocal类来实现。ThreadLocal是一个线程内部的存储类,可以在指定线程内存储数据,数据存储以后,只有指定线程可以得到存储数据。ThreadLocal通过每个线程单独一份存储空间,它具有线程隔离的效果,只有在线程内才能获取到对应的值,线程外则不能访问到想要的值。因此,进行交易的当前线程能通过自定义的上下文获取到从上游系统传输至本系统的子交易序号。In a specific embodiment of the present application, after receiving the message transmitted by the upstream system, the sub-transaction sequence number in the message is stored in a custom context, and the custom context uses the JAVA native ThreadLocal class to accomplish. ThreadLocal is a storage class inside a thread, which can store data in a specified thread. After the data is stored, only the specified thread can get the stored data. ThreadLocal has a separate storage space for each thread. It has the effect of thread isolation. The corresponding value can only be obtained within the thread, and the desired value cannot be accessed outside the thread. Therefore, the current thread performing the transaction can obtain the sub-transaction sequence number transmitted from the upstream system to the current system through the self-defined context.

在自定义上下文中创建栈的数据结构,该结构用来存储新生成的子交易序号,记作子交易序号栈。该栈一开始存储的子交易序号个数为0,每生成一个新的子交易序号就将该子交易序号压入栈中,栈顶的元素永远是最新的子交易序号。需要注意的是,自定义上下文中一共有两个属性来存储子交易序号,在本申请中分别记作subTxNo和subTxNoStack两个属性的区别如下表三所示。The data structure of the stack is created in the custom context, which is used to store the newly generated sub-transaction sequence number, which is recorded as the sub-transaction sequence number stack. The number of sub-transaction sequence numbers stored in the stack at the beginning is 0. Each time a new sub-transaction sequence number is generated, the sub-transaction sequence number is pushed into the stack, and the element at the top of the stack is always the latest sub-transaction sequence number. It should be noted that there are a total of two attributes in the custom context to store the sub-transaction sequence number, which are respectively denoted as subTxNo and subTxNoStack in this application. The difference between the two attributes is shown in Table 3 below.

表三Table 3

Figure BDA0003539528190000111
Figure BDA0003539528190000111

Figure BDA0003539528190000121
Figure BDA0003539528190000121

需要对子交易序号升层时,主要通过子交易序号栈subTxNoStack中的元素个数是否为0来进行判断,如果为0表示当前系统未进行过子交易序号的生成,说明当前系统为首次调用外系统,则进行升层的逻辑。升层时,需要从自定义上下文中取出上游系统传输至本系统的子交易序号subTxNo,以它为基准,完成上述章节中子交易序号升层的逻辑,最后将新生成的子交易序号压入自定义上下文的子交易序号栈subTxNoStack中。When it is necessary to upgrade the sub-transaction sequence number, it is mainly judged by whether the number of elements in the sub-transaction sequence number stack subTxNoStack is 0. If it is 0, it means that the current system has not generated the sub-transaction sequence number, which means that the current system is the first call outside. system, then carry out the logic of upgrading. When upgrading, you need to take out the sub-transaction serial number subTxNo transmitted from the upstream system to this system from the custom context, use it as the benchmark, complete the sub-transaction serial number upgrade logic in the above chapter, and finally push the newly generated sub-transaction serial number into the The sub-transaction sequence number stack of the custom context is in subTxNoStack.

子交易序号升次时,也是通过子交易序号栈subTxNoStack中的元素个数是否为0来进行判断,如果不为0则表示当前系统已进行过子交易序号的生成,说明当前系统为非首次调用外系统,则进行升次的逻辑。升次时,需要从子交易序号栈subTxNoStack中获取栈顶的子交易序号,以该子交易序号为基准,完成上述章节中子交易序号升次的逻辑,最后将新生成的子交易序号压入子交易序号栈subTxNoStack中。When the sub-transaction sequence number increases, it is also judged by whether the number of elements in the sub-transaction sequence number stack subTxNoStack is 0. If it is not 0, it means that the current system has generated the sub-transaction sequence number, indicating that the current system is not the first call. If the external system is used, the logic of ascending order is performed. When ascending the order, you need to obtain the sub-transaction serial number on the top of the stack from the sub-transaction serial number stack subTxNoStack. Based on the sub-transaction serial number, complete the logic of the ascending order of the sub-transaction serial number in the above chapter, and finally push the newly generated sub-transaction serial number into Sub-transaction serial number stack subTxNoStack.

调用方系统需要生成子交易序号时,则将自定义上下文的子交易序号栈的栈顶元素返回给系统。When the calling system needs to generate a sub-transaction sequence number, it returns the top element of the sub-transaction sequence number stack of the custom context to the system.

本申请的又一种实施例中,依据上述当前系统调用信息,生成上述目标子交易序号,包括:获取上述当前调用发起方系统对应的标识码,并将上述标识码确定为上述目标子交易序号的前缀;生成上述目标子交易序号,以获取交易实例序号;确定上述当前系统处于上述交易链路的层级,并确定上述层级对应的层级号;将上述前缀、上述层级号依次排列,并确定除上述前缀以及上述层级号以外的字符为0,以生成上述目标子交易序号对应的基准序号;获取上述当前调用发起方系统调用上述当前被调用系统的调用情况,并依据上述调用情况对上述基准序号调整;将调整后的上述基准序号,确定为上述目标子交易序号。本实施例中,首先确定调用发起发系统的前缀和交易所处的层级号,然后确定目标子交易序号中的字符个数,将上述前缀、上述层级号依次排列,并确定除上述前缀以及上述层级号以外的字符为0,从而生成目标子交易序号,这样从生成的目标子交易序号中通过前缀就可以快速定位到调用的发起方系统,根据层级号,就可以定位到调用了几次,从而更加快速地定位发生异常的系统。In another embodiment of the present application, generating the target sub-transaction sequence number according to the current system invocation information includes: acquiring an identification code corresponding to the current invocation initiator system, and determining the identification code as the target sub-transaction sequence number generate the above-mentioned target sub-transaction serial number to obtain the transaction instance serial number; determine that the above-mentioned current system is at the level of the above-mentioned transaction link, and determine the level number corresponding to the above-mentioned level; The characters other than the above-mentioned prefix and the above-mentioned level number are set to 0, so as to generate the reference sequence number corresponding to the above-mentioned target sub-transaction sequence number; obtain the calling situation of the above-mentioned current calling initiator system calling the above-mentioned currently called system, and according to the above-mentioned calling situation. Adjustment; determine the above-mentioned benchmark serial number after adjustment as the above-mentioned target sub-transaction serial number. In this embodiment, first determine the prefix of the calling and issuing system and the level number at the exchange, then determine the number of characters in the sequence number of the target sub-transaction, arrange the above prefix and the above level number in sequence, and determine to remove the above prefix and the above The character other than the level number is 0, so that the target sub-transaction sequence number is generated, so that from the generated target sub-transaction sequence number, the calling initiator system can be quickly located through the prefix. Thereby, the abnormal system can be located more quickly.

上述目标子交易序号生成过程具体如下:以图7所示的交易链路为例,此链路重点关注最新交易编排号的生成流程,针对子交易序号中系统号和交易实例序号统一使用相应的占位符来表示,比如系统A使用字母“A”来表示其系统号和交易实例序号,系统B使用字母“B”表示其系统号和交易实例序号,以此类推。The above-mentioned target sub-transaction sequence number generation process is as follows: Take the transaction link shown in Figure 7 as an example, this link focuses on the generation process of the latest transaction sequence number, and uses the corresponding system number and transaction instance sequence number in the sub-transaction sequence number uniformly. For example, system A uses the letter "A" to represent its system number and transaction instance serial number, system B uses the letter "B" to represent its system number and transaction instance serial number, and so on.

(1)系统A作为交易发起方生成此笔交易第一个子交易序号,该子交易序号为“A1000000000000000000”。系统A作为交易发起方,其交易层级号为1,因此其对应的最新交易编排号中第一位为1,后19位都为0;(1) System A, as the transaction initiator, generates the first sub-transaction serial number of this transaction, and the sub-transaction serial number is "A1000000000000000000". System A is the transaction initiator, and its transaction level number is 1, so the first digit in the corresponding latest transaction number is 1, and the last 19 digits are 0;

(2)系统A首先调用系统B,然后调用系统C,再调用系统D。(2) System A first calls system B, then calls system C, and then calls system D.

此时需要生成三个新的子交易序号来表示这三个调用分支,三个子交易序号中的系统号和交易实例序号都由系统A来生成,因此子交易序号的前缀都是A。第一次,系统A调用系统B,属于系统A首次调用外系统,因此需要进行升层的逻辑,以第一个子交易序号“A1000000000000000000”为基准,按照上述升层的逻辑,得到的子交易序号为“A1100000000000000000”;第二次,系统A调用系统C,非系统A首次调用外系统,因此需要进行升次的逻辑,以上一个子交易序号“A1100000000000000000”为基准,按照升次的逻辑,得到的子交易序号为“A1200000000000000000”;第三次,系统A调用D,非系统A首次调用外系统,因此需要进行升次的逻辑,以上一个子交易序号“A1200000000000000000”为基准,按照升次的逻辑,得到的子交易序号为“A1300000000000000000”。At this time, three new sub-transaction sequence numbers need to be generated to represent the three call branches. The system number and transaction instance sequence number in the three sub-transaction sequence numbers are generated by system A, so the prefixes of the sub-transaction sequence numbers are all A. For the first time, system A calls system B, which is the first time that system A calls an external system. Therefore, the logic of upgrading is required. Based on the first sub-transaction serial number "A1000000000000000000", according to the above-mentioned upgrading logic, the obtained sub-transaction The serial number is "A110000000000000000"; the second time, system A calls system C, and non-system A calls the external system for the first time, so the logic of ascending order needs to be performed. The sub-transaction serial number is "A1200000000000000000"; the third time, system A calls D, and non-system A calls the external system for the first time, so the logic of ascending order needs to be performed. , the obtained sub-transaction serial number is "A1300000000000000000".

(3)系统B调用系统E,系统B调用系统F。此时需要生成两个新的子交易序号来表示这两个调用子分支,两个子交易序号中的系统号和交易实例序号都是由系统B来生成。第一次,系统B调用系统E,属于系统B首次调用外系统,因此需要进行升层的逻辑,以前一个子交易序号“A1100000000000000000”为基准,按照升层的逻辑,生成的子交易序号为“B1110000000000000000”;第二次,系统B调用系统F,非系统B首次调用外系统,因此需要进行升次的逻辑,以前一个子交易序号“B1110000000000000000”为基准,按照升次的逻辑,得到的子交易序号为“B1120000000000000000”。(3) System B calls system E, and system B calls system F. In this case, two new sub-transaction sequence numbers need to be generated to represent the two calling sub-branches. The system number and transaction instance sequence number in the two sub-transaction sequence numbers are both generated by system B. For the first time, system B calls system E, which is the first time that system B calls an external system. Therefore, the logic of upgrading is required. The previous sub-transaction serial number "A1100000000000000000" is the benchmark. According to the upgrading logic, the generated sub-transaction serial number is " B1110000000000000000"; the second time, system B calls system F, and non-system B calls the external system for the first time, so the logic of ascending order needs to be performed. The serial number is "B1120000000000000000".

(4)系统D调用系统G。此时需要生成一个新的子交易序号来表示这个调用子分支,该子交易序号的系统号和交易实例序号是由系统D来生成。系统D调用系统G,属于系统D首次调用外系统,因此需要进行升层的逻辑,以上一个子交易序号“A1300000000000000000”为基准,按照升层的逻辑,得到的子交易序号为“D1310000000000000000”。至此,此条交易链路的最新交易编排号生成流程已完成。(4) System D calls system G. At this time, a new sub-transaction sequence number needs to be generated to represent the calling sub-branch. The system number and transaction instance sequence number of the sub-transaction sequence number are generated by system D. System D calls system G, which is the first time that system D calls an external system. Therefore, the logic of upgrading is required. Based on the previous sub-transaction serial number "A1300000000000000000", according to the upgrading logic, the obtained sub-transaction serial number is "D1310000000000000000". So far, the latest transaction arrangement number generation process for this transaction link has been completed.

以上述生成的目标子交易序号“D1310000000000000000”为例,首先可以了解到系统调用方为系统D;在后20位的最新交易编排号中,一共有3个非0字符,则表明当前系统在交易链路中的交易层级号为3;找到最新交易编排号从左往右第一个出现字符0的位置,记作pos,pos减一的位置其对应的字符为“1”,表示当前系统为系统D调用的第一个系统。Taking the target sub-transaction serial number "D1310000000000000000" generated above as an example, you can first know that the system caller is system D; in the last 20 digits of the latest transaction number, there are a total of 3 non-zero characters, indicating that the current system is in the transaction The transaction level number in the link is 3; find the position where the character 0 appears first from left to right in the latest transaction arrangement number, and record it as pos. The first system called by system D.

为了更加快速地定位发生异常的系统,本申请的另一种实施例中,获取上述当前调用发起方系统调用上述当前被调用系统的调用情况,并依据上述调用情况对上述基准序号调整,包括:判断上述当前调用发起方系统在调用上述当前被调用系统时,上述当前调用发起方系统是否为首次调用外系统;在上述当前调用发起方系统为首次调用上述外系统的情况下,对上述基准序号进行升层处理以使上述基准序号中第一位为0的字符转换为1;在上述当前调用发起方系统为非首次调用上述外系统的情况下,对上述基准序号进行升次处理以调整上述基准序号中的层级号加1。本实施例中,根据上述调用发起方系统是否为首次调用外系统进行升层逻辑或者升次逻辑,这样根据基准序号中的第一位和层级号就可以得到当前系统的调用情况。In order to locate the abnormal system more quickly, in another embodiment of the present application, the calling situation of the current calling initiator system calling the current called system is obtained, and the reference sequence number is adjusted according to the calling situation, including: Judging whether the current calling initiator system is the first call to the external system when the current calling initiator system calls the current called system; in the case that the current calling initiator system is the first call to the external system, the above reference sequence number Perform upgrade processing to convert the character whose first digit is 0 in the above-mentioned reference sequence number to 1; in the case that the above-mentioned current invocation originator system is not the first time to call the above-mentioned external system, the above-mentioned reference sequence number is upgraded by processing to adjust the above-mentioned The level number in the reference sequence number is incremented by 1. In this embodiment, according to whether the above-mentioned calling initiator system is the first call to the external system to perform the upgrade logic or the upgrade logic, the calling status of the current system can be obtained according to the first digit in the reference sequence number and the level number.

本申请的一种具体的实施例中,上述升层逻辑如图8所示,需要在最新交易编排号中从左到右找到第一个出现字符0的位置,如果该位置存在,则将字符0修改为1即完成最新交易编排号的升层逻辑,如果该位置不存在则表示交易层级号已经达到最大,无法继续升层。In a specific embodiment of the present application, the above-mentioned upgrade logic is shown in FIG. 8 . It is necessary to find the first position where the character 0 appears in the latest transaction number from left to right. If the position exists, the character If 0 is changed to 1, the upgrade logic of the latest transaction arrangement number is completed. If this position does not exist, it means that the transaction level number has reached the maximum, and the upgrade cannot be continued.

本申请的另一种具体的实施例中,上述升次逻辑如图9所示,首先在最新交易编排号从左往右找到第一个出现字符0的位置,记作pos。如果pos存在,则获取pos减1位置的字符,然后判断该字符是否为Z计数,进制运算,如果为Z则表示同层级交易实例数已达到最大,如果不为Z,则将该字符进行自增。字符自增需要注意的是,当字符为9时,自增后的结果为A。如果pos不存在,则获取最新交易编排号中最后一位字符,然后进行判断该字符是否为Z,后面的步骤与前面步骤一致。In another specific embodiment of the present application, the above-mentioned ascending logic is shown in FIG. 9 . First, the position where the character 0 appears first is found in the latest transaction arrangement number from left to right, which is denoted as pos. If pos exists, obtain the character at the position of pos minus 1, and then judge whether the character is counted by Z, and the base operation is performed. If it is Z, it means that the number of transaction instances at the same level has reached the maximum. auto increment. It should be noted that when the character is auto-incremented, when the character is 9, the result of the auto-increment is A. If pos does not exist, obtain the last character in the latest transaction arrangement number, and then judge whether the character is Z, and the following steps are the same as the previous steps.

本发明实施例还提供了一种定位异常交易的装置,需要说明的是,本发明实施例的定位异常交易的装置可以用于执行本发明实施例所提供的用于定位异常交易的方法。以下对本发明实施例提供的定位异常交易的装置进行介绍。The embodiment of the present invention further provides an apparatus for locating abnormal transactions. It should be noted that the apparatus for locating abnormal transactions in the embodiments of the present invention may be used to execute the method for locating abnormal transactions provided by the embodiments of the present invention. The following describes the device for locating abnormal transactions provided by the embodiments of the present invention.

图2是根据本发明实施例的定位异常交易的装置的示意图。如图2所示,该装置包括:FIG. 2 is a schematic diagram of an apparatus for locating abnormal transactions according to an embodiment of the present invention. As shown in Figure 2, the device includes:

第一获取单元10,用于在检测到多个交易中存在异常交易的情况下,获取上述异常交易对应的目标流水号;The first obtaining unit 10 is configured to obtain the target serial number corresponding to the abnormal transaction in the case of detecting that there is an abnormal transaction in the plurality of transactions;

定位单元20,用于依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易的信息以及上述异常交易在交易链路中发生异常时对应的调用系统,上述调用系统包括交易的调用发起方系统。。The locating unit 20 is configured to locate the above-mentioned abnormal transaction according to the above-mentioned target serial number, so as to determine the information of the above-mentioned abnormal transaction and the corresponding calling system when the above-mentioned abnormal transaction is abnormal in the transaction link, and the above-mentioned calling system includes the invocation of the transaction. square system. .

上述的装置,包括第一获取单元和定位单元,上述获取单元用于在检测到多个交易中存在异常交易的情况下,获取异常交易对应的目标流水号,上述定位单元用于根据目标流水号对异常交易进行定位,确定异常交易的信息以及发生异常时对应的调用系统,调用系统包括交易调用的发起方系统以及被调用系统。该装置中,获取到异常交易的目标流水号具有唯一性,可以唯一定位一笔交易,并且可以描述交易链路的调用的各个系统,所以根据该目标流水号可以定位到异常交易的信息以及发生异常时的调用系统,从而实现根据目标流水号就可以定位到发生异常的系统,进而解决了相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的技术问题。The above-mentioned device includes a first acquisition unit and a positioning unit, the above-mentioned acquisition unit is used to obtain the target serial number corresponding to the abnormal transaction in the case of detecting that there are abnormal transactions in multiple transactions, and the above-mentioned positioning unit is used for according to the target serial number. Locate the abnormal transaction, determine the information of the abnormal transaction and the corresponding calling system when the abnormality occurs. The calling system includes the initiator system and the called system of the transaction call. In this device, the target serial number of the abnormal transaction is unique, which can uniquely locate a transaction and describe the various systems of the transaction link. Therefore, according to the target serial number, the information and occurrence of abnormal transactions can be located. The system is called when an exception occurs, so that the abnormal system can be located according to the target serial number, thereby solving the technical problem that the transaction serial number in the related technology is difficult to locate the abnormal system when the transaction occurs. .

本申请的一种实施例中,上述第一获取单元包括第一获取子单元和第二获取子单元,其中,上述第一获取子单元用于在检测到多个交易中存在异常交易的情况下,获取上述异常交易在交易过程中生成的当前报文;上述第二获取子单元用于获取所述报文中包含的所述目标流水号,其中,所述目标流水号包括所述异常交易对应的全局业务跟踪号以及所述异常交易对应的子交易序号,所述全局业务跟踪号贯穿所述异常交易对应的整个交易过程。进行跨系统调用时,会使用标准的公共报文来记录交易所需的关键字段,目标流水号属于需要记录的关键字段,所以可以从当前报文中,获取上述目标流水号,上述目标流水号包括贯穿上述异常交易的整个交易过程的全局业务跟踪号和子交易序号,本实施例并不需要生成新的目标流水号,直接从当前报文中获取,从而实现快速定位交易异常的系统。In an embodiment of the present application, the first acquisition unit includes a first acquisition subunit and a second acquisition subunit, wherein the first acquisition subunit is used when abnormal transactions are detected among the multiple transactions , to obtain the current message generated by the abnormal transaction during the transaction process; the second obtaining subunit is used to obtain the target serial number contained in the message, wherein the target serial number includes the corresponding number of the abnormal transaction. The global business tracking number and the sub-transaction sequence number corresponding to the abnormal transaction, and the global business tracking number runs through the entire transaction process corresponding to the abnormal transaction. When making a cross-system call, the standard public message will be used to record the key fields required for the transaction. The target serial number belongs to the key field that needs to be recorded. Therefore, the above target serial number can be obtained from the current message. The above target serial number The serial number includes the global business tracking number and sub-transaction serial number throughout the entire transaction process of the abnormal transaction. This embodiment does not need to generate a new target serial number and is directly obtained from the current message, thereby realizing a system for quickly locating transaction abnormality.

为了得到准确的异常交易的信息,本申请的再一种实施例中,上述定位单元包括第一解析子单元和第一确定子单元,其中,上述第一解析子单元用于对上述全局业务跟踪号进行解析,并获得第一解析结果,其中,上述第一解析结果至少包括时间戳、第一系统号、第一交易实例序号以及序列号,上述时间戳为上述异常交易在交易发起时对应的时间戳,上述第一系统号上述异常交易的原始发起方系统对应的标识码,上述第一交易实例序号为上述异常交易对应的交易实例所在机器的标识码,上述序列号为上述异常交易在发起时,为上述原始发起方系统生成的循环递增的序列号;上述第一确定子单元用于依据上述第一解析结果,确定上述异常交易的信息。全局业务跟踪号由触发点生成,一致持续到时间完整结束,所以全局业务跟踪号中记录了上述异常交易的信息,所以,本实施例中,需要先对全局业务跟踪号进行解析,得到第一解析结果,根据第一解析结果就可以得到全局业务跟踪号中所记录的异常交易的信息。In order to obtain accurate abnormal transaction information, in another embodiment of the present application, the positioning unit includes a first analysis subunit and a first determination subunit, wherein the first analysis subunit is used for tracking the global business The first analysis result includes at least a time stamp, a first system number, a first transaction instance serial number and a serial number, and the above time stamp is the corresponding abnormal transaction when the transaction is initiated. Timestamp, the above-mentioned first system number The identification code corresponding to the system of the original initiator of the above-mentioned abnormal transaction, the above-mentioned first transaction instance serial number is the identification code of the machine where the transaction instance corresponding to the above-mentioned abnormal transaction is located, and the above-mentioned serial number is the above-mentioned abnormal transaction. is the cyclically incremented serial number generated by the original initiator system; the first determination subunit is configured to determine the abnormal transaction information according to the first analysis result. The global business tracking number is generated by the trigger point, and lasts consistently until the time completes. Therefore, the information about the above abnormal transaction is recorded in the global business tracking number. Therefore, in this embodiment, the global business tracking number needs to be parsed first to obtain the first According to the analysis result, the abnormal transaction information recorded in the global business tracking number can be obtained according to the first analysis result.

上述全局业务跟踪号在系统中有可能作为数据库主键来进行使用,对于数据库的主键来说,要求主键长度不能过长,另外考虑到全局全局业务跟踪号组成部分较多,本申请的一种具体的实施例中将上述全局业务跟踪号设置为32位。上述全局业务跟踪号的组成如表一所示:The above-mentioned global business tracking number may be used as the primary key of the database in the system. For the primary key of the database, the length of the primary key is required not to be too long. In addition, considering that there are many components of the global global business tracking number, a specific In this embodiment, the above-mentioned global service tracking number is set to 32 bits. The composition of the above global service tracking number is shown in Table 1:

表一Table I

Figure BDA0003539528190000171
Figure BDA0003539528190000171

上述时间戳:通过获取本地系统时间来生成,属于技术字段。The above timestamp: generated by obtaining the local system time, which belongs to the technical field.

上述系统号:对所有系统按照业务职能的划分进行编排,是具有业务属性的编码,该部分组成为7位,它是来源于统一的标准。例如,存款系统使用“1111111”,汇款系统使用“2222222”。使用、全局业务跟踪号中的系统号由交易发起方生成。The above system number: All systems are arranged according to the division of business functions. It is a code with business attributes. This part consists of 7 digits, which is derived from a unified standard. For example, the deposit system uses "1111111" and the remittance system uses "2222222". Used, the system number in the global business tracking number is generated by the transaction initiator.

上述交易实例序号:该组成部分属于技术字段。生成流程如图3所示,发起交易实例序号获取时,首先从本地的环境变量中获取,上述环境变量为服务器里配置的一个环境参数,如果存在则直接返回,如果不存在则从系统的启动参数中获取,如果启动参数中存在交易实例序号的配置则直接返回,如果不存在则通过本地默认实现的算法来生成。全局业务跟踪号中的交易实例序号由交易发起方生成。The above transaction instance serial number: This component belongs to the technical field. The generation process is shown in Figure 3. When initiating the acquisition of the transaction instance serial number, it is first obtained from the local environment variable. The above environment variable is an environment parameter configured in the server. If it exists, it will return directly. If it does not exist, it will be obtained from the system startup. If the configuration of the transaction instance serial number exists in the startup parameters, it will be returned directly. If it does not exist, it will be generated by the local default algorithm. The transaction instance serial number in the global business tracking number is generated by the transaction initiator.

上述序列号的生成:在本申请中,序列号循环使用,其生成的流程如图4所示。序列号采用Java原生的AtomicInteger来进行自增,自增后得到的结果判断是否大于999999,如果大于则将序列号置为1并进行字符串格式化,如果不大于999999就将得到的结果进行字符串格式,生成最终的序列号。Generation of the above-mentioned serial number: In this application, the serial number is used cyclically, and the flow of its generation is shown in FIG. 4 . The serial number is self-incremented using Java's native AtomicInteger. The result obtained after self-increment is judged whether it is greater than 999999. If it is greater than 1, the serial number is set to 1 and the string is formatted. If it is not greater than 999999, the obtained result is character string format to generate the final serial number.

将以上生成的14位时间戳、7位系统编码、5位发起交易实例序号和6位序列号拼接,即得到生成的全局业务跟踪号。如图5所示,假设有一笔交易,其交易链路如下图所示。系统A作为交易发起方,则由系统A来生成此笔交易的全局业务跟踪号,系统B和系统C不会再生成全局业务跟踪号。交易中每次系统间的调用都会将全局业务跟踪号发送至下游系统。The generated global business tracking number is obtained by splicing the 14-digit timestamp, 7-digit system code, 5-digit transaction instance serial number and 6-digit serial number generated above. As shown in Figure 5, suppose there is a transaction, and its transaction link is shown in the figure below. If system A is the transaction initiator, system A will generate the global business tracking number for this transaction, and system B and system C will not generate the global business tracking number again. Each inter-system call in the transaction sends the global business tracking number to the downstream system.

本申请的又一种实施例中,如图6所示,上述装置还包括第二获取单元、第一计算单元和第二计算单元,其中,上述第二获取单元用于在依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易的信息之前,获取上述异常交易对应的原始交易实例所在机器对应的MAC地址;上述第一计算单元用于计算上述MAC地址对应的hash值,并对上述hash值进行取模运算以得到取模结果;上述第二计算单元用于对上述取模结果进行补零操作以得到上述第一交易实例序号。本实施例中,通过原始交易实例所在机器的MAC地址,计算hash值,然后对hash值进行取模运算,最后对取模运算的结果进行补零操作,从而得到准确的第一交易实施例序号。In yet another embodiment of the present application, as shown in FIG. 6 , the above-mentioned apparatus further includes a second obtaining unit, a first calculating unit and a second calculating unit, wherein the above-mentioned second obtaining unit is configured to The above-mentioned abnormal transaction is located, and before the information of the above-mentioned abnormal transaction is determined, the MAC address corresponding to the machine where the original transaction instance corresponding to the above-mentioned abnormal transaction is located is obtained; the above-mentioned first calculation unit is used to calculate the hash value corresponding to the above-mentioned MAC address, and to The above-mentioned hash value is subjected to a modulo operation to obtain a modulo result; the above-mentioned second calculation unit is configured to perform a zero-fill operation on the above-mentioned modulo result to obtain the above-mentioned first transaction instance serial number. In this embodiment, the hash value is calculated based on the MAC address of the machine where the original transaction instance is located, then a modulo operation is performed on the hash value, and a zero-fill operation is performed on the result of the modulo operation, thereby obtaining an accurate first transaction embodiment serial number .

例如,若交易实例序号为5位,则对99999(5个9)取模,若交易实例序号为6位,则对999999(6个9)进行取模。最后,对取模结果进行字符串格式化(即补零操作)完成交易实例序号的生成。For example, if the transaction instance serial number is 5 digits, then modulo 99999 (five 9s), if the transaction instance serial number is 6 digits, then take the modulo 999999 (six 9s). Finally, string formatting (that is, zero-filling operation) is performed on the modulo result to complete the generation of the transaction instance serial number.

本申请的另一种实施例中,上述定位单元包括第三获取子单元、第二解析子单元和第二确定子单元,其中,上述第三获取子单元用于获取上述目标流水号中包含的多个上述子交易序号中的目标子交易序号,其中,上述目标子交易序号为上述异常交易在交易过程中生成的当前子交易序号;上述第二解析子单元用于对上述目标子交易序号进行解析,并获得第二解析结果,其中,上述第二解析结果至少包括第二系统号、第二交易实例序号以及最新交易编排号,上述第二系统号为上述异常交易对应的上述当前调用发起方系统对应的标识码、上述第二交易实例序号为上述当前调用发起方系统生成的上述异常交易对应的交易实例所在机器的标识码,上述最新交易编排号从横向以及纵向两个维度表示当前调用过程中对系统的调用链路;上述第二确定子单元用于依据上述第二解析结果,确定上述异常交易在交易链路中发生异常时对应的调用系统。本实施例中,需要先对上述目标子交易序号,得到第二系统号、第二交易实例序号以及最新交易编排号,通过上述第二系统号、上述第二交易实例序号以及上述最新交易编排号就可以定位异常交易的调用发起系统以及调用过程的交易链路,从而实现对复杂链路中的发生异常的调用系统快速定位。In another embodiment of the present application, the positioning unit includes a third acquisition subunit, a second analysis subunit, and a second determination subunit, wherein the third acquisition subunit is used to acquire the target serial number included in the The target sub-transaction sequence number in the plurality of sub-transaction sequence numbers, wherein the target sub-transaction sequence number is the current sub-transaction sequence number generated during the transaction process of the abnormal transaction; the second parsing sub-unit is used to analyze the target sub-transaction sequence number. Parse, and obtain a second parsing result, wherein the second parsing result at least includes the second system number, the second transaction instance serial number, and the latest transaction arrangement number, and the second system number is the current calling initiator corresponding to the abnormal transaction. The identification code corresponding to the system and the sequence number of the second transaction instance are the identification code of the machine where the transaction instance corresponding to the abnormal transaction generated by the current invocation initiator system is located, and the latest transaction arrangement number indicates the current invocation process from horizontal and vertical dimensions The second determining subunit is used to determine the corresponding calling system when the abnormal transaction occurs in the transaction link according to the second analysis result. In this embodiment, it is necessary to obtain the second system number, the second transaction instance serial number and the latest transaction arrangement number from the above-mentioned target sub-transaction serial numbers. The call initiation system of the abnormal transaction and the transaction link of the call process can be located, thereby realizing the rapid location of the abnormal call system in the complex link.

上述目标子交易序号包括第二系统号、第二交易实例序号和最新交易编排号。上述目标子交易序号主要用于标识一笔交易的各个调用子分支。上述目标子交易序号的组成如表二所示:The above-mentioned target sub-transaction sequence number includes the second system number, the second transaction instance sequence number and the latest transaction arrangement number. The above target sub-transaction sequence number is mainly used to identify each calling sub-branch of a transaction. The composition of the above target sub-transaction serial numbers is shown in Table 2:

表二Table II

Figure BDA0003539528190000191
Figure BDA0003539528190000191

上述第二系统号与上述全局业务跟踪号中的系统号不一样的地方在于上述第二系统号由当前调用发起方系统生成。The difference between the second system number and the system number in the global service tracking number is that the second system number is generated by the current calling initiator system.

上述交易实例序号的生成方法与上述全局业务跟踪号的方法一致,但不同点是交易实例序号由调用发起方系统生成。The method for generating the transaction instance serial number is the same as the method for generating the global business tracking number above, but the difference is that the transaction instance serial number is generated by the calling initiator system.

上述最新交易编排号由字母和数字组成。最新交易编排号一共20位,表示交易层级号最大支持20层,最新交易编排号中每一位的字符取值范围为“1-9,A-Z”,表示同层级交易实例数最大支持35个。最新交易编排号从横向、纵向两个维度表示交易的调用链路,最新交易编排号沿交易链路往后传递。最新交易编排号初始值全为0,交易链路上每发生一次系统调用,最新交易编排号将会进行升层或升次的逻辑。The latest transaction number listed above consists of letters and numbers. The latest transaction sequence number has a total of 20 digits, indicating that the transaction level number supports a maximum of 20 layers. The character value range of each digit in the latest transaction sequence number is "1-9, A-Z", indicating that the maximum number of transaction instances at the same level supports 35. The latest transaction arrangement number represents the call link of the transaction from the horizontal and vertical dimensions, and the latest transaction arrangement number is passed along the transaction link. The initial value of the latest transaction arrangement number is all 0. Every time a system call occurs on the transaction link, the latest transaction arrangement number will be upgraded or upgraded.

本申请的再一种实施例中,上述装置包括第三获取单元和生成单元,其中,第三获取单元用于在依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易在交易链路中发生异常时对应的调用系统之前,获取上述异常交易在上述交易链路中对应的当前系统调用信息,上述当前系统调用信息至少包括上述异常交易对应的上述当前调用发起方系统的信息以及上述当前被调用系统的信息;上述生成单元用于依据上述当前系统调用信息,生成上述目标子交易序号。本实施例中,上述目标子交易序号是根据当前系统的调用信息生成的,所以后续根据上述目标子交易序号,就可以定位到发生异常交易的系统,从而更加快速地定位发生异常的调用系统。In still another embodiment of the present application, the above-mentioned apparatus includes a third acquisition unit and a generation unit, wherein the third acquisition unit is used to locate the above-mentioned abnormal transaction according to the above-mentioned target serial number, so as to determine that the above-mentioned abnormal transaction is in the transaction chain Before calling the system corresponding to the abnormal transaction in the road, obtain the current system call information corresponding to the above abnormal transaction in the above transaction link. Information of the currently called system; the generating unit is configured to generate the sequence number of the target sub-transaction according to the current system calling information. In this embodiment, the above-mentioned target sub-transaction sequence number is generated according to the calling information of the current system, so the system in which the abnormal transaction occurs can be located according to the above-mentioned target sub-transaction sequence number, thereby locating the abnormal invocation system more quickly.

本申请的一种具体的实施例中,在接收到上游系统传输的报文后,会将报文中的子交易序号存储到自定义的上下文中,自定义的上下文使用JAVA原生的ThreadLocal类来实现。ThreadLocal是一个线程内部的存储类,可以在指定线程内存储数据,数据存储以后,只有指定线程可以得到存储数据。ThreadLocal通过每个线程单独一份存储空间,它具有线程隔离的效果,只有在线程内才能获取到对应的值,线程外则不能访问到想要的值。因此,进行交易的当前线程能通过自定义的上下文获取到从上游系统传输至本系统的子交易序号。In a specific embodiment of the present application, after receiving the message transmitted by the upstream system, the sub-transaction sequence number in the message is stored in a custom context, and the custom context uses the JAVA native ThreadLocal class to accomplish. ThreadLocal is a storage class inside a thread, which can store data in a specified thread. After the data is stored, only the specified thread can get the stored data. ThreadLocal has a separate storage space for each thread. It has the effect of thread isolation. The corresponding value can only be obtained within the thread, and the desired value cannot be accessed outside the thread. Therefore, the current thread performing the transaction can obtain the sub-transaction sequence number transmitted from the upstream system to the current system through the self-defined context.

在自定义上下文中创建栈的数据结构,该结构用来存储新生成的子交易序号,记作子交易序号栈。该栈一开始存储的子交易序号个数为0,每生成一个新的子交易序号就将该子交易序号压入栈中,栈顶的元素永远是最新的子交易序号。需要注意的是,自定义上下文中一共有两个属性来存储子交易序号,在本申请中分别记作subTxNo和subTxNoStack两个属性的区别如下表三所示。The data structure of the stack is created in the custom context, which is used to store the newly generated sub-transaction sequence number, which is recorded as the sub-transaction sequence number stack. The number of sub-transaction sequence numbers stored in the stack at the beginning is 0. Each time a new sub-transaction sequence number is generated, the sub-transaction sequence number is pushed into the stack, and the element at the top of the stack is always the latest sub-transaction sequence number. It should be noted that there are a total of two attributes in the custom context to store the sub-transaction sequence number, which are respectively denoted as subTxNo and subTxNoStack in this application. The difference between the two attributes is shown in Table 3 below.

表三Table 3

Figure BDA0003539528190000211
Figure BDA0003539528190000211

需要对子交易序号升层时,主要通过子交易序号栈subTxNoStack中的元素个数是否为0来进行判断,如果为0表示当前系统未进行过子交易序号的生成,说明当前系统为首次调用外系统,则进行升层的逻辑。升层时,需要从自定义上下文中取出上游系统传输至本系统的子交易序号subTxNo,以它为基准,完成上述章节中子交易序号升层的逻辑,最后将新生成的子交易序号压入自定义上下文的子交易序号栈subTxNoStack中。When it is necessary to upgrade the sub-transaction sequence number, it is mainly judged by whether the number of elements in the sub-transaction sequence number stack subTxNoStack is 0. If it is 0, it means that the current system has not generated the sub-transaction sequence number, which means that the current system is the first call outside. system, then carry out the logic of upgrading. When upgrading, you need to take out the sub-transaction serial number subTxNo transmitted from the upstream system to this system from the custom context, use it as the benchmark, complete the sub-transaction serial number upgrade logic in the above chapter, and finally push the newly generated sub-transaction serial number into the The sub-transaction sequence number stack of the custom context is in subTxNoStack.

子交易序号升次时,也是通过子交易序号栈subTxNoStack中的元素个数是否为0来进行判断,如果不为0则表示当前系统已进行过子交易序号的生成,说明当前系统为非首次调用外系统,则进行升次的逻辑。升次时,需要从子交易序号栈subTxNoStack中获取栈顶的子交易序号,以该子交易序号为基准,完成上述章节中子交易序号升次的逻辑,最后将新生成的子交易序号压入子交易序号栈subTxNoStack中。When the sub-transaction sequence number increases, it is also judged by whether the number of elements in the sub-transaction sequence number stack subTxNoStack is 0. If it is not 0, it means that the current system has generated the sub-transaction sequence number, indicating that the current system is not the first call. If the external system is used, the logic of ascending order is performed. When ascending the order, you need to obtain the sub-transaction serial number on the top of the stack from the sub-transaction serial number stack subTxNoStack. Based on the sub-transaction serial number, complete the logic of the ascending order of the sub-transaction serial number in the above chapter, and finally push the newly generated sub-transaction serial number into Sub-transaction serial number stack subTxNoStack.

调用方系统需要生成子交易序号时,则将自定义上下文的子交易序号栈的栈顶元素返回给系统。When the calling system needs to generate a sub-transaction sequence number, it returns the top element of the sub-transaction sequence number stack of the custom context to the system.

本申请的又一种实施例中,上述生成单元包括第四获取子单元、第一生成子单元、第三确定子单元、第四确定子单元、第五确定子单元、第二生成子单元、第五获取子单元和第六确定子单元,其中,上述第四获取子单元用于获取上述当前调用发起方系统对应的标识码,并将上述标识码确定为上述目标子交易序号的前缀;上述第一生成子单元用于生成上述目标子交易序号,以获取交易实例序号;上述第三确定子单元用于确定上述当前系统处于上述交易链路的层级,并确定上述层级对应的层级号;上述第四确定子单元用于确定上述当前系统处于上述交易链路的当前层级的编号;上述第五确定子单元用于确定上述目标子交易序号中包含的字符个数;上述第二生成子单元用于将上述前缀、上述层级号依次排列,并确定除上述前缀以及上述层级号以外的字符为0,以生成上述目标子交易序号对应的基准序号;上述第五获取子单元用于获取上述当前调用发起方系统调用上述当前被调用系统的调用情况,并依据上述调用情况对上述基准序号调整;上述第六确定子单元用于将调整后的上述基准序号,确定为上述目标子交易序号。本实施例中,首先确定调用发起发系统的前缀和交易所处的层级号,然后确定目标子交易序号中的字符个数,将上述前缀、上述层级号依次排列,并确定除上述前缀以及上述层级号以外的字符为0,从而生成目标子交易序号,这样从生成的目标子交易序号中通过前缀就可以快速定位到调用的发起方系统,根据层级号,就可以定位到调用了几次,从而更加快速地定位发生异常的系统。In another embodiment of the present application, the generating unit includes a fourth acquiring subunit, a first generating subunit, a third determining subunit, a fourth determining subunit, a fifth determining subunit, a second generating subunit, The fifth acquisition subunit and the sixth determination subunit, wherein the fourth acquisition subunit is used to acquire the identification code corresponding to the current call initiator system, and determine the identification code as the prefix of the target sub-transaction sequence number; the above The first generation subunit is used to generate the above-mentioned target sub-transaction sequence number to obtain the transaction instance sequence number; the above-mentioned third determination subunit is used to determine that the above-mentioned current system is at the level of the above-mentioned transaction link, and to determine the level number corresponding to the above-mentioned level; the above-mentioned The fourth determination subunit is used to determine the number of the current system at the current level of the transaction link; the fifth determination subunit is used to determine the number of characters contained in the target sub-transaction sequence number; the second generation subunit is used for The above-mentioned prefix and the above-mentioned level number are arranged in sequence, and the characters other than the above-mentioned prefix and the above-mentioned level number are determined to be 0, so as to generate the reference sequence number corresponding to the above-mentioned target sub-transaction serial number; the above-mentioned fifth obtaining subunit is used to obtain the above-mentioned current call The initiator system invokes the invocation status of the current called system, and adjusts the reference sequence number according to the invocation status; the sixth determination subunit is used to determine the adjusted reference sequence number as the target sub-transaction sequence number. In this embodiment, first determine the prefix of the calling and issuing system and the level number at the exchange, then determine the number of characters in the sequence number of the target sub-transaction, arrange the above prefix and the above level number in sequence, and determine to remove the above prefix and the above The character other than the level number is 0, so that the target sub-transaction sequence number is generated, so that from the generated target sub-transaction sequence number, the calling initiator system can be quickly located through the prefix. Thereby, the abnormal system can be located more quickly.

上述目标子交易序号生成过程具体如下:以图7所示的交易链路为例,此链路重点关注最新交易编排号的生成流程,针对子交易序号中系统号和交易实例序号统一使用相应的占位符来表示,比如系统A使用字母“A”来表示其系统号和交易实例序号,系统B使用字母“B”表示其系统号和交易实例序号,以此类推。The above-mentioned target sub-transaction sequence number generation process is as follows: Take the transaction link shown in Figure 7 as an example, this link focuses on the generation process of the latest transaction sequence number, and uses the corresponding system number and transaction instance sequence number in the sub-transaction sequence number uniformly. For example, system A uses the letter "A" to represent its system number and transaction instance serial number, system B uses the letter "B" to represent its system number and transaction instance serial number, and so on.

(1)系统A作为交易发起方生成此笔交易第一个子交易序号,该子交易序号为“A1000000000000000000”。系统A作为交易发起方,其交易层级号为1,因此其对应的最新交易编排号中第一位为1,后19位都为0;(1) System A, as the transaction initiator, generates the first sub-transaction serial number of this transaction, and the sub-transaction serial number is "A1000000000000000000". System A is the transaction initiator, and its transaction level number is 1, so the first digit in the corresponding latest transaction number is 1, and the last 19 digits are 0;

(2)系统A首先调用系统B,然后调用系统C,再调用系统D。(2) System A first calls system B, then calls system C, and then calls system D.

此时需要生成三个新的子交易序号来表示这三个调用分支,三个子交易序号中的系统号和交易实例序号都由系统A来生成,因此子交易序号的前缀都是A。第一次,系统A调用系统B,属于系统A首次调用外系统,因此需要进行升层的逻辑,以第一个子交易序号“A1000000000000000000”为基准,按照上述升层的逻辑,得到的子交易序号为“A1100000000000000000”;第二次,系统A调用系统C,非系统A首次调用外系统,因此需要进行升次的逻辑,以上一个子交易序号“A1100000000000000000”为基准,按照升次的逻辑,得到的子交易序号为“A1200000000000000000”;第三次,系统A调用D,非系统A首次调用外系统,因此需要进行升次的逻辑,以上一个子交易序号“A1200000000000000000”为基准,按照升次的逻辑,得到的子交易序号为“A1300000000000000000”。At this time, three new sub-transaction sequence numbers need to be generated to represent the three call branches. The system number and transaction instance sequence number in the three sub-transaction sequence numbers are generated by system A, so the prefixes of the sub-transaction sequence numbers are all A. For the first time, system A calls system B, which is the first time that system A calls an external system. Therefore, the logic of upgrading is required. Based on the first sub-transaction serial number "A1000000000000000000", according to the above-mentioned upgrading logic, the obtained sub-transaction The serial number is "A110000000000000000"; the second time, system A calls system C, and non-system A calls the external system for the first time, so the logic of ascending order needs to be performed. The sub-transaction serial number is "A1200000000000000000"; the third time, system A calls D, and non-system A calls the external system for the first time, so the logic of ascending order needs to be performed. , the obtained sub-transaction serial number is "A1300000000000000000".

(3)系统B调用系统E,系统B调用系统F。此时需要生成两个新的子交易序号来表示这两个调用子分支,两个子交易序号中的系统号和交易实例序号都是由系统B来生成。第一次,系统B调用系统E,属于系统B首次调用外系统,因此需要进行升层的逻辑,以前一个子交易序号“A1100000000000000000”为基准,按照升层的逻辑,生成的子交易序号为“B1110000000000000000”;第二次,系统B调用系统F,非系统B首次调用外系统,因此需要进行升次的逻辑,以前一个子交易序号“B1110000000000000000”为基准,按照升次的逻辑,得到的子交易序号为“B1120000000000000000”。(3) System B calls system E, and system B calls system F. In this case, two new sub-transaction sequence numbers need to be generated to represent the two calling sub-branches. The system number and transaction instance sequence number in the two sub-transaction sequence numbers are both generated by system B. For the first time, system B calls system E, which is the first time that system B calls an external system. Therefore, the logic of upgrading is required. The previous sub-transaction serial number "A1100000000000000000" is the benchmark. According to the upgrading logic, the generated sub-transaction serial number is " B1110000000000000000"; the second time, system B calls system F, and non-system B calls the external system for the first time, so the logic of ascending order needs to be performed. The serial number is "B1120000000000000000".

(4)系统D调用系统G。此时需要生成一个新的子交易序号来表示这个调用子分支,该子交易序号的系统号和交易实例序号是由系统D来生成。系统D调用系统G,属于系统D首次调用外系统,因此需要进行升层的逻辑,以上一个子交易序号“A1300000000000000000”为基准,按照升层的逻辑,得到的子交易序号为“D1310000000000000000”。至此,此条交易链路的最新交易编排号生成流程已完成。(4) System D calls system G. At this time, a new sub-transaction sequence number needs to be generated to represent the calling sub-branch. The system number and transaction instance sequence number of the sub-transaction sequence number are generated by system D. System D calls system G, which is the first time that system D calls an external system. Therefore, the logic of upgrading is required. Based on the previous sub-transaction serial number "A1300000000000000000", according to the upgrading logic, the obtained sub-transaction serial number is "D1310000000000000000". So far, the latest transaction arrangement number generation process for this transaction link has been completed.

以上述生成的目标子交易序号“D1310000000000000000”为例,首先可以了解到系统调用方为系统D;在后20位的最新交易编排号中,一共有3个非0字符,则表明当前系统在交易链路中的交易层级号为3;找到最新交易编排号从左往右第一个出现字符0的位置,记作pos,pos减一的位置其对应的字符为“1”,表示当前系统为系统D调用的第一个系统。Taking the target sub-transaction serial number "D1310000000000000000" generated above as an example, you can first know that the system caller is system D; in the last 20 digits of the latest transaction number, there are a total of 3 non-zero characters, indicating that the current system is in the transaction The transaction level number in the link is 3; find the position where the character 0 appears first from left to right in the latest transaction arrangement number, and record it as pos. The first system called by system D.

为了更加快速地定位发生异常的系统,本申请的另一种实施例中,上述第五获取子单元包括判断模块、第一调整模块和第二调整模块,其中,上述判断模块用于判断上述当前调用发起方系统在调用上述当前被调用系统时,上述当前调用发起方系统是否为首次调用外系统;上述第一调整模块用于在上述当前调用发起方系统为首次调用上述外系统的情况下,对上述基准序号进行升层处理以使上述基准序号中第一位为0的字符转换为1;上述第二调整模块用于在上述当前调用发起方系统为非首次调用上述外系统的情况下,对上述基准序号进行升次处理以调整上述基准序号中的层级号加1。本实施例中,根据上述调用发起方系统是否为首次调用外系统进行升层逻辑或者升次逻辑,这样根据基准序号中的第一位和层级号就可以得到当前系统的调用情况。In order to locate the abnormal system more quickly, in another embodiment of the present application, the fifth acquisition subunit includes a judgment module, a first adjustment module, and a second adjustment module, wherein the judgment module is used to judge the current When the calling initiator system calls the above-mentioned currently called system, whether the above-mentioned current calling initiator system is the first time to call the external system; the above-mentioned first adjustment module is used to call the above-mentioned external system for the first time when the above-mentioned current calling initiator system is the first time to call the above-mentioned external system, The above-mentioned reference serial number is upgraded to make the character whose first digit is 0 in the above-mentioned reference serial number is converted into 1; the above-mentioned second adjustment module is used to call the above-mentioned external system when the above-mentioned current calling initiator system is not the first time. An ascending process is performed on the above-mentioned reference serial number to adjust the level number in the above-mentioned reference serial number plus 1. In this embodiment, according to whether the above-mentioned calling initiator system is the first call to the external system to perform the upgrade logic or the upgrade logic, the calling status of the current system can be obtained according to the first digit in the reference sequence number and the level number.

本申请的一种具体的实施例中,上述升层逻辑如图8所示,需要在最新交易编排号中从左到右找到第一个出现字符0的位置,如果该位置存在,则将字符0修改为1即完成最新交易编排号的升层逻辑,如果该位置不存在则表示交易层级号已经达到最大,无法继续升层。In a specific embodiment of the present application, the above-mentioned upgrade logic is shown in FIG. 8 . It is necessary to find the first position where the character 0 appears in the latest transaction number from left to right. If the position exists, the character If 0 is changed to 1, the upgrade logic of the latest transaction arrangement number is completed. If this position does not exist, it means that the transaction level number has reached the maximum, and the upgrade cannot be continued.

本申请的另一种具体的实施例中,上述升次逻辑如图9所示,首先在最新交易编排号从左往右找到第一个出现字符0的位置,记作pos。如果pos存在,则获取pos减1位置的字符,然后判断该字符是否为Z计数,进制运算,如果为Z则表示同层级交易实例数已达到最大,如果不为Z,则将该字符进行自增。字符自增需要注意的是,当字符为9时,自增后的结果为A。如果pos不存在,则获取最新交易编排号中最后一位字符,然后进行判断该字符是否为Z,后面的步骤与前面步骤一致。In another specific embodiment of the present application, the above-mentioned ascending logic is shown in FIG. 9 . First, the position where the character 0 appears first is found in the latest transaction arrangement number from left to right, which is denoted as pos. If pos exists, obtain the character at the position of pos minus 1, and then judge whether the character is counted by Z, and the base operation is performed. If it is Z, it means that the number of transaction instances at the same level has reached the maximum. auto increment. It should be noted that when the character is auto-incremented, when the character is 9, the result of the auto-increment is A. If pos does not exist, obtain the last character in the latest transaction arrangement number, and then judge whether the character is Z, and the following steps are the same as the previous steps.

上述定位异常交易的装置包括处理器和存储器,上述获取单元和定位单元等均作为程序单元存储在存储器中,由处理器执行存储在存储器中的上述程序单元来实现相应的功能。The above apparatus for locating abnormal transactions includes a processor and a memory. The above acquiring unit and locating unit are stored in the memory as program units, and the processor executes the above program units stored in the memory to realize corresponding functions.

处理器中包含内核,由内核去存储器中调取相应的程序单元。内核可以设置一个或以上,通过调整内核参数来解决相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的问题。The processor includes a kernel, and the kernel calls the corresponding program unit from the memory. The kernel can be set with one or more than one, and by adjusting the kernel parameters, the problem of the transaction serial number in the related art can be solved that it is difficult to locate the abnormal system when the transaction occurs abnormally.

存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM),存储器包括至少一个存储芯片。Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory, such as read only memory (ROM) or flash memory (flash RAM), the memory including at least one memory chip.

本发明实施例提供了一种非易失性存储介质,其上存储有程序,该程序被处理器执行时实现上述定位异常交易的方法。An embodiment of the present invention provides a non-volatile storage medium on which a program is stored, and when the program is executed by a processor, the above method for locating an abnormal transaction is implemented.

本发明实施例提供了一种处理器,上述处理器用于运行程序,其中,上述程序运行时执行上述定位异常交易的方法。An embodiment of the present invention provides a processor for running a program, wherein the method for locating an abnormal transaction is executed when the program is running.

本发明实施例提供了一种设备,设备包括处理器、存储器及存储在存储器上并可在处理器上运行的程序,处理器执行程序时实现以下步骤:An embodiment of the present invention provides a device. The device includes a processor, a memory, and a program stored in the memory and running on the processor. The processor implements the following steps when executing the program:

步骤S101,在检测到多个交易中存在异常交易的情况下,获取上述异常交易对应的目标流水号;Step S101, in the case of detecting that an abnormal transaction exists in the plurality of transactions, obtain the target serial number corresponding to the abnormal transaction;

步骤S102,依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易的信息以及上述异常交易在交易链路中发生异常时对应的调用系统,上述调用系统包括交易的调用发起方系统。。Step S102, locate the abnormal transaction according to the target serial number to determine the information of the abnormal transaction and the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, and the calling system includes the calling initiator system of the transaction. .

本文中的设备可以是服务器、PC、PAD、手机等。The devices in this article can be servers, PCs, PADs, mobile phones, and so on.

本发明还提供了一种计算机程序产品,当在数据处理设备上执行时,适于执行初始化有如下方法步骤的程序:The present invention also provides a computer program product that, when executed on a data processing device, is adapted to execute a program initialized with the following method steps:

步骤S101,在检测到多个交易中存在异常交易的情况下,获取上述异常交易对应的目标流水号;Step S101, in the case of detecting that an abnormal transaction exists in the plurality of transactions, obtain the target serial number corresponding to the abnormal transaction;

步骤S102,依据上述目标流水号对上述异常交易进行定位,以确定上述异常交易的信息以及上述异常交易在交易链路中发生异常时对应的调用系统,上述调用系统包括交易的调用发起方系统。。Step S102, locate the abnormal transaction according to the target serial number to determine the information of the abnormal transaction and the corresponding calling system when the abnormal transaction occurs abnormally in the transaction link, and the calling system includes the calling initiator system of the transaction. .

本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用非易失性存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may employ a computer program product embodied on one or more computer-usable non-volatile storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein form.

本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each process and/or block in the flowchart illustrations and/or block diagrams, and combinations of processes and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to the processor of a general purpose computer, special purpose computer, embedded processor or other programmable data processing device to produce a machine such that the instructions executed by the processor of the computer or other programmable data processing device produce Means for implementing the functions specified in a flow or flow of a flowchart and/or a block or blocks of a block diagram.

这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory result in an article of manufacture comprising instruction means, the instructions The apparatus implements the functions specified in the flow or flow of the flowcharts and/or the block or blocks of the block diagrams.

这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded on a computer or other programmable data processing device to cause a series of operational steps to be performed on the computer or other programmable device to produce a computer-implemented process such that The instructions provide steps for implementing the functions specified in the flow or blocks of the flowcharts and/or the block or blocks of the block diagrams.

在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。In a typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.

存储器可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。存储器是计算机可读介质的示例。Memory may include non-persistent memory in computer readable media, random access memory (RAM) and/or non-volatile memory in the form of, for example, read only memory (ROM) or flash memory (flash RAM). Memory is an example of a computer-readable medium.

计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的非易失性存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology. Information may be computer readable instructions, data structures, modules of programs, or other data. Examples of non-volatile storage media for computers include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM) , read only memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile disc (DVD) or Other optical storage, magnetic tape cartridges, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission medium, may be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.

还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device comprising a series of elements includes not only those elements, but also Other elements not expressly listed, or which are inherent to such a process, method, article of manufacture, or apparatus are also included. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article of manufacture or apparatus that includes the element.

本领域技术人员应明白,本发明的实施例可提供为方法、系统或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用非易失性存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may employ a computer program product embodied on one or more computer-usable non-volatile storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein form.

从以上的描述中,可以看出,本申请上述的实施例实现了如下技术效果:From the above description, it can be seen that the above-mentioned embodiments of the present application achieve the following technical effects:

1)、本申请的定位异常交易的方法中,首先,在检测到多个交易中存在异常交易的情况下,获取异常交易对应的目标流水号,然后,根据目标流水号对异常交易进行定位,确定异常交易的信息以及发生异常时对应的调用系统,调用系统包括交易调用的发起方系统以及被调用系统。该方法中,获取到异常交易的目标流水号具有唯一性,可以唯一定位一笔交易,并且可以描述交易链路的调用的各个系统,所以根据该目标流水号可以定位到异常交易的信息以及发生异常时的调用系统,从而实现根据目标流水号就可以定位到发生异常的系统,进而解决了相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的技术问题。1), in the method for locating abnormal transactions of the present application, first, in the case of detecting that there are abnormal transactions in multiple transactions, obtain the target serial number corresponding to the abnormal transaction, and then locate the abnormal transaction according to the target serial number, Determine the information of the abnormal transaction and the corresponding calling system when the exception occurs. The calling system includes the initiator system of the transaction call and the called system. In this method, the target serial number of the abnormal transaction is unique, which can uniquely locate a transaction and describe the various systems of the transaction link. Therefore, according to the target serial number, the information and occurrence of the abnormal transaction can be located. The system is called when abnormal, so that the abnormal system can be located according to the target serial number, thereby solving the technical problem that the transaction serial number in the related technology is difficult to locate the abnormal system when the transaction is abnormal. .

2)、本申请的定位异常交易的装置,包括获取单元和定位单元,上述获取单元用于在检测到多个交易中存在异常交易的情况下,获取异常交易对应的目标流水号,上述定位单元用于根据目标流水号对异常交易进行定位,确定异常交易的信息以及发生异常时对应的调用系统,调用系统包括交易调用的发起方系统以及被调用系统。该装置中,获取到异常交易的目标流水号具有唯一性,可以唯一定位一笔交易,并且可以描述交易链路的调用的各个系统,所以根据该目标流水号可以定位到异常交易的信息以及发生异常时的调用系统,从而实现根据目标流水号就可以定位到发生异常的系统,进而解决了相关技术中的交易流水号在交易发生异常的情况下,很难定位到发生异常的系统的技术问题。2), the device for locating abnormal transactions of the present application includes an acquisition unit and a locating unit, and the above-mentioned acquisition unit is used to acquire the target serial number corresponding to the abnormal transaction when detecting that there are abnormal transactions in multiple transactions, and the above-mentioned locating unit It is used to locate the abnormal transaction according to the target serial number, determine the information of the abnormal transaction and the corresponding calling system when the exception occurs. The calling system includes the initiator system and the called system of the transaction call. In the device, the target serial number of the abnormal transaction is unique, which can uniquely locate a transaction and describe the various systems of the transaction link. Therefore, according to the target serial number, the information and occurrence of abnormal transactions can be located. The system is called when an exception occurs, so that the abnormal system can be located according to the target serial number, thereby solving the technical problem that the transaction serial number in the related technology is difficult to locate the abnormal system when the transaction occurs. .

以上仅为本发明的实施例而已,并不用于限制本发明。对于本领域技术人员来说,本发明可以有各种更改和变化。凡在本发明的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本发明的权利要求范围之内。The above are only embodiments of the present invention, and are not intended to limit the present invention. Various modifications and variations of the present invention are possible for those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included within the scope of the claims of the present invention.

Claims (11)

1. A method for locating anomalous transactions comprising:
under the condition that abnormal transactions exist in a plurality of transactions, acquiring a target serial number corresponding to the abnormal transactions;
and positioning the abnormal transaction according to the target serial number to determine the information of the abnormal transaction and a corresponding calling system when the abnormal transaction is abnormal in a transaction link, wherein the calling system comprises a transaction calling initiator system.
2. The method according to claim 1, wherein in a case that it is detected that there is an abnormal transaction in a plurality of transactions, acquiring a target serial number corresponding to the abnormal transaction, including:
under the condition that abnormal transactions exist in a plurality of transactions, acquiring a current message generated in the transaction process of the abnormal transactions;
and acquiring the target serial number contained in the message, wherein the target serial number comprises a global service tracking number corresponding to the abnormal transaction and a sub-transaction serial number corresponding to the abnormal transaction, and the global service tracking number runs through the whole transaction process corresponding to the abnormal transaction.
3. The method of claim 2, wherein locating the abnormal transaction according to the target serial number to determine information of the abnormal transaction comprises:
analyzing the global service tracking number and obtaining a first analysis result, wherein the first analysis result at least comprises a timestamp, a first system number, a first transaction instance serial number and a serial number, the timestamp is the timestamp corresponding to the abnormal transaction when the transaction is initiated, the first system number is an identification code corresponding to an original initiator system of the abnormal transaction, the first transaction instance serial number is the identification code of a machine where the transaction instance corresponding to the abnormal transaction is located, and the serial number is a circularly-increased serial number generated by the original initiator system when the abnormal transaction is initiated;
and determining the information of the abnormal transaction according to the first analysis result.
4. The method of claim 3, wherein prior to locating the anomalous transaction based on the target serial number to determine information about the anomalous transaction, the method further comprises:
acquiring an MAC address corresponding to a machine where an original transaction instance corresponding to the abnormal transaction is located;
calculating a hash value corresponding to the MAC address, and performing a modulus operation on the hash value to obtain a modulus result;
and carrying out zero filling operation on the modulus result to obtain the first transaction instance serial number.
5. The method of claim 2, wherein locating the abnormal transaction according to the target serial number to determine a calling system corresponding to the abnormal transaction when an abnormality occurs in a transaction link comprises:
acquiring a target sub-transaction serial number contained in the target serial number, wherein the target sub-transaction serial number is a current sub-transaction serial number generated in the transaction process of the abnormal transaction;
analyzing the target sub-transaction serial number and obtaining a second analysis result, wherein the second analysis result at least comprises a second system number, a second transaction instance serial number and a latest transaction arrangement number, the second system number is an identification code corresponding to the current calling initiator system corresponding to the abnormal transaction, the second transaction instance serial number is an identification code of a machine where the transaction instance corresponding to the current calling initiator system is located, and the latest transaction arrangement number represents a call link to the system in the current calling process from two dimensions, namely a horizontal dimension and a longitudinal dimension;
and determining a corresponding calling system when the abnormal transaction is abnormal in the transaction link according to the second analysis result.
6. The method of claim 5, wherein before locating the abnormal transaction according to the target serial number to determine a corresponding calling system when the abnormal transaction is abnormal in a transaction link, the method comprises:
acquiring current system call information corresponding to the abnormal transaction in the transaction link, wherein the current system call information at least comprises information of the current call initiator system corresponding to the abnormal transaction and information of the current called system;
and generating the target sub-transaction serial number according to the current system calling information.
7. The method of claim 6, wherein generating the target sub-transaction sequence number according to the current system call information comprises:
acquiring an identification code corresponding to the current calling initiator system, and determining the identification code as a prefix of the target sub-transaction serial number;
determining the level of the transaction link where the current system is located, and determining a number corresponding to the level of the transaction link;
arranging the prefixes and the numbers in sequence, and determining characters except the prefixes and the hierarchy numbers to be 0 so as to generate a reference serial number corresponding to the target sub-transaction serial number;
acquiring the calling condition of the current calling initiator system for calling the current called system, and adjusting the reference serial number according to the calling condition;
and determining the adjusted reference serial number as the target sub-transaction serial number.
8. The method of claim 7, wherein obtaining a call condition of the current call initiator system calling the current called system, and adjusting the reference sequence number according to the call condition comprises:
judging whether the current calling initiator system is an external system for the first calling when the current called system is called by the current calling initiator system;
under the condition that the current calling initiator system calls the external system for the first time, performing layer-ascending processing on the reference serial number to convert a character with a first bit of 0 in the reference serial number into 1;
and under the condition that the current calling initiator system does not call the external system for the first time, performing ascending processing on the reference sequence number to adjust the level number in the reference sequence number to be added with 1.
9. An apparatus for locating anomalous transactions, comprising:
the system comprises an acquisition unit, a processing unit and a processing unit, wherein the acquisition unit is used for acquiring a target serial number corresponding to an abnormal transaction when the abnormal transaction is detected in a plurality of transactions;
and the positioning unit is used for positioning the abnormal transaction according to the target serial number so as to determine the information of the abnormal transaction and a corresponding calling system when the abnormal transaction is abnormal in a transaction link, and the calling system comprises a transaction calling initiator system.
10. A non-volatile storage medium, comprising a stored program, wherein the program, when executed, controls a device in which the non-volatile storage medium is located to perform a method for locating an exception transaction according to any one of claims 1 to 8.
11. A processor configured to run a program, wherein the program when running performs the method for locating anomalous transactions according to any one of the claims 1 to 8.
CN202210234282.6A 2022-03-09 2022-03-09 Method, device, non-volatile storage medium and processor for locating abnormal transactions Active CN114691732B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210234282.6A CN114691732B (en) 2022-03-09 2022-03-09 Method, device, non-volatile storage medium and processor for locating abnormal transactions

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210234282.6A CN114691732B (en) 2022-03-09 2022-03-09 Method, device, non-volatile storage medium and processor for locating abnormal transactions

Publications (2)

Publication Number Publication Date
CN114691732A true CN114691732A (en) 2022-07-01
CN114691732B CN114691732B (en) 2025-02-11

Family

ID=82138840

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210234282.6A Active CN114691732B (en) 2022-03-09 2022-03-09 Method, device, non-volatile storage medium and processor for locating abnormal transactions

Country Status (1)

Country Link
CN (1) CN114691732B (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115904872A (en) * 2022-12-01 2023-04-04 深圳市雁联计算系统有限公司 Transaction link monitoring method, system and storage medium
CN115936608A (en) * 2022-12-01 2023-04-07 深圳市雁联计算系统有限公司 Distributed serial number generation method and device based on transaction link and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109767329A (en) * 2018-12-29 2019-05-17 北京金山安全软件有限公司 Abnormal transaction detection method and device, electronic equipment and storage medium
CN110223173A (en) * 2019-05-20 2019-09-10 深圳壹账通智能科技有限公司 Trade link abnormality eliminating method and relevant device
CN112446786A (en) * 2020-11-13 2021-03-05 中信银行股份有限公司 Abnormal transaction processing method and device, electronic equipment and readable storage medium
CN113128986A (en) * 2021-04-23 2021-07-16 中国工商银行股份有限公司 Error reporting processing method and device for long-link transaction
CN114092246A (en) * 2021-11-24 2022-02-25 中国银行股份有限公司 Problem locating method and device for financial transaction link

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109767329A (en) * 2018-12-29 2019-05-17 北京金山安全软件有限公司 Abnormal transaction detection method and device, electronic equipment and storage medium
CN110223173A (en) * 2019-05-20 2019-09-10 深圳壹账通智能科技有限公司 Trade link abnormality eliminating method and relevant device
WO2020233066A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 Abnormity processing method based on data computation link, and related device
CN112446786A (en) * 2020-11-13 2021-03-05 中信银行股份有限公司 Abnormal transaction processing method and device, electronic equipment and readable storage medium
CN113128986A (en) * 2021-04-23 2021-07-16 中国工商银行股份有限公司 Error reporting processing method and device for long-link transaction
CN114092246A (en) * 2021-11-24 2022-02-25 中国银行股份有限公司 Problem locating method and device for financial transaction link

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
喻乐平;龚伟;刘武贵;: "基于ESB发布订阅模式下的业务数据异常处理解决方案", 电子世界, no. 09, 8 May 2019 (2019-05-08) *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115904872A (en) * 2022-12-01 2023-04-04 深圳市雁联计算系统有限公司 Transaction link monitoring method, system and storage medium
CN115936608A (en) * 2022-12-01 2023-04-07 深圳市雁联计算系统有限公司 Distributed serial number generation method and device based on transaction link and storage medium
CN115936608B (en) * 2022-12-01 2024-03-05 深圳市雁联计算系统有限公司 Distributed serial number generation method and device based on transaction link and storage medium
CN115904872B (en) * 2022-12-01 2024-03-12 深圳市雁联计算系统有限公司 Transaction link monitoring method, system and storage medium

Also Published As

Publication number Publication date
CN114691732B (en) 2025-02-11

Similar Documents

Publication Publication Date Title
CN110188096B (en) Index creating method, device and equipment for data record
TWI662426B (en) Method and device for distributed stream data processing
CN109902071B (en) Service log storage method, system, device and equipment
CN110162526B (en) Method, device and equipment for inquiring data records in block chain type account book
CN108932257B (en) Multi-dimensional data query method and device
CN106897335B (en) Service data storage method, record identifier generation method and device
CN114691732A (en) Method, device, non-volatile storage medium and processor for locating abnormal transactions
CN104346365A (en) Device and method for determining specific service associated logs
EP3961461A1 (en) Method and apparatus for obtaining number for transaction-accessed variable in blockchain in parallel
CN108399175A (en) A kind of storage of data, querying method and its device
CN111708771A (en) Data duplicate checking method, device, equipment and computer storage medium
JP2019504426A (en) Method and apparatus for generating random character string
CN107391532B (en) Data filtering method and device
CN114493551B (en) Contract generation method and device, electronic equipment and storage medium
CN110347678A (en) A kind of storage method of finance data, system, device and equipment
CN112162951A (en) Information retrieval method, server and storage medium
CN111327466A (en) Alarm analysis method, system, equipment and medium
CN110532248B (en) CMDB-based server application information acquisition and adjustment method
CN111738815A (en) Financial information conversion and accounting method and device, computer equipment and storage medium
CN109035040B (en) Policy generation method and device and electronic equipment
CN110689418A (en) Bill generation method and device
CN117149702A (en) Service data processing method and related equipment
CN111414427B (en) A data processing method and device suitable for quasi-real-time service
CN110648219B (en) Method and device for standardizing input area of bank transaction system
CN115034207B (en) Method, system, device and storage medium for verifying identification data

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant