CN106933932B - Data processing method, device and application server - Google Patents
Data processing method, device and application server Download PDFInfo
- Publication number
- CN106933932B CN106933932B CN201511033240.2A CN201511033240A CN106933932B CN 106933932 B CN106933932 B CN 106933932B CN 201511033240 A CN201511033240 A CN 201511033240A CN 106933932 B CN106933932 B CN 106933932B
- Authority
- CN
- China
- Prior art keywords
- event
- domain
- user
- events
- domain event
- 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.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/23—Updating
- G06F16/2308—Concurrency control
- G06F16/2315—Optimistic concurrency control
- G06F16/2322—Optimistic concurrency control using timestamps
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION 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
- G06Q30/00—Commerce
- G06Q30/01—Customer relationship services
- G06Q30/015—Providing customer assistance, e.g. assisting a customer within a business location or via helpdesk
- G06Q30/016—After-sales
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Physics & Mathematics (AREA)
- Accounting & Taxation (AREA)
- General Engineering & Computer Science (AREA)
- Databases & Information Systems (AREA)
- Data Mining & Analysis (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Finance (AREA)
- Marketing (AREA)
- Strategic Management (AREA)
- General Business, Economics & Management (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
Abstract
本发明实施例提供一种数据处理方法、装置及应用服务器,涉及通信技术领域。该方法包括:接收数据处理请求,数据处理请求包括用户标识和电子凭证标识,以及操作类型;若操作类型为第一操作,则基于电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件;基于用户标识查询事件数据库,获取与用户标识对应的领域事件中,除第一领域事件之外的其他领域事件;将其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与用户标识对应的处理后的业务状态信息;根据用户标识对应的处理后的业务状态信息,对状态数据库中用户标识对应的业务状态信息进行更新。
Embodiments of the present invention provide a data processing method, an apparatus, and an application server, and relate to the technical field of communications. The method includes: receiving a data processing request, where the data processing request includes a user identification, an electronic credential identification, and an operation type; if the operation type is a first operation, marking the first domain event as a first domain event based on the electronic credential identification and the first corresponding relationship Rollback events; query the event database based on the user ID to obtain other domain events except the first domain event among the domain events corresponding to the user ID; reprocess the other domain events in the order of the occurrence time of the domain events to obtain the processed service status information corresponding to the user ID; and update the service status information corresponding to the user ID in the status database according to the processed service status information corresponding to the user ID.
Description
技术领域technical field
本发明涉及通信技术领域,尤其涉及一种数据处理方法、装置及应用服务器。The present invention relates to the field of communication technologies, and in particular, to a data processing method, device and application server.
背景技术Background technique
在通信运营过程中,由于客户的需要、操作员的误操作等,对于已经完成的业务订单经常出现需要业务回退的情况,比如,客户订购了一个短信呼业务,相应的业务订单已经处理完成,操作员提示客户可以使用短信呼业务,而客户发现短信呼业务实际上并没有开通,操作员由于操作失误帮客户订购的是彩铃包月套餐,因此,操作员需要查询出已经办理的业务订单,进行相应的业务回退,并重新为客户订购正确的短信呼业务。In the process of communication operation, due to the needs of customers and the misoperation of operators, it is often necessary to roll back the completed business orders. For example, the customer ordered a short message call service, and the corresponding business order has been processed. , the operator prompts the customer to use the SMS calling service, but the customer finds that the SMS calling service has not actually been activated. The operator ordered the monthly CRBT package for the customer due to an operation error. Carry out the corresponding service rollback, and re-order the correct SMS calling service for the customer.
目前,为了完成业务订单的回退,通常是设计相应的实体状态变更的日志表,该实体可以为订单、订购产品等,也即是,由客户关系管理(英文:Customer RelationshipManagement,简称:CRM)系统记录下哪一笔订单导致的实体状态发生变化,以及变化前后该实体状态的值分别是什么,从而将CRM系统中存放的实体状态“恢复”到对应的业务订单履行完工之前的状态,以完成业务订单的回退。At present, in order to complete the rollback of business orders, it is usually necessary to design a log table of corresponding entity status changes. The entity can be orders, ordered products, etc. The system records which order causes the entity state to change, and the value of the entity state before and after the change, so as to "restore" the entity state stored in the CRM system to the state before the corresponding business order is fulfilled, to Complete the rollback of business orders.
但是,对于实体状态变更需要维护相应的实体状态变更日志表,以及对实体状态变更日志进行相应的逻辑处理,从而增加了开发人员额外的负担,同时也会产生不满足条件的业务回退等问题。However, for the entity state change, it is necessary to maintain the corresponding entity state change log table and perform corresponding logical processing on the entity state change log, which increases the extra burden on the developer, and also causes problems such as business rollback that does not meet the conditions. .
发明内容SUMMARY OF THE INVENTION
本发明的实施例提供一种数据处理方法、装置及应用服务器,用于提高数据处理的速度和简化数据处理过程的问题。Embodiments of the present invention provide a data processing method, an apparatus and an application server, which are used for improving the speed of data processing and simplifying the problem of the data processing process.
为达到上述目的,本发明的实施例采用如下技术方案:To achieve the above object, the embodiments of the present invention adopt the following technical solutions:
第一方面,提供一种数据处理方法,应用于应用服务器中,所述应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,所述方法包括:In a first aspect, a data processing method is provided, applied in an application server, the application server at least includes a first event bus and a second event bus, wherein the first event bus is used to transmit domain events for the first operation of the business, The second event bus is used to transmit domain events for the second operation of the service, and the method includes:
接收数据处理请求,所述数据处理请求包括用户标识和电子凭证标识,以及操作类型,电子凭证用于表示用户与业务之间满足预设状态;Receive a data processing request, where the data processing request includes a user ID, an electronic voucher ID, and an operation type, and the electronic voucher is used to indicate that a preset state is satisfied between the user and the service;
若所述操作类型为第一操作,则基于所述电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,所述第一领域事件为与所述电子凭证标识对应的领域事件,所述第一对应关系包含电子凭证标识以及与所述电子凭证标识对应的领域事件;If the operation type is the first operation, the first domain event is marked as a fallback event based on the electronic certificate identifier and the first corresponding relationship, and the first domain event is the domain corresponding to the electronic certificate identifier an event, the first correspondence includes an electronic credential identifier and a domain event corresponding to the electronic credential identifier;
基于所述用户标识查询事件数据库,获取与所述用户标识对应的领域事件中,除所述第一领域事件之外的其他领域事件;其中,所述事件数据库包含用户标识、以及与用户标识对应的领域事件以及所述领域事件对应的发生时间;Query an event database based on the user ID, and obtain other domain events except the first domain event among the domain events corresponding to the user ID; The domain event and the corresponding occurrence time of the domain event;
将所述其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与所述用户标识对应的处理后的业务状态信息;Reprocessing the other domain events in sequence according to the occurrence time of the domain events to obtain the processed service status information corresponding to the user identifier;
根据所述用户标识对应的处理后的业务状态信息,对状态数据库中所述用户标识对应的业务状态信息进行更新,其中,所述状态数据库包含用户标识、以及与所述用户标识对应的业务状态信息。According to the processed service status information corresponding to the user ID, the service status information corresponding to the user ID in the status database is updated, wherein the status database includes the user ID and the service status corresponding to the user ID. information.
结合第一方面,在第一方面的第一种可能的实现方式中,所述将所述其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与所述用户标识对应的处理后的业务状态信息,包括:With reference to the first aspect, in a first possible implementation manner of the first aspect, the other domain events are reprocessed in sequence according to the occurrence time of the domain events to obtain the processing corresponding to the user ID Post business status information, including:
将所述其他领域事件按照领域事件的发生时间的先后顺序依次发送给第一事件总线;sending the other domain events to the first event bus in sequence according to the occurrence time of the domain events;
从所述第一事件总线上依次获取所述其他领域事件,并以同步侦听的模式进行处理,得到与所述用户标识对应的处理后的业务状态信息。The other domain events are sequentially acquired from the first event bus, and processed in a synchronous listening mode to obtain processed service status information corresponding to the user ID.
结合第一方面的第一种可能的实现方式,在第一方面的第二种可能的实现方式中,所述将所述其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与所述用户标识对应的处理后的业务状态信息,还包括:With reference to the first possible implementation manner of the first aspect, in the second possible implementation manner of the first aspect, the other domain events are sequentially reprocessed in the order of the occurrence time of the domain events, to obtain The processed service status information corresponding to the user identifier further includes:
若所述其他领域事件中存在第二领域事件与所述第一领域事件存在预设关联关系,则发送错误信息,所述错误信息用于指示所述第一操作发生错误。If there is a preset association relationship between the second domain event and the first domain event among the other domain events, error information is sent, where the error information is used to indicate that an error occurs in the first operation.
结合第一方面至第一方面的第二种可能的实现方式中的任一种可能的实现方式,在第一方面的第三种可能的实现方式中,所述基于所述用户标识查询事件数据库,获取与所述用户标识对应的领域事件中,除所述第一领域事件之外的其他领域事件,包括:With reference to any possible implementation manner of the first aspect to the second possible implementation manner of the first aspect, in a third possible implementation manner of the first aspect, the query event database based on the user identifier , to obtain other domain events except the first domain event in the domain events corresponding to the user ID, including:
从所述事件数据库中,获取当前时刻之前的预设时长内与所述用户标识对应的领域事件;From the event database, obtain a domain event corresponding to the user ID within a preset time period before the current moment;
若所述当前时刻之前的预设时长内与所述用户标识对应的领域事件包含所述第一领域事件,则将所述第一领域事件删除后获取除所述第一领域事件之外的其他领域事件;If the domain event corresponding to the user identifier within the preset time period before the current moment includes the first domain event, delete the first domain event and obtain other domain events other than the first domain event domain events;
若所述当前时刻之前的预设时长内与所述用户标识对应的领域事件不包含所述第一领域事件,则发送错误信息,所述错误信息用于指示所述第一操作发生错误。If the domain event corresponding to the user identifier does not include the first domain event within a preset time period before the current moment, an error message is sent, where the error message is used to indicate that an error occurs in the first operation.
第二方面,提供一种数据处理方法,应用于应用服务器中,所述应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,所述方法包括:In a second aspect, a data processing method is provided, which is applied to an application server, where the application server at least includes a first event bus and a second event bus, wherein the first event bus is used to transmit domain events for the first operation of the business, The second event bus is used to transmit domain events for the second operation of the service, and the method includes:
接收数据处理请求,所述数据处理请求包括用户标识和业务标识,以及操作类型;receiving a data processing request, where the data processing request includes a user ID, a service ID, and an operation type;
若所述操作类型为第二操作,则基于所述数据处理请求生成电子凭证,所述电子凭证用于表示用户与业务之间满足预设状态;If the operation type is the second operation, generating an electronic voucher based on the data processing request, where the electronic voucher is used to indicate that a preset state is satisfied between the user and the service;
基于所述电子凭证的标识,生成与所述电子凭证的标识对应的第一领域事件;generating a first domain event corresponding to the identification of the electronic credential based on the identification of the electronic credential;
根据所述第一领域事件更新事件数据库,其中,所述事件数据库包含用户标识、与用户标识对应的领域事件以及所述领域事件对应的发生时间;Update an event database according to the first domain event, wherein the event database includes a user ID, a domain event corresponding to the user ID, and an occurrence time corresponding to the domain event;
对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态;processing the first domain event to obtain a business state corresponding to the first domain event;
根据所述第一领域事件对应的业务状态对状态数据库中所述用户标识对应的业务状态信息进行更新,其中,所述状态数据库包含用户标识、以及与所述用户标识对应的业务状态信息。Update the business status information corresponding to the user ID in the status database according to the business status corresponding to the first domain event, wherein the status database includes the user ID and business status information corresponding to the user ID.
结合第二方面,在第二方面的第一种可能的实现方式中,所述对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态,包括:With reference to the second aspect, in a first possible implementation manner of the second aspect, the processing of the first domain event to obtain a business state corresponding to the first domain event includes:
根据预设的第二对应关系,若确定所述预设状态包含相互关联的第一预设状态以及第二预设状态,且所述第二预设状态为所述第一预设状态的必要条件,则根据所述预设的第二对应关系确定与所述第二预设状态对应的第二领域事件;其中,所述第二对应关系包含电子凭证标识以及与所述电子凭证标识对应的领域事件,以及分别与每个领域事件对应的预设状态;According to the preset second correspondence, if it is determined that the preset state includes a first preset state and a second preset state that are related to each other, and the second preset state is necessary for the first preset state condition, the second domain event corresponding to the second preset state is determined according to the preset second correspondence relationship; wherein the second correspondence relationship includes an electronic certificate identifier and an electronic certificate identifier corresponding to the electronic certificate identifier. Domain events, and preset states corresponding to each domain event;
若确定所述事件数据库不存在与所述第二预设状态对应的第二领域事件,则所述对所述第一领域事件进行处理后,触发生成所述第二领域事件。If it is determined that there is no second domain event corresponding to the second preset state in the event database, after the first domain event is processed, the generation of the second domain event is triggered.
若确定所述事件数据库存在与所述第二预设状态对应的第二领域事件,则所述对所述第一领域事件进行处理。If it is determined that there is a second domain event corresponding to the second preset state in the event database, the first domain event is processed.
结合第二方面的第一种可能的实现方式,在第二方面的第二种可能的实现方式中,所述方法还包括:With reference to the first possible implementation manner of the second aspect, in the second possible implementation manner of the second aspect, the method further includes:
根据所述第二领域事件更新事件数据库;Update the event database according to the second domain event;
对所述第二领域事件进行处理,获得与所述第二领域事件对应的业务状态;processing the second domain event to obtain a business state corresponding to the second domain event;
根据所述第二领域事件对应的业务状态对状态数据库中所述用户标识对应的业务状态信息进行更新。The business state information corresponding to the user identifier in the state database is updated according to the business state corresponding to the second domain event.
结合第二方面或第二方面的第一种可能的实现方式,在第二方面的第三种可能的实现方式中,所述根据所述第一领域事件更新事件数据库之前,还包括:With reference to the second aspect or the first possible implementation manner of the second aspect, in a third possible implementation manner of the second aspect, before updating the event database according to the first domain event, the method further includes:
将所述第一领域事件发送给第二事件总线;sending the first domain event to the second event bus;
相应的,对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态,包括:Correspondingly, the first domain event is processed to obtain a business state corresponding to the first domain event, including:
从所述第二事件总线上获取所述第一事件总线,以及对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态。The first event bus is obtained from the second event bus, and the first domain event is processed to obtain a business state corresponding to the first domain event.
第三方面,提供一种数据处理装置,应用于应用服务器中,所述应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,所述装置包括:In a third aspect, a data processing device is provided, which is applied in an application server, the application server includes at least a first event bus and a second event bus, wherein the first event bus is used to transmit domain events for the first operation of the business, The second event bus is used to transmit domain events for the second operation of the service, and the device includes:
接收单元,用于接收数据处理请求,所述数据处理请求包括用户标识和电子凭证标识,以及操作类型,电子凭证用于表示用户与业务之间满足预设状态;a receiving unit, configured to receive a data processing request, where the data processing request includes a user ID, an electronic voucher ID, and an operation type, and the electronic voucher is used to indicate that a preset state is satisfied between the user and the service;
标记单元,用于若所述操作类型为第一操作,则基于所述电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,所述第一领域事件为与所述电子凭证标识对应的领域事件,所述第一对应关系包含电子凭证标识以及与所述电子凭证标识对应的领域事件;a marking unit, configured to mark the first domain event as a fallback event based on the electronic certificate identifier and the first corresponding relationship if the operation type is the first operation, and the first domain event is related to the electronic certificate a domain event corresponding to the credential identifier, and the first correspondence includes an electronic credential identifier and a domain event corresponding to the electronic credential identifier;
获取单元,用于基于所述用户标识查询事件数据库,获取与所述用户标识对应的领域事件中,除所述第一领域事件之外的其他领域事件;其中,所述事件数据库包含用户标识、以及与用户标识对应的领域事件以及所述领域事件对应的发生时间;an obtaining unit, configured to query an event database based on the user ID, and obtain other domain events except the first domain event among the domain events corresponding to the user ID; wherein, the event database includes the user ID, and the domain event corresponding to the user ID and the occurrence time corresponding to the domain event;
处理单元,用于将所述其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与所述用户标识对应的处理后的业务状态信息;a processing unit, configured to reprocess the other domain events in sequence according to the occurrence time of the domain events to obtain processed service status information corresponding to the user identifier;
更新单元,用于根据所述用户标识对应的处理后的业务状态信息,对状态数据库中所述用户标识对应的业务状态信息进行更新,其中,所述状态数据库包含用户标识、以及与所述用户标识对应的业务状态信息。an update unit, configured to update the business status information corresponding to the user identification in the status database according to the processed business status information corresponding to the user identification, wherein the status database includes a user identification and a Identifies the corresponding service status information.
结合第三方面,在第三方面的第一种可能的实现方式中,所述处理单元具体用于:With reference to the third aspect, in a first possible implementation manner of the third aspect, the processing unit is specifically configured to:
将所述其他领域事件按照领域事件的发生时间的先后顺序依次发送给第一事件总线;sending the other domain events to the first event bus in sequence according to the occurrence time of the domain events;
从所述第一事件总线上依次获取所述其他领域事件,并以同步侦听的模式进行处理,得到与所述用户标识对应的处理后的业务状态信息。The other domain events are sequentially acquired from the first event bus, and processed in a synchronous listening mode to obtain processed service status information corresponding to the user ID.
结合第三方面的第一种可能的实现方式,在第三方面的第二种可能的实现方式中,所述处理单元还具体用于:With reference to the first possible implementation manner of the third aspect, in the second possible implementation manner of the third aspect, the processing unit is further specifically configured to:
若所述其他领域事件中存在第二领域事件与所述第一领域事件存在预设关联关系,则发送错误信息,所述错误信息用于指示所述第一操作发生错误。If there is a preset association relationship between the second domain event and the first domain event among the other domain events, error information is sent, where the error information is used to indicate that an error occurs in the first operation.
结合第三方面至第三方面的第二种可能的实现方式中的任一种可能的实现方式,在第三方面的第三种可能的实现方式中,所述获取单元具体用于:With reference to any one of the possible implementation manners of the third aspect to the second possible implementation manner of the third aspect, in the third possible implementation manner of the third aspect, the obtaining unit is specifically configured to:
从所述事件数据库中,获取当前时刻之前的预设时长内与所述用户标识对应的领域事件;From the event database, obtain a domain event corresponding to the user ID within a preset time period before the current moment;
若所述当前时刻之前的预设时长内与所述用户标识对应的领域事件包含所述第一领域事件,则将所述第一领域事件删除后获取除所述第一领域事件之外的其他领域事件;If the domain event corresponding to the user identifier within the preset time period before the current moment includes the first domain event, delete the first domain event and obtain other domain events other than the first domain event domain events;
若所述当前时刻之前的预设时长内与所述用户标识对应的领域事件不包含所述第一领域事件,则发送错误信息,所述错误信息用于指示所述第一操作发生错误。If the domain event corresponding to the user identifier does not include the first domain event within a preset time period before the current moment, an error message is sent, where the error message is used to indicate that an error occurs in the first operation.
第四方面,提供一种数据处理装置,应用于应用服务器中,所述应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,所述装置包括:In a fourth aspect, a data processing device is provided, which is applied to an application server, the application server includes at least a first event bus and a second event bus, wherein the first event bus is used to transmit domain events for the first operation of the business, The second event bus is used to transmit domain events for the second operation of the service, and the device includes:
接收单元,用于接收数据处理请求,所述数据处理请求包括用户标识和业务标识,以及操作类型;a receiving unit, configured to receive a data processing request, where the data processing request includes a user ID, a service ID, and an operation type;
第一生成单元,用于若所述操作类型为第二操作,则基于所述数据处理请求生成电子凭证,所述电子凭证用于表示用户与业务之间满足预设状态;a first generating unit, configured to generate an electronic voucher based on the data processing request if the operation type is the second operation, where the electronic voucher is used to indicate that a preset state is satisfied between the user and the service;
第二生成单元,用于基于所述电子凭证的标识,生成与所述电子凭证的标识对应的第一领域事件;a second generating unit, configured to generate a first domain event corresponding to the identifier of the electronic certificate based on the identifier of the electronic certificate;
第一更新单元,用于根据所述第一领域事件更新事件数据库,其中,所述事件数据库包含用户标识、与用户标识对应的领域事件以及所述领域事件对应的发生时间;a first updating unit, configured to update an event database according to the first domain event, wherein the event database includes a user ID, a domain event corresponding to the user ID, and an occurrence time corresponding to the domain event;
第一处理单元,用于对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态;a first processing unit, configured to process the first domain event to obtain a business state corresponding to the first domain event;
第二更新单元,用于根据所述第一领域事件对应的业务状态对状态数据库中所述用户标识对应的业务状态信息进行更新,其中,所述状态数据库包含用户标识、以及与所述用户标识对应的业务状态信息。a second updating unit, configured to update the business status information corresponding to the user ID in the status database according to the business status corresponding to the first domain event, wherein the status database contains the user ID and the user ID and the user ID. Corresponding service status information.
结合第四方面,在第四方面的第一种可能的实现方式中,所述第一处理单元还具体用于:With reference to the fourth aspect, in a first possible implementation manner of the fourth aspect, the first processing unit is further specifically configured to:
根据预设的第二对应关系,若确定所述预设状态包含相互关联的第一预设状态以及第二预设状态,且所述第二预设状态为所述第一预设状态的必要条件,则根据所述预设的第二对应关系确定与所述第二预设状态对应的第二领域事件;其中,所述第二对应关系包含电子凭证标识以及与所述电子凭证标识对应的领域事件,以及分别与每个领域事件对应的预设状态;According to the preset second correspondence, if it is determined that the preset state includes a first preset state and a second preset state that are related to each other, and the second preset state is necessary for the first preset state condition, the second domain event corresponding to the second preset state is determined according to the preset second correspondence relationship; wherein the second correspondence relationship includes an electronic certificate identifier and an electronic certificate identifier corresponding to the electronic certificate identifier. Domain events, and preset states corresponding to each domain event;
若确定所述事件数据库不存在与所述第二预设状态对应的第二领域事件,则所述对所述第一领域事件进行处理后,触发生成所述第二领域事件。If it is determined that there is no second domain event corresponding to the second preset state in the event database, after the first domain event is processed, the generation of the second domain event is triggered.
若确定所述事件数据库存在与所述第二预设状态对应的第二领域事件,则所述对所述第一领域事件进行处理。If it is determined that there is a second domain event corresponding to the second preset state in the event database, the first domain event is processed.
结合第四方面的第一种可能的实现方式,在第四方面的第二种可能的实现方式中,所述装置还包括:With reference to the first possible implementation manner of the fourth aspect, in a second possible implementation manner of the fourth aspect, the apparatus further includes:
第三更新单元,用于根据所述第二领域事件更新事件数据库;a third updating unit, configured to update the event database according to the second domain event;
第二处理单元,用于对所述第二领域事件进行处理,获得与所述第二领域事件对应的业务状态;a second processing unit, configured to process the second domain event to obtain a business state corresponding to the second domain event;
第四更新单元,用于根据所述第二领域事件对应的业务状态对状态数据库中所述用户标识对应的业务状态信息进行更新。The fourth updating unit is configured to update the business status information corresponding to the user identifier in the status database according to the business status corresponding to the second domain event.
结合第四方面或第四方面的第一种可能的实现方式,在第四方面的第三种可能的实现方式中,所述装置还包括:With reference to the fourth aspect or the first possible implementation manner of the fourth aspect, in a third possible implementation manner of the fourth aspect, the apparatus further includes:
发送单元,用于将所述第一领域事件发送给第二事件总线;a sending unit, configured to send the first domain event to the second event bus;
相应的,所述第一处理单元还具体用于:Correspondingly, the first processing unit is also specifically used for:
从所述第二事件总线上获取所述第一事件总线,以及对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态。The first event bus is obtained from the second event bus, and the first domain event is processed to obtain a business state corresponding to the first domain event.
第五方面,提供一种应用服务器,所述应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,所述应用服务器包括第三方面至第三方面的第三种可能的实现方式中的任一种可能的实现方式所述的数据处理装置、以及第四方面至第四方面的第三种可能的实现方式中的任一种可能的实现方式所述的数据处理装置。In a fifth aspect, an application server is provided, the application server includes at least a first event bus and a second event bus, wherein the first event bus is used to transmit domain events for the first operation of the business, and the second event bus is used to transmit For the domain event of the second operation of the business, the application server includes the data processing device described in any one of the third possible implementations of the third aspect to the third possible implementation, and the fourth aspect to The data processing apparatus described in any one of the third possible implementations of the fourth aspect.
本发明的实施例提供的数据处理方法、装置及应用服务器,通过接收数据处理请求,数据处理请求包括用户标识和电子凭证标识,以及操作类型,若操作类型为第一操作,则基于电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,之后,基于用户标识查询事件数据库,获取与用户标识对应的领域事件中,除第一领域事件之外的其他领域事件,将其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与用户标识对应的处理后的业务状态信息,并根据用户标识对应的处理后的业务状态信息,对状态数据库中用户标识对应的业务状态信息进行更新,从而通过基于现有的业务逻辑,正向的对除回退事件之外的领域事件进行重放,进而无需额外开发状态信息的变更日志表,减少了开发人员的负担,同时也保证了业务回退的条件。The data processing method, device, and application server provided by the embodiments of the present invention receive a data processing request. The data processing request includes a user ID, an electronic voucher ID, and an operation type. If the operation type is the first operation, the data processing request is based on the electronic voucher ID. and the first correspondence, marking the first domain event as a fallback event, and then querying the event database based on the user ID to obtain the domain events corresponding to the user ID, other domain events except the first domain event, and other domain events. The domain events are reprocessed in sequence according to the occurrence time of the domain events, and the processed business status information corresponding to the user ID is obtained. The business status information is updated, so that based on the existing business logic, the domain events other than the fallback events can be replayed in a positive direction, thereby eliminating the need to develop additional change log tables for status information, reducing the burden on developers. At the same time, the conditions for business rollback are also guaranteed.
附图说明Description of drawings
为了更清楚地说明本发明实施例的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions of the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some of the present invention. In the embodiments, for those of ordinary skill in the art, other drawings can also be obtained according to these drawings without any creative effort.
图1为本发明实施例提供的一种通信系统的系统架构图;1 is a system architecture diagram of a communication system according to an embodiment of the present invention;
图2为本发明实施例提供的第一种数据处理方法的流程示意图;2 is a schematic flowchart of a first data processing method provided by an embodiment of the present invention;
图3为本发明实施例提供的第二种数据处理方法的流程示意图;3 is a schematic flowchart of a second data processing method provided by an embodiment of the present invention;
图4为本发明实施例提供的第三种数据处理方法的流程示意图;4 is a schematic flowchart of a third data processing method provided by an embodiment of the present invention;
图5为本发明实施例提供的第四种数据处理方法的流程示意图;5 is a schematic flowchart of a fourth data processing method provided by an embodiment of the present invention;
图6为本发明实施例提供的第五种数据处理方法的流程示意图;6 is a schematic flowchart of a fifth data processing method provided by an embodiment of the present invention;
图7为本发明实施例提供的第一种数据处理装置的结构示意图;FIG. 7 is a schematic structural diagram of a first data processing apparatus provided by an embodiment of the present invention;
图8为本发明实施例提供的第二种数据处理装置的结构示意图;8 is a schematic structural diagram of a second data processing apparatus provided by an embodiment of the present invention;
图9为本发明实施例提供的第三种数据处理装置的结构示意图。FIG. 9 is a schematic structural diagram of a third data processing apparatus according to an embodiment of the present invention.
具体实施方式Detailed ways
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。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 a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
本发明的实施例所应用的通信系统的系统架构如图1所示,该通信系统包括:客户端101、应用服务器102、存储服务器103。A system architecture of a communication system to which the embodiments of the present invention are applied is shown in FIG. 1 , and the communication system includes: a
其中,客户端101可以是手机、笔记本电脑、计算机等,客户端101可以通过指定浏览或者指定应用程序的方式等多种方式与应用服务器102之间进行通信,且通信的数据可以通过有线或者无线的形式进行传输。The
应用服务器102包括存储器1021、处理器1022、系统总线1023、电源组件1024、输入\输出接口1025和通信组件1026等;其中,存储器1021可用于存储数据、软件程序以及模块,主要包括存储程序区和存储数据区,存储程序区可存储操作系统、至少一个功能所需的应用程序等,存储数据区可存储应用服务器102的使用所创建的数据等;处理器1022通过运行或执行存储在存储器1021内的软件程序和/或模块,以及调用存储在存储器1021内的数据,执行应用服务器102的各种功能和处理数据,例如,处理器1022在处理事件时按照事件总线上排列的事件顺序依次进行处理,其中事件总线用于放置应用服务器102中待处理的事件;系统总线1023包括地址总线、数据总线、控制总线,用于传输数据和指令;电源组件1024用于为应用服务器102的各个组件提供电源;输入\输出接口1025为处理器1022和外围接口模块之间提供接口;通信组件1026用于为应用服务器102和其他设备之间进行有线或无线方式的通信。The
存储服务器103与应用服务器102可以通过网络或数据线进行连接,存储服务器103主要用于存储应用服务器102在执行或运行时所产生的领域事件,该领域事件可以永久性的进行存储,也可以存储指定时长。此外,存储服务器103可以是单独用于存储的服务器,也可以是应用服务器102的存储器1021中的一部分,也即是,将应用服务器102在执行或运行时所产生的领域事件存储在存储器1021中。The
图2为本发明实施例提供的一种数据处理方法,应用于应用服务器中,该应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,参见图2,该方法包括以下几个步骤。FIG. 2 is a data processing method provided by an embodiment of the present invention, applied to an application server, where the application server at least includes a first event bus and a second event bus, wherein the first event bus is used to transmit data for the first operation of the service. Domain event, the second event bus is used to transmit the domain event of the second operation of the service, referring to FIG. 2 , the method includes the following steps.
步骤201:接收数据处理请求,该数据处理请求包括用户标识和电子凭证标识,以及操作类型,电子凭证用于表示用户与业务之间满足预设状态。Step 201: Receive a data processing request, where the data processing request includes a user ID, an electronic voucher ID, and an operation type, and the electronic voucher is used to indicate that a preset state is satisfied between the user and the service.
其中,电子凭证标识用于唯一标识该电子凭证,且该电子凭证用于表示用户与业务之间满足预设状态,比如,当该电子凭证为用户订购业务产生的订单时,该电子凭证标识可以是该订单的订单标识,该订单标识可以是订单号,该订单号用于表示用户订购了该业务。Wherein, the electronic certificate identifier is used to uniquely identify the electronic certificate, and the electronic certificate is used to indicate that the user and the service meet a preset state. For example, when the electronic certificate is an order generated by the user ordering a service, the electronic certificate identifier can be is the order identifier of the order, and the order identifier can be an order number, and the order number is used to indicate that the user has ordered the service.
另外,该操作类型包括第一操作和第二操作,当该数据处理请求包括用户标识和电子凭证标识时,该操作类型为第一操作,当该数据处理请求包括用户标识和业务标识时,该操作类型为第二操作。比如,当用户需要办理或者取消某个业务时,第一操作类型可以是指取消办理的业务,第二操作可以是办理需要的业务。In addition, the operation type includes a first operation and a second operation, when the data processing request includes a user ID and an electronic credential ID, the operation type is the first operation, and when the data processing request includes a user ID and a service ID, the The operation type is the second operation. For example, when the user needs to handle or cancel a certain business, the first operation type may refer to canceling the business to be handled, and the second operation may be to handle the required business.
步骤202:若该操作类型为第一操作,则基于该电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,第一领域事件为与电子凭证标识对应的领域事件,第一对应关系包含电子凭证标识以及与电子凭证标识对应的领域事件。Step 202: If the operation type is the first operation, based on the electronic certificate identifier and the first correspondence, mark the first domain event as a rollback event, the first domain event is the domain event corresponding to the electronic certificate identifier, and the first domain event is the domain event corresponding to the electronic certificate identifier. A corresponding relationship includes an electronic certificate identifier and a domain event corresponding to the electronic certificate identifier.
其中,第一对应关系是指电子凭证标识与领域事件之间的对应关系,通过电子凭证标识可以确定与该电子凭证标识对应的领域事件,且第一对应关系可以单独进行存储,也可以存储在事件数据库中。The first correspondence refers to the correspondence between the electronic certificate identifier and the domain event. The domain event corresponding to the electronic certificate identifier can be determined through the electronic certificate identifier, and the first correspondence can be stored separately or stored in in the event database.
比如,用户期望取消之前办理的短信呼业务,该电子凭证标识为办理短信呼业务时的订单标识,则应用服务器基于办理短信呼业务时的订单标识,从第一对应关系中获取与办理短信呼业务时的订单标识对应的第一领域事件,即订购短信呼业务,从而将第一领域事件订购短信呼业务标记为回退事件。For example, if the user wishes to cancel the SMS call service previously handled, and the electronic voucher ID is the order ID when handling the SMS call service, the application server obtains and handles the SMS call from the first correspondence based on the order ID when handling the SMS call service. The first domain event corresponding to the order identifier during the service, that is, ordering the short message calling service, thereby marking the first domain event ordering the short message calling service as a fallback event.
需要说明的是,第一对应关系,即电子凭证标识以及与电子凭证标识对应的领域事件,是之前生成电子凭证,以及基于电子凭证标识生成领域事件时进行存储的,具体的生成电子凭证、以及基于电子凭证标识生成领域事件的方法,可以参考操作类型为第二操作的数据处理方法,本发明实施例在此不再赘述。It should be noted that the first correspondence, that is, the electronic certificate identifier and the domain event corresponding to the electronic certificate identifier, is stored when the electronic certificate is generated before and the domain event is generated based on the electronic certificate identifier. For a method for generating a domain event based on an electronic credential identifier, reference may be made to a data processing method whose operation type is the second operation, which will not be repeated in this embodiment of the present invention.
步骤203:基于用户标识查询事件数据库,获取与用户标识对应的领域事件中,除第一领域事件之外的其他领域事件;其中,事件数据库包含用户标识、与用户标识对应的领域事件、以及领域事件对应的发生时间。Step 203: query the event database based on the user ID, and obtain other domain events except the first domain event among the domain events corresponding to the user ID; wherein, the event database includes the user ID, the domain events corresponding to the user ID, and the domain events The time at which the event occurred.
其中,事件数据库除了包含用户标识、以及与用户标识对应的领域事件、以及领域事件对应的发生时间之外,还可以包含电子凭证标识、事件的数据、或者事件状态、以及它们分别与用户标识和领域事件之间的对应关系等,此外,领域事件对应的发生时间可以精确到秒、毫秒、或者微秒等,本发明实施例对此不作限定。Wherein, the event database may contain, in addition to the user ID, the domain event corresponding to the user ID, and the occurrence time corresponding to the domain event, the electronic credential ID, the event data, or the event status, and their respective associations with the user ID and the event status. The corresponding relationship between the domain events, etc., in addition, the occurrence time corresponding to the domain event may be accurate to seconds, milliseconds, or microseconds, which is not limited in this embodiment of the present invention.
另外,该事件数据库可以存储在应用服务器中,也可以单独存储在存储服务器中,且事件数据库中的数据信息可以是永久性的存储,也可以是预设时长内的存储,当该数据信息为永久性的存储时,可以基于用户标识和电子凭证标识对事件数据库中的任一领域事件进行第一操作,当该数据信息为预设时长内的存储时,可以基于用户标识和电子凭证信息对预设时长内的任一领域事件进行第一操作,本发明实施例对此不作限定。In addition, the event database can be stored in the application server, or can be stored separately in the storage server, and the data information in the event database can be permanently stored or stored for a preset period of time. When the data information is When permanently stored, the first operation can be performed on any domain event in the event database based on the user ID and the electronic voucher ID. When the data information is stored within a preset time period, the user ID and the electronic voucher information The first operation is performed on any domain event within the preset duration, which is not limited in this embodiment of the present invention.
比如,用户标识为1234567、电子凭证标识为订单标识且为ID1,第一领域事件为事件1,应用服务器基于用户标识1234567查询如下表1所示的事件数据库,获取与用户标识1234567对应的领域事件中,除事件1之外的其他领域事件为事件2和事件3。For example, if the user ID is 1234567, the electronic voucher ID is the order ID and ID1, and the first domain event is event 1, the application server queries the event database shown in the following table 1 based on the user ID 1234567, and obtains the domain event corresponding to the user ID 1234567 , the other domain events except event 1 are event 2 and event 3.
表1Table 1
需要说明的是,本发明实施例仅以上述表1所示的事件数据库为例进行说明,上述表1所示的用户标识、订单标识、领域事件、领域事件的发生时间和事件状态之间的对应关系并不对本发明实施例构成限定。It should be noted that the embodiment of the present invention only takes the event database shown in Table 1 above as an example for description. The corresponding relationship does not limit the embodiments of the present invention.
可选的,当事件数据库中的数据信息是预设时长内的存储时,应用服务器从事件数据库中,获取当前时刻之前的预设时长内与用户标识对应的领域事件;若当前时刻之前的预设时长内与用户标识对应的领域事件包含第一领域事件,则将第一领域事件删除后获取除第一领域事件之外的其他领域事件;若当前时刻之前的预设时长内与用户标识对应的领域事件不包含第一领域事件,则发送错误信息,错误信息用于指示第一操作发生错误。Optionally, when the data information in the event database is stored within a preset duration, the application server obtains, from the event database, the domain events corresponding to the user ID within the preset duration before the current moment; It is assumed that the domain events corresponding to the user ID in the duration include the first domain event, then delete the first domain event and obtain other domain events except the first domain event; if the preset duration before the current moment corresponds to the user ID If the domain event does not contain the first domain event, an error message is sent, and the error message is used to indicate that an error occurs in the first operation.
也即是,事件数据库中只存储当前时刻之前的预设时长内的领域事件,超出当前时刻之前的预设时长内的领域事件则进行删除,若第一领域事件是属于当前时刻之前的预设时长内的领域事件,则会存储在事件数据库中,从而可以将与用户标识对应的领域事件中的第一领域事件删除后,获取除第一领域事件之外的其他领域事件;若第一领域事件是不属于当前时刻之前的预设时长内的领域事件,则不会存储在事件数据库中,从而应用服务器可以向用户终端发送错误信息,该错误信息用于指示第一操作发生错误,也即是,应用服务器向用户终端发送第一领域事件不能被回退的信息。That is, only domain events within the preset duration before the current moment are stored in the event database, and domain events exceeding the preset duration before the current moment are deleted, if the first domain event belongs to the preset duration before the current moment. The domain events within the duration will be stored in the event database, so that after deleting the first domain event in the domain events corresponding to the user ID, other domain events except the first domain event can be obtained; if the first domain event The event is a domain event that does not belong to the preset time period before the current moment, so it will not be stored in the event database, so that the application server can send an error message to the user terminal, and the error message is used to indicate that an error occurred in the first operation, that is, Yes, the application server sends the information that the first domain event cannot be rolled back to the user terminal.
需要说明的是,预设时长可以事先设置,且不同的领域事件对应的预设时长可以相同,也可以不同,本发明实施例对此不作限定。It should be noted that the preset duration may be set in advance, and the preset durations corresponding to different domain events may be the same or different, which is not limited in this embodiment of the present invention.
比如,在通信运营过程中规定订购短信呼业务超过三个月则不能进行退订,若第一领域事件为订购短信呼业务,则预设时长为三个月,且在三个月内事件数据库中包含第一领域事件订购短信呼业务,用户可以申请进行回退,超过三个月事件数据库则删除第一领域事件订购短信呼业务,若用户申请进行回退,则应用服务器向用户终端发送不能回退的信息。For example, in the communication operation process, it is stipulated that the subscription of the SMS call service cannot be unsubscribed for more than three months. If the first field event is the subscription of the SMS call service, the preset duration is three months, and the event database within three months It includes the event subscription SMS call service in the first field, and the user can apply for a rollback. If the event database exceeds three months, the event subscription SMS call service in the first field will be deleted. If the user applies for a rollback, the application server will send a message that cannot Fallback information.
步骤204:将其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与用户标识对应的处理后的业务状态信息。Step 204: Reprocess other domain events in sequence according to the time sequence of occurrence of the domain events to obtain processed service status information corresponding to the user ID.
由于每一个领域事件都有一个事件侦听者,由事件侦听者将对应的领域事件进行处理,因此,将其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理时,可以将其他领域事件按照领域事件的发生时间的先后顺序依次发送给第一事件总线,由相应的事件侦听者从第一事件总线上依次获取其他领域事件,并以同步侦听的模式进行处理,得到与用户标识对应的处理后的业务状态信息。Since each domain event has an event listener, the corresponding domain event is processed by the event listener. Therefore, when other domain events are reprocessed in the order of the occurrence time of the domain events, other domain events can be reprocessed. The domain events are sent to the first event bus in the order of the occurrence time of the domain events, and the corresponding event listeners obtain other domain events from the first event bus in turn, and process them in a synchronous listening mode. The processed service status information corresponding to the user ID.
其中,以同步侦听的模式进行处理是指,领域事件的发送和接收处理在相同的线程中,不进行线程切换,确保每个领域事件被处理完毕之后再处理下一个领域事件。Among them, processing in the mode of synchronous listening means that the sending and receiving of domain events are processed in the same thread, and no thread switching is performed to ensure that each domain event is processed before processing the next domain event.
需要说明的是,应用服务器在系统初始化时,针对不同的领域事件有对应的事件侦听者,事件侦听者的目的就是针对不同的领域事件调用不同的领域服务,在系统运行时捕获到待处理的领域事件,调用对应的领域事件的相应领域服务,从而进行对应的领域事件处理,具体的领域事件处理可以参考相关技术,本发明实施例在此不作阐述。It should be noted that when the application server initializes the system, there are corresponding event listeners for different domain events. The purpose of the event listener is to call different domain services for different domain events, and capture the pending events when the system is running. The processed domain event calls the corresponding domain service of the corresponding domain event, so as to process the corresponding domain event. For the specific domain event processing, reference may be made to the related art, which is not described in this embodiment of the present invention.
步骤205:根据用户标识对应的处理后的业务状态信息,对状态数据库中用户标识对应的业务状态信息进行更新,其中,状态数据库包含用户标识、以及与用户标识对应的业务状态信息。Step 205: Update the service state information corresponding to the user ID in the state database according to the processed service state information corresponding to the user ID, wherein the state database includes the user ID and the service state information corresponding to the user ID.
由于状态数据库包含用户标识、以及与用户标识对应的业务状态信息,而进行第一操作后用户标识对应的业务状态信息发生了变化,且为了将状态数据库中用户标识对应的业务状态信息恢复至第一领域事件未发生时的状态,可以根据用户标识对应的处理后的业务状态信息,对状态数据库中用户标识对应的业务状态信息进行更新,即可以将状态数据库中用户标识对应的业务状态信息,替换为用户标识对应的处理后的业务状态信息。Since the status database contains the user ID and the business status information corresponding to the user ID, the business status information corresponding to the user ID has changed after the first operation, and in order to restore the business status information corresponding to the user ID in the status database to the first In the state when an event in a domain does not occur, the business state information corresponding to the user ID in the state database can be updated according to the processed business state information corresponding to the user ID, that is, the business state information corresponding to the user ID in the state database can be updated. Replace with the processed service status information corresponding to the user ID.
需要说明的是,状态数据库用于存储用户的业务状态信息,且该状态数据库包含用户标识、以及与用户标识对应的业务状态信息,而该业务状态信息可以包括业务标识、电子凭证标识、信息的创建时间等等,本发明实施例对此不作具体限定。It should be noted that the status database is used to store the business status information of the user, and the status database includes the user ID and the business status information corresponding to the user ID, and the business status information may include the business ID, the electronic voucher ID, the information The creation time, etc., is not specifically limited in this embodiment of the present invention.
可选的,参见图3,在步骤203之后,该方法还包括:Optionally, referring to FIG. 3, after
步骤206:若其他领域事件中存在第二领域事件与第一领域事件存在预设关联关系,则发送错误信息,该错误信息用于指示第一操作发生错误。Step 206: If there is a preset association relationship between the second domain event and the first domain event among other domain events, send error information, where the error information is used to indicate that an error occurs in the first operation.
其中,预设关联关系是指第一领域事件和第二领域事件相互关联,且第二领域事件存在时,第一领域事件也必须存在。比如,在通信运营过程中规定套餐B包含短信呼业务,若第二领域事件为订购套餐B,第一领域事件为订购短信呼业务,由于订购套餐B与订购短信呼业务相互关联,因此,当第二领域事件订购套餐B存在时,第一领域事件订购短信呼业务也必须存在。The preset association relationship means that the first domain event and the second domain event are related to each other, and when the second domain event exists, the first domain event must also exist. For example, in the communication operation process, it is stipulated that package B includes the SMS calling service. If the second domain event is the subscription package B, and the first domain event is the SMS calling service subscription, since the subscription package B and the SMS calling service are related to each other, when When the event subscription package B in the second domain exists, the event subscription SMS call service in the first domain must also exist.
具体的,在其他领域事件中,若有第二领域事件与第一领域事件存在预设关联关系,则确定第一领域事件不能被回退,因此,应用服务器可以向用户终端发送错误信息,该错误信息用于指示第一操作发生错误,也即是,应用服务器向用户终端发送第一领域事件不能被回退的信息。Specifically, in other domain events, if there is a preset association relationship between the second domain event and the first domain event, it is determined that the first domain event cannot be rolled back. Therefore, the application server may send an error message to the user terminal, the The error information is used to indicate that an error occurs in the first operation, that is, the application server sends the information that the first domain event cannot be rolled back to the user terminal.
本发明的实施例提供的数据处理方法,通过接收数据处理请求,数据处理请求包括用户标识和电子凭证标识,以及操作类型,若操作类型为第一操作,则基于电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,之后,基于用户标识查询事件数据库,获取与用户标识对应的领域事件中,除第一领域事件之外的其他领域事件,将其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与用户标识对应的处理后的业务状态信息,并根据用户标识对应的处理后的业务状态信息,对状态数据库中用户标识对应的业务状态信息进行更新,从而通过基于现有的业务逻辑,正向的对除回退事件之外的领域事件进行重放,进而无需额外开发状态信息的变更日志表,减少了开发人员的负担,同时也保证了业务回退的条件。In the data processing method provided by the embodiment of the present invention, by receiving a data processing request, the data processing request includes a user ID, an electronic voucher ID, and an operation type. If the operation type is the first operation, the data processing request is based on the electronic voucher ID and the first corresponding relationship. , mark the first domain event as a fallback event, and then query the event database based on the user ID to obtain other domain events except the first domain event among the domain events corresponding to the user ID, and classify other domain events as domain events Reprocessing is performed in the order of the occurrence time of the user ID, and the processed service status information corresponding to the user ID is obtained, and the service status information corresponding to the user ID in the status database is updated according to the processed service status information corresponding to the user ID. , so that based on the existing business logic, the domain events other than the fallback events are replayed positively, and there is no need to develop additional change log tables for status information, which reduces the burden on developers and ensures business Fallback conditions.
图4为本发明实施例提供的一种数据处理方法,应用于应用服务器中,该应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,该方法包括以下几个步骤:FIG. 4 is a data processing method provided by an embodiment of the present invention, which is applied to an application server. The application server includes at least a first event bus and a second event bus, wherein the first event bus is used to transmit data for the first operation of the service. Domain event, the second event bus is used to transmit the domain event of the second operation of the business, and the method includes the following steps:
步骤301:接收数据处理请求,数据处理请求包括用户标识和业务标识,以及操作类型。Step 301: Receive a data processing request, where the data processing request includes a user ID, a service ID, and an operation type.
其中,该操作类型包括第一操作和第二操作,当该数据处理请求包括用户标识和电子凭证标识时,该操作类型为第一操作,当该数据处理请求包括用户标识和业务标识时,该操作类型为第二操作。比如,当用户需要办理或者取消某个业务时,第一操作类型可以是指取消办理的业务,第二操作可以是办理需要的业务。The operation type includes a first operation and a second operation. When the data processing request includes a user ID and an electronic credential ID, the operation type is the first operation. When the data processing request includes a user ID and a service ID, the operation type is the first operation. The operation type is the second operation. For example, when the user needs to handle or cancel a certain business, the first operation type may refer to canceling the business to be handled, and the second operation may be to handle the required business.
步骤302:若操作类型为第二操作,则基于数据处理请求生成电子凭证,电子凭证用于表示用户与业务之间满足预设状态。Step 302: If the operation type is the second operation, generate an electronic voucher based on the data processing request, and the electronic voucher is used to indicate that a preset state is satisfied between the user and the service.
其中,基于数据处理请求生成电子凭证是指,基于数据处理请求包括的用户标识和业务标识生成电子凭证。比如,在通信运营过程中,该数据处理请求可以为用户订购业务的请求,应用服务器可以基于用户标识和用户期望订购的业务标识生成订单,该订单用于表示用户订购了该业务,此时该电子凭证即为产生的订单,电子凭证标识可以是该订单的订单标识,该订单标识可以是订单号。Wherein, generating the electronic voucher based on the data processing request refers to generating the electronic voucher based on the user ID and the service ID included in the data processing request. For example, in the process of communication operation, the data processing request may be a request for a user to order a service, and the application server may generate an order based on the user ID and the service ID that the user expects to order. The electronic voucher is the generated order, the electronic voucher identifier can be the order identifier of the order, and the order identifier can be the order number.
步骤303:基于电子凭证的标识,生成与电子凭证的标识对应的第一领域事件。Step 303: Based on the identifier of the electronic certificate, generate a first domain event corresponding to the identifier of the electronic certificate.
其中,电子凭证的标识即电子凭证标识,应用服务器在基于电子凭证标识,生成与电子凭证标识对应的第一领域事件之后,还可以将该电子凭证标识、以及电子凭证标识对应的第一领域事件存储在第一对应关系中,且该第一对应关系可以单独进行存储,也可以存储在事件数据中。The identifier of the electronic certificate is the electronic certificate identifier. After generating the first domain event corresponding to the electronic certificate identifier based on the electronic certificate identifier, the application server may also generate the electronic certificate identifier and the first domain event corresponding to the electronic certificate identifier. is stored in the first corresponding relationship, and the first corresponding relationship can be stored separately or in the event data.
比如,在通信运营过程中,用户期望订购短信呼业务,且此时的电子凭证为订单,则应用服务器可以基于订单标识,生成与订单标识对应的第一领域事件,即订购短信呼业务,之后,可以将该订单标识、以及与订单标识对应的第一领域事件存储在第一对应关系中。For example, in the process of communication operation, if the user wishes to order the SMS calling service, and the electronic certificate at this time is an order, the application server can generate the first domain event corresponding to the order ID based on the order ID, that is, order the SMS calling service, and then , the order identifier and the first domain event corresponding to the order identifier can be stored in the first correspondence.
步骤304:根据第一领域事件更新事件数据库,其中,事件数据库包含用户标识、与用户标识对应的领域事件、以及领域事件对应的发生时间;Step 304: Update the event database according to the first domain event, wherein the event database includes the user ID, the domain event corresponding to the user ID, and the occurrence time corresponding to the domain event;
其中,事件数据库除了包含用户标识、以及与用户标识对应的领域事件、以及领域事件对应的发生时间之外,还可以包含电子凭证标识、事件的数据、或者事件状态、以及它们分别与用户标识和领域事件之间的对应关系等,此外,领域事件对应的发生时间可以精确到秒、毫秒、或者微秒等,本发明实施例对此不作限定。Wherein, the event database may contain, in addition to the user ID, the domain event corresponding to the user ID, and the occurrence time corresponding to the domain event, the electronic credential ID, the event data, or the event status, and their respective associations with the user ID and the event status. The corresponding relationship between the domain events, etc., in addition, the occurrence time corresponding to the domain event may be accurate to seconds, milliseconds, or microseconds, which is not limited in this embodiment of the present invention.
另外,该事件数据库可以存储在应用服务器中,也可以单独存储在存储服务器中,且事件数据库中的数据信息可以是永久性的存储,也可以是预设时长内的存储,当该数据信息为预设时长内的存储时,事件数据库中只存储当前时刻之前的预设时长内的领域事件,超出当前时刻之前的预设时长内的领域事件则进行删除。In addition, the event database can be stored in the application server, or can be stored separately in the storage server, and the data information in the event database can be permanently stored or stored for a preset period of time. When the data information is When storing within the preset duration, only the domain events within the preset duration before the current time are stored in the event database, and the domain events exceeding the preset duration before the current time will be deleted.
需要说明的是,预设时长可以事先设置,且不同的领域事件对应的预设时长可以相同,也可以不同,本发明实施例对此不作限定。It should be noted that the preset duration may be set in advance, and the preset durations corresponding to different domain events may be the same or different, which is not limited in this embodiment of the present invention.
步骤305:对第一领域事件进行处理,获得与第一领域事件对应的业务状态;Step 305: Process the first domain event to obtain a business state corresponding to the first domain event;
具体的,在对第一领域事件进行处理之前,可以将第一领域事件发送给第二事件总线,由于每一个领域事件都有一个事件侦听者,由对应的事件侦听者从第二事件总线上获取第一领域事件,以及对第一领域事件进行处理,获得与第一领域事件对应的业务状态。Specifically, before the first domain event is processed, the first domain event can be sent to the second event bus. Since each domain event has an event listener, the corresponding event listener can read the second event from the second event. The first domain event is acquired on the bus, and the first domain event is processed to obtain a business state corresponding to the first domain event.
需要说明的是,应用服务器在系统初始化时,针对不同的领域事件有对应的事件侦听者,事件侦听者的目的就是针对不同的领域事件调用不同的领域服务,在系统运行时捕获到待处理的领域事件,调用对应的领域事件的相应领域服务,从而进行对应的领域事件处理,具体的领域事件处理可以参考相关技术,本发明实施例在此不作阐述。It should be noted that when the application server initializes the system, there are corresponding event listeners for different domain events. The purpose of the event listener is to call different domain services for different domain events, and capture the pending events when the system is running. The processed domain event calls the corresponding domain service of the corresponding domain event, so as to process the corresponding domain event. For the specific domain event processing, reference may be made to the related art, which is not described in this embodiment of the present invention.
步骤306:根据第一领域事件对应的业务状态,对状态数据库中用户标识对应的业务状态信息进行更新,其中,状态数据库包含用户标识、以及与用户标识对应的业务状态信息。Step 306: Update the business status information corresponding to the user ID in the status database according to the business status corresponding to the first domain event, wherein the status database includes the user ID and the business status information corresponding to the user ID.
当获取第一领域事件对应的业务状态之后,可以根据第一领域事件对应的业务状态,对状态数据库中用户标识对应的业务状态信息进行更新,即可以将状态数据库中第一领域事件对应的业务状态,添加在用户标识对应的业务状态信息中。After obtaining the business status corresponding to the first domain event, the business status information corresponding to the user ID in the status database can be updated according to the business status corresponding to the first domain event, that is, the business status corresponding to the first domain event in the status database can be updated. Status, which is added to the service status information corresponding to the user ID.
需要说明的是,状态数据库用于存储用户的业务状态信息,且该状态数据库包含用户标识、以及与用户标识对应的业务状态信息,而该业务状态信息可以包括业务标识、电子凭证标识、信息的创建时间等等,本发明实施例对此不作具体限定。It should be noted that the status database is used to store the business status information of the user, and the status database includes the user ID and the business status information corresponding to the user ID, and the business status information may include the business ID, the electronic voucher ID, the information The creation time, etc., is not specifically limited in this embodiment of the present invention.
可选的,参见图5,在步骤305之后,该方法还包括:Optionally, referring to FIG. 5, after
步骤307:根据预设的第二对应关系,若确定预设状态包含相互关联的第一预设状态以及第二预设状态,且第二预设状态为第一预设状态的必要条件,则根据预设的第二对应关系确定与第二预设状态对应的第二领域事件;第二对应关系包含电子凭证标识、与电子凭证标识对应的领域事件,以及分别与每个领域事件对应的预设状态。Step 307: According to the preset second correspondence, if it is determined that the preset state includes the first preset state and the second preset state that are related to each other, and the second preset state is a necessary condition of the first preset state, then The second domain event corresponding to the second preset state is determined according to the preset second correspondence; the second correspondence includes the electronic certificate identifier, the domain event corresponding to the electronic certificate identifier, and the predetermined corresponding to each domain event respectively. set status.
其中,第二对应关系中包含的电子凭证标识对应的领域事件可以包括第一领域事件和第二领域事件,比如,当用户期望订购的业务为套餐B时,该电子凭证标识可以为订单标识,由于套餐B包含短信呼业务,因此,与订单标识对应的领域事件包括两个,即第一领域事件为用户订购套餐B,第二领域事件为用户订购短信呼业务。Wherein, the domain event corresponding to the electronic certificate identifier included in the second correspondence relationship may include the first domain event and the second domain event. For example, when the service the user expects to order is Package B, the electronic certificate identifier may be the order identifier, Since the package B includes the SMS calling service, there are two domain events corresponding to the order identifier, that is, the first domain event is that the user subscribes to the package B, and the second domain event is that the user subscribes to the SMS calling service.
另外,第二对应关系中包含的分别与每个领域事件对应的预设状态是指,第二对应关系中包括每个领域事件对应的状态信息,比如,第一领域事件的预设状态为第一预设状态,第一预设状态即为第一领域事件的状态信息。In addition, the preset states corresponding to each domain event included in the second correspondence relationship means that the second correspondence relationship includes state information corresponding to each domain event. For example, the preset state of the first domain event is the first A preset state, the first preset state is the state information of the first domain event.
具体的,第一领域事件对应第一预设状态,第二领域事件对应第二预设状态,且第一预设状态与第二预设状态相互关联,则应用服务器基于电子凭证标识和预设的第二对应关系,确定第二对应关系是否包括与第一预设状态相互关联的第二预设状态,若确定存在第二预设状态,则根据预设的第二对应关系确定与第二预设状态对应的第二领域事件。Specifically, the first domain event corresponds to the first preset state, the second domain event corresponds to the second preset state, and the first preset state and the second preset state are associated with each other, the application server is based on the electronic certificate identifier and the preset state. the second corresponding relationship, determine whether the second corresponding relationship includes a second preset state interrelated with the first preset state, if it is determined that there is a second preset state, then determine the The second domain event corresponding to the preset state.
步骤308:若确定事件数据库不存在与第二预设状态对应的第二领域事件,则对第一领域事件进行处理后,触发生成第二领域事件。Step 308 : If it is determined that there is no second domain event corresponding to the second preset state in the event database, after processing the first domain event, trigger the generation of the second domain event.
当确定第二领域事件时,需要查询事件数据库是否存在与第二预设状态对应的第二领域事件,若确定事件数据库不存在与第二预设状态对应的第二领域事件,由于第一预设状态与第二预设状态相互关联,且第二预设状态为第一预设状态的必要条件,因此,需要在对第一领域事件进行处理后,触发生成第二领域事件。When determining the second domain event, it is necessary to query the event database to see if there is a second domain event corresponding to the second preset state. If it is determined that the event database does not have a second domain event corresponding to the second preset state, the It is assumed that the state and the second preset state are interrelated, and the second preset state is a necessary condition of the first preset state. Therefore, it is necessary to trigger the generation of the second domain event after processing the first domain event.
比如,在通信运营过程中,套餐B包含短信呼业务,第一领域事件为用户订购套餐B,第二领域事件为用户订购短信呼业务,若确定事件数据库中不存在第二领域事件,也即是,用户未订购短信呼业务,则需要在为用户订购套餐B,触发生成订购短信呼业务的第二领域事件。For example, in the process of communication operation, package B includes the SMS calling service, the first domain event is that the user subscribes to the package B, and the second domain event is that the user subscribes the SMS calling service. If it is determined that there is no second domain event in the event database, that is, Yes, if the user does not subscribe to the SMS calling service, it is necessary to subscribe the package B for the user to trigger the generation of the second domain event for ordering the SMS calling service.
步骤309:若确定事件数据库存在与第二预设状态对应的第二领域事件,则对第一领域事件进行处理。Step 309: If it is determined that there is a second domain event corresponding to the second preset state in the event database, process the first domain event.
当查询事件数据库是否存在与第二预设状态对应的第二领域事件时,若确定事件数据库存在与第二预设状态对应的第二领域事件,也即是,第二领域事件已经存在,则无需触发生成第二领域事件,直接对第一领域事件进行处理。When querying the event database for whether there is a second domain event corresponding to the second preset state, if it is determined that the event database has a second domain event corresponding to the second preset state, that is, the second domain event already exists, then There is no need to trigger the generation of the second domain event, and the first domain event is directly processed.
可选的,参见图6,在步骤308之后,该方法还包括:Optionally, referring to FIG. 6, after
步骤310:根据第二领域事件更新事件数据库,对第二领域事件进行处理,获得与第二领域事件对应的业务状态。Step 310: Update the event database according to the second domain event, process the second domain event, and obtain a business state corresponding to the second domain event.
具体的,在对第二领域事件进行处理之前,可以将第一领域事件发送给第二事件总线,且在第二领域事件被对应的事件侦听者获取之前,将第二领域事件更新到事件数据库中,之后,由对应的事件侦听者从第二事件总线上获取第二领域事件,以及对第二领域事件进行处理,获得与第二领域事件对应的业务状态。Specifically, before processing the second domain event, the first domain event can be sent to the second event bus, and before the second domain event is acquired by the corresponding event listener, the second domain event is updated to the event After that, the corresponding event listener obtains the second domain event from the second event bus, and processes the second domain event to obtain the business state corresponding to the second domain event.
步骤311:根据第二领域事件对应的业务状态,对状态数据库中用户标识对应的业务状态信息进行更新。Step 311: Update the business status information corresponding to the user identifier in the status database according to the business status corresponding to the second domain event.
当获取第二领域事件对应的业务状态之后,可以根据第二领域事件对应的业务状态,对状态数据库中用户标识对应的业务状态信息进行更新,即可以将状态数据库中第二领域事件对应的业务状态,添加在用户标识对应的业务状态信息中。After obtaining the business status corresponding to the second domain event, the business status information corresponding to the user ID in the status database can be updated according to the business status corresponding to the second domain event, that is, the business status corresponding to the second domain event in the status database can be updated. Status, which is added to the service status information corresponding to the user ID.
本发明实施例提供的数据处理方法,通过接收数据处理请求,数据处理请求包括用户标识和业务标识,以及操作类型,若操作类型为第二操作,则基于数据处理请求生成电子凭证,基于电子凭证的标识,生成与电子凭证的标识对应的第一领域事件,之后,根据第一领域事件更新事件数据库,并对第一领域事件进行处理,获得与第一领域事件对应的业务状态,根据第一领域事件对应的业务状态,对状态数据库中用户标识对应的业务状态信息进行更新,并且在事件数据库不存在与第二预设状态对应的第二领域事件时,则对第一领域事件进行处理后,触发生成第二领域事件,从而可以快速有效的进行相关业务的数据处理,同时保证业务处理满足一定的条件。In the data processing method provided by the embodiment of the present invention, by receiving a data processing request, the data processing request includes a user ID, a service ID, and an operation type. If the operation type is the second operation, an electronic certificate is generated based on the data processing request, and the electronic certificate is based on the , generate the first domain event corresponding to the identification of the electronic certificate, then update the event database according to the first domain event, process the first domain event, and obtain the business status corresponding to the first domain event, according to the first domain event. The business state corresponding to the domain event, update the business state information corresponding to the user ID in the state database, and when there is no second domain event corresponding to the second preset state in the event database, the first domain event is processed after , triggering the generation of a second domain event, so that data processing of related services can be performed quickly and effectively, and at the same time, it is ensured that the service processing meets certain conditions.
图7为本发明实施例提供的一种数据处理装置的结构示意图,应用于应用服务器中,该应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,参见图7,该装置包括:7 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present invention, applied to an application server, where the application server at least includes a first event bus and a second event bus, wherein the first event bus A domain event of an operation, the second event bus is used to transmit the domain event of the second operation of the business, referring to FIG. 7 , the device includes:
接收单元401,用于接收数据处理请求,所述数据处理请求包括用户标识和电子凭证标识,以及操作类型,电子凭证用于表示用户与业务之间满足预设状态;A receiving
标记单元402,用于若所述操作类型为第一操作,则基于所述电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,所述第一领域事件为与所述电子凭证标识对应的领域事件,所述第一对应关系包含电子凭证标识以及与所述电子凭证标识对应的领域事件;The marking
获取单元403,用于基于所述用户标识查询事件数据库,获取与所述用户标识对应的领域事件中,除所述第一领域事件之外的其他领域事件;其中,所述事件数据库包含用户标识、与用户标识对应的领域事件、以及所述领域事件对应的发生时间;The obtaining
处理单元404,用于将所述其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与所述用户标识对应的处理后的业务状态信息;The
更新单元405,用于根据所述用户标识对应的处理后的业务状态信息,对状态数据库中所述用户标识对应的业务状态信息进行更新,其中,所述状态数据库包含用户标识、以及与所述用户标识对应的业务状态信息。The updating
可选的,处理单元404具体用于:Optionally, the
将所述其他领域事件按照领域事件的发生时间的先后顺序依次发送给第一事件总线;sending the other domain events to the first event bus in sequence according to the occurrence time of the domain events;
从所述第一事件总线上依次获取所述其他领域事件,并以同步侦听的模式进行处理,得到与所述用户标识对应的处理后的业务状态信息。The other domain events are sequentially acquired from the first event bus, and processed in a synchronous listening mode to obtain processed service status information corresponding to the user ID.
可选的,处理单元404还具体用于:Optionally, the
若所述其他领域事件中存在第二领域事件与所述第一领域事件存在预设关联关系,则发送错误信息,所述错误信息用于指示所述第一操作发生错误。If there is a preset association relationship between the second domain event and the first domain event among the other domain events, error information is sent, where the error information is used to indicate that an error occurs in the first operation.
可选的,获取单元403具体用于:Optionally, the obtaining
从所述事件数据库中,获取当前时刻之前的预设时长内与所述用户标识对应的领域事件;From the event database, obtain a domain event corresponding to the user ID within a preset time period before the current moment;
若所述当前时刻之前的预设时长内与所述用户标识对应的领域事件包含所述第一领域事件,则将所述第一领域事件删除后获取除所述第一领域事件之外的其他领域事件;If the domain event corresponding to the user identifier within the preset time period before the current moment includes the first domain event, delete the first domain event and obtain other domain events other than the first domain event domain events;
若所述当前时刻之前的预设时长内与所述用户标识对应的领域事件不包含所述第一领域事件,则发送错误信息,所述错误信息用于指示所述第一操作发生错误。If the domain event corresponding to the user identifier does not include the first domain event within a preset time period before the current moment, an error message is sent, where the error message is used to indicate that an error occurs in the first operation.
本发明的实施例提供的数据处理装置,通过接收数据处理请求,数据处理请求包括用户标识和电子凭证标识,以及操作类型,若操作类型为第一操作,则基于电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,之后,基于用户标识查询事件数据库,获取与用户标识对应的领域事件中,除第一领域事件之外的其他领域事件,将其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与用户标识对应的处理后的业务状态信息,并根据用户标识对应的处理后的业务状态信息,对状态数据库中用户标识对应的业务状态信息进行更新,从而通过基于现有的业务逻辑,正向的对除回退事件之外的领域事件进行重放,进而无需额外开发状态信息的变更日志表,减少了开发人员的负担,同时也保证了业务回退的条件。The data processing apparatus provided by the embodiment of the present invention receives a data processing request, and the data processing request includes a user ID, an electronic voucher ID, and an operation type. If the operation type is the first operation, the data processing request is based on the electronic voucher ID and the first corresponding relationship. , mark the first domain event as a fallback event, and then query the event database based on the user ID to obtain other domain events except the first domain event among the domain events corresponding to the user ID, and classify other domain events as domain events Reprocessing is performed in the order of the occurrence time of the user ID, and the processed service status information corresponding to the user ID is obtained, and the service status information corresponding to the user ID in the status database is updated according to the processed service status information corresponding to the user ID. , so that based on the existing business logic, the domain events other than the fallback events are replayed positively, and there is no need to develop additional change log tables for status information, which reduces the burden on developers and ensures business Fallback conditions.
图8为本发明实施例提供的一种数据处理装置的结构示意图,应用于应用服务器中,应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,参见图8,该装置包括:8 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present invention, which is applied to an application server, where the application server at least includes a first event bus and a second event bus, wherein the first event bus The domain event of the operation, the second event bus is used to transmit the domain event of the second operation of the business, referring to FIG. 8 , the device includes:
接收单元501,用于接收数据处理请求,所述数据处理请求包括用户标识和业务标识,以及操作类型;a receiving
第一生成单元502,用于若所述操作类型为第二操作,则基于所述数据处理请求生成电子凭证,所述电子凭证用于表示用户与业务之间满足预设状态;a
第二生成单元503,用于基于所述电子凭证的标识,生成与所述电子凭证的标识对应的第一领域事件;A
第一更新单元504,用于根据所述第一领域事件更新事件数据库,其中,所述事件数据库包含用户标识、与用户标识对应的领域事件、以及所述领域事件对应的发生时间;a
第一处理单元505,用于对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态;a
第二更新单元506,用于根据所述第一领域事件对应的业务状态对状态数据库中所述用户标识对应的业务状态信息进行更新,其中,所述状态数据库包含用户标识、以及与所述用户标识对应的业务状态信息。The
可选的,第一处理单元505还具体用于:Optionally, the
根据预设的第二对应关系,若确定所述预设状态包含相互关联的第一预设状态以及第二预设状态,且所述第二预设状态为所述第一预设状态的必要条件,则根据所述预设的第二对应关系确定与所述第二预设状态对应的第二领域事件;其中,所述第二对应关系包含电子凭证标识以及与所述电子凭证标识对应的领域事件,以及分别与每个领域事件对应的预设状态;According to the preset second correspondence, if it is determined that the preset state includes a first preset state and a second preset state that are related to each other, and the second preset state is necessary for the first preset state condition, the second domain event corresponding to the second preset state is determined according to the preset second correspondence relationship; wherein the second correspondence relationship includes an electronic certificate identifier and an electronic certificate identifier corresponding to the electronic certificate identifier. Domain events, and preset states corresponding to each domain event;
若确定所述事件数据库不存在与所述第二预设状态对应的第二领域事件,则所述对所述第一领域事件进行处理后,触发生成所述第二领域事件。If it is determined that there is no second domain event corresponding to the second preset state in the event database, after the first domain event is processed, the generation of the second domain event is triggered.
若确定所述事件数据库存在与所述第二预设状态对应的第二领域事件,则所述对所述第一领域事件进行处理。If it is determined that there is a second domain event corresponding to the second preset state in the event database, the first domain event is processed.
可选的,参见图9,该装置还包括:Optionally, referring to Figure 9, the device further includes:
第三更新单元507,用于根据所述第二领域事件更新事件数据库;A
第二处理单元508,用于对所述第二领域事件进行处理,获得与所述第二领域事件对应的业务状态;A
第四更新单元509,用于根据所述第二领域事件对应的业务状态对状态数据库中所述用户标识对应的业务状态信息进行更新。The
可选的,该装置还包括:Optionally, the device further includes:
发送单元,用于将所述第一领域事件发送给第二事件总线;a sending unit, configured to send the first domain event to the second event bus;
相应的,第一处理单元505还具体用于:Correspondingly, the
从所述第二事件总线上获取所述第一事件总线,以及对所述第一领域事件进行处理,获得与所述第一领域事件对应的业务状态。The first event bus is obtained from the second event bus, and the first domain event is processed to obtain a business state corresponding to the first domain event.
本发明实施例提供的数据处理方法,通过接收数据处理请求,数据处理请求包括用户标识和业务标识,以及操作类型,若操作类型为第二操作,则基于数据处理请求生成电子凭证,基于电子凭证的标识,生成与电子凭证的标识对应的第一领域事件,之后,根据第一领域事件更新事件数据库,并对第一领域事件进行处理,获得与第一领域事件对应的业务状态,根据第一领域事件对应的业务状态,对状态数据库中用户标识对应的业务状态信息进行更新,并且在事件数据库不存在与第二预设状态对应的第二领域事件时,则对第一领域事件进行处理后,触发生成第二领域事件,从而可以快速有效的进行相关业务的数据处理,同时保证业务处理满足一定的条件。In the data processing method provided by the embodiment of the present invention, by receiving a data processing request, the data processing request includes a user ID, a service ID, and an operation type. If the operation type is the second operation, an electronic certificate is generated based on the data processing request, and the electronic certificate is based on the , generate the first domain event corresponding to the identification of the electronic certificate, then update the event database according to the first domain event, process the first domain event, and obtain the business status corresponding to the first domain event, according to the first domain event. The business state corresponding to the domain event, update the business state information corresponding to the user ID in the state database, and when there is no second domain event corresponding to the second preset state in the event database, the first domain event is processed after , triggering the generation of a second domain event, so that data processing of related services can be performed quickly and effectively, and at the same time, it is ensured that the service processing meets certain conditions.
本发明实施例提供一种应用服务器,所述应用服务器至少包括第一事件总线和第二事件总线,其中第一事件总线用于传输对业务第一操作的领域事件,第二事件总线用于传输对业务第二操作的领域事件,所述应用服务器包括图7所示的数据处理装置,或图8、图9任意之一所示的数据处理装置。An embodiment of the present invention provides an application server, where the application server includes at least a first event bus and a second event bus, wherein the first event bus is used to transmit domain events for a first operation of a service, and the second event bus is used to transmit For the domain event of the second business operation, the application server includes the data processing apparatus shown in FIG. 7 , or the data processing apparatus shown in any one of FIG. 8 and FIG. 9 .
本发明的实施例提供的应用服务器,通过接收数据处理请求,数据处理请求包括用户标识和电子凭证标识,以及操作类型,若操作类型为第一操作,则基于电子凭证标识以及第一对应关系,将第一领域事件标记为回退事件,之后,基于用户标识查询事件数据库,获取与用户标识对应的领域事件中,除第一领域事件之外的其他领域事件,将其他领域事件按照领域事件的发生时间的先后顺序依次进行重新处理,得到与用户标识对应的处理后的业务状态信息,并根据用户标识对应的处理后的业务状态信息,对状态数据库中用户标识对应的业务状态信息进行更新,从而通过基于现有的业务逻辑,正向的对除回退事件之外的领域事件进行重放,进而无需额外开发状态信息的变更日志表,减少了开发人员的负担,同时也保证了业务回退的条件。The application server provided by the embodiment of the present invention receives a data processing request, and the data processing request includes a user ID, an electronic voucher ID, and an operation type. If the operation type is the first operation, based on the electronic voucher ID and the first corresponding relationship, Mark the first domain event as a fallback event, and then query the event database based on the user ID to obtain other domain events except the first domain event among the domain events corresponding to the user ID, and classify the other domain events according to the domain events. The sequence of occurrence time is reprocessed in turn to obtain the processed service status information corresponding to the user ID, and according to the processed service status information corresponding to the user ID, the service status information corresponding to the user ID in the status database is updated. Therefore, based on the existing business logic, the domain events other than the rollback events are replayed in a positive direction, and there is no need to develop additional change log tables for status information, which reduces the burden on developers and ensures business return. conditions of withdrawal.
最后应说明的是:以上实施例仅用以说明本发明的技术方案,而非对其限制;尽管参照前述实施例对本发明进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例技术方案的精神和范围。Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, but not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that it can still be The technical solutions described in the foregoing embodiments are modified, or some technical features thereof are equivalently replaced; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims (17)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511033240.2A CN106933932B (en) | 2015-12-31 | 2015-12-31 | Data processing method, device and application server |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201511033240.2A CN106933932B (en) | 2015-12-31 | 2015-12-31 | Data processing method, device and application server |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106933932A CN106933932A (en) | 2017-07-07 |
CN106933932B true CN106933932B (en) | 2020-11-06 |
Family
ID=59444692
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201511033240.2A Active CN106933932B (en) | 2015-12-31 | 2015-12-31 | Data processing method, device and application server |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106933932B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110196895B (en) * | 2019-04-19 | 2022-05-17 | 平安科技(深圳)有限公司 | User data information self-service query method and device, computer equipment and storage medium |
CN111652781A (en) * | 2020-06-01 | 2020-09-11 | 阿里巴巴集团控股有限公司 | Service processing method, device, equipment and storage medium based on community codes |
CN112435004A (en) * | 2020-11-20 | 2021-03-02 | 金蝶软件(中国)有限公司 | Method and device for realizing service flow processing |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101039259A (en) * | 2006-03-17 | 2007-09-19 | 华为技术有限公司 | Method for controlling service of communication equipment and system thereof |
CN103747072A (en) * | 2013-12-30 | 2014-04-23 | 乐视网信息技术(北京)股份有限公司 | Data reading and writing method and application server |
Family Cites Families (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8571791B2 (en) * | 2009-07-29 | 2013-10-29 | Searete Llc | Remote processing of selected vehicle operating parameters |
US8621072B2 (en) * | 2011-12-06 | 2013-12-31 | Microsoft Corporation | Providing notification of document repository events to external systems |
WO2015085507A1 (en) * | 2013-12-11 | 2015-06-18 | 华为技术有限公司 | Data storage method, data processing method and device, and mobile terminal |
CN104636437B (en) * | 2014-12-31 | 2018-06-05 | 华为技术有限公司 | A kind of processing method and processing device of event notification method, monitor |
-
2015
- 2015-12-31 CN CN201511033240.2A patent/CN106933932B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101039259A (en) * | 2006-03-17 | 2007-09-19 | 华为技术有限公司 | Method for controlling service of communication equipment and system thereof |
CN103747072A (en) * | 2013-12-30 | 2014-04-23 | 乐视网信息技术(北京)股份有限公司 | Data reading and writing method and application server |
Also Published As
Publication number | Publication date |
---|---|
CN106933932A (en) | 2017-07-07 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
KR101802264B1 (en) | Method for sharing virtual sim card by multiple terminals, terminals, server, and system | |
US20160321628A1 (en) | Online payment method, system, and apparatus | |
US20200021963A1 (en) | Communication Identifier Binding Processing Method and Terminal | |
CN103577757A (en) | Virus defending method and device | |
CN110335022A (en) | Automatic audit method, device, equipment and storage medium | |
CN110471884A (en) | Data managing method, device, equipment, system and computer readable storage medium | |
CN106933932B (en) | Data processing method, device and application server | |
WO2022062661A1 (en) | Operation notification method and apparatus, and storage medium and electronic apparatus | |
CN110674153B (en) | Data consistency detection method and device and electronic equipment | |
CN110096547A (en) | Supply synchronous method, device, computer equipment and the computer storage medium of data | |
US11243979B1 (en) | Asynchronous propagation of database events | |
CN112733001A (en) | Method and device for acquiring subscription information and electronic equipment | |
CN111355765B (en) | A method and device for processing and sending network requests | |
CN109391658B (en) | Account data synchronization method and equipment, storage medium and terminal thereof | |
CN111294377A (en) | Network request sending method of dependency relationship, terminal device and storage medium | |
CN111045725B (en) | Control method and device of code management system and storage medium | |
CN106375551B (en) | Information interaction method, device and terminal | |
CN114595069B (en) | Service offline method and device, electronic equipment and storage medium | |
US20150120607A1 (en) | System and method for customer event email consolidation and delivery | |
CN113867778B (en) | Image file generation method and device, electronic equipment and storage medium | |
CN118210799A (en) | Index switching method, device and computer readable storage medium | |
CN114866970A (en) | Policy control method, system and related equipment | |
CN111506571A (en) | Management method, device and equipment of short link data and storage medium | |
CN114676288A (en) | ID pull-through method and device | |
CN111061576A (en) | A method and system for creating an entity object |
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 | ||
TA01 | Transfer of patent application right | ||
TA01 | Transfer of patent application right |
Effective date of registration: 20200214 Address after: 518129 Bantian HUAWEI headquarters office building, Longgang District, Guangdong, Shenzhen Applicant after: HUAWEI TECHNOLOGIES Co.,Ltd. Address before: 210012 HUAWEI Nanjing base, 101 software Avenue, Yuhuatai District, Jiangsu, Nanjing Applicant before: Huawei Technologies Co.,Ltd. |
|
GR01 | Patent grant | ||
GR01 | Patent grant |