CN104679596A - Message processing method and system for improving concurrence performance of server-side - Google Patents

Message processing method and system for improving concurrence performance of server-side Download PDF

Info

Publication number
CN104679596A
CN104679596A CN201310632566.1A CN201310632566A CN104679596A CN 104679596 A CN104679596 A CN 104679596A CN 201310632566 A CN201310632566 A CN 201310632566A CN 104679596 A CN104679596 A CN 104679596A
Authority
CN
China
Prior art keywords
message
data
thread
queue
message processing
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.)
Pending
Application number
CN201310632566.1A
Other languages
Chinese (zh)
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.)
Aisino Corp
Original Assignee
Aisino Corp
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 Aisino Corp filed Critical Aisino Corp
Priority to CN201310632566.1A priority Critical patent/CN104679596A/en
Publication of CN104679596A publication Critical patent/CN104679596A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/04Network architectures or network communication protocols for network security for providing a confidential data exchange among entities communicating through data packet networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)
  • Computer And Data Communications (AREA)

Abstract

The invention discloses a message processing method and system for improving the concurrence performance of a server-side. The message processing method comprises the steps of establishing a data receiving thread A, a message processing thread B and a message queue MQ, reading corresponding data, organizing the data into messages of certain format and inserting the messages into the tail portion of the message queue MQ when the data receiving thread A detects that data are readable, enabling the message processing thread B to circularly detect whether the message queue MQ is empty or not, taking out the messages at the head portion of the message queue MQ when the message queue MQ is not empty and analyzing, saving and encrypting unrelated data. By means of the message processing method, efficient response can be achieved, and the data encryption requirement in a high concurrency state can be met.

Description

A kind of message treatment method and system thereof improving server end concurrency performance
Technical field
The present invention relates to data encryption technology field, particularly a kind of message treatment method improving data encryption system server end concurrency performance.
Background technology
Concentrating type data encryption equipment a kind ofly encrypts the system of various data for accurate recording, and system is made up of data server, data encryption equipment cluster, as shown in Figure 1.Whole system adopts the C/S model network architecture, and wherein data server is as the server end in C/S model, and data transmitting equipment and data encryption equipment are then the client in C/S model.Data server process, from the message of client, stores combined data simultaneously, and data encryption equipment cluster, for recording data and to data encryption, generates and returns to the enciphered message of data sending terminal unique identification data.
For a data encryption process, data server needs the data of preserving to comprise relevant two classes irrelevant with data encryption of data encryption.The data that wherein data encryption is correlated with refer to that needing to be sent to encryption device by data server carries out calculating the data obtaining enciphered message.The data that data encryption has nothing to do refer to the some other related data not needing to be sent to data encryption equipment.
The course of work of system is as follows: data transmitting equipment sends data to data server, data server stores data, encryption related data is sent to certain data encryption equipment in data encryption equipment cluster simultaneously, the enciphered message of generation is returned to data server by data encryption equipment, enciphered message is returned to data transmitting equipment by data server, the enciphered message that simultaneously more these data are corresponding in new database.
A kind of application scenarios of this system is the source of tax revenue data acquisition of retailing enterprise.In such a scenario, make out an invoice end in the POS foreground that data transmitting equipment is enterprise, data encryption equipment storage inside electronic invoice number, data encryption information is the information such as tax-control code, invoice codes, invoice number.All POS end of making out an invoice is connected to data server by network concurrent, often complete a transaction record, before printing receipt or invoice, related data (commodity detail, Payment Details etc.) is sent to data server, data server record transaction data, and the encryption related datas such as Amount in Total are sent to data encryption equipment acquisition tax information.Because the real-time of Shang Chao enterprise to data processing has strict requirement, simultaneously relatively high in the concurrency of transaction peak period, therefore, be necessary to design a kind of method, make data server can the process of the real-time high-efficiency request of holding from POS.
Summary of the invention
Fundamental purpose of the present invention is to provide a kind of message treatment method and the system thereof that improve server end concurrency performance, to solve problem existing in above-mentioned prior art, reaches the data encryption request under efficient response, high concurrent state.
In order to achieve the above object, the invention provides a kind of message treatment method improving server end concurrency performance, it comprises: set up data receiver thread A, set up Message Processing thread B and message queue MQ; When data receiver thread A detects that data are readable, read corresponding data, and organize data into the message of certain format, message is inserted the afterbody of message queue MQ, whether Message Processing thread B cycle detection message queue MQ is empty, when message queue MQ is not empty, take out the message of message queue MQ head, resolve and preserve encryption extraneous data.
Wherein, by the combination of IP+ port, determine message source to enable Message Processing thread B.
Wherein, described Message Processing thread B takes out the message being positioned at team's head, extract the message source of message, binary data, length and CRC information, whether legal according to these information check message, then binary data is resolved, preserve and resolve binary data result to database, and according to real processing results tissue response data, finally by response data rreturn value message source.
Wherein, described data receiver thread A and described Message Processing thread B is synchronous working.
Wherein, by creating a mutex CMutex, described data receiver thread A and described Message Processing thread B is made to be synchronous working.
In order to achieve the above object, the present invention also provides a kind of message handling system improving server end concurrency performance, it comprises data transmitting equipment, data server and data encryption equipment cluster, described data encryption equipment cluster is the set of multiple data encryption equipment, between communicated with data server by TCP network, data server adopts the mode of thread pool, and it comprises data receiver thread A, Message Processing thread B and message queue MQ; When data receiver thread A detects that data are readable, read corresponding data, and organize data into the message of certain format, message is inserted the afterbody of message queue MQ, whether Message Processing thread B cycle detection message queue MQ is empty, when message queue MQ is not empty, take out the message of message queue MQ head, resolve and preserve encryption extraneous data.
Wherein, described data server adopts queue data structure to preserve message, described queue data structure is the linear list that in STL is special, deletion action can be carried out in the front end of linear list, and update is carried out in the rear end of linear list, the message inserted at first is always removed deletion at first, and the message finally inserted finally will be removed deletion.
Wherein, by the combination of IP+ port, determine message source to enable Message Processing thread B.
Wherein, described data receiver thread A and described Message Processing thread B is synchronous working.
Wherein, by creating a mutex CMutex, described data receiver thread A and described Message Processing thread B is made to be synchronous working.
Compared with prior art, the invention has the advantages that:
It is short that data transmitting equipment waits for that enciphered message postpones: because the transition of operation of data being preserved has arrived in independent thread, the performance of data server network data is greatly improved, postpone almost negligible in LAN (Local Area Network), the delay of such data encryption equals the time needed for data encryption equipment hardware encipher substantially, so just to be dropped to the times to be encrypted such as data transmitting equipment minimum.
Data server utilization factor is high: the raising of concurrency performance makes same data server can manage more data encryption equipment and data transmitting equipment, while making to increase data encryption equipment and data transmitting equipment, the not corresponding increase of data server quantity, effectively reduces the cost of enterprise.
Accompanying drawing explanation
Fig. 1 is the concentrating type data encryption system schematic diagram of prior art;
Fig. 2 is a kind of process flow diagram improving the message treatment method of server end concurrency performance of one embodiment of the invention;
Fig. 3 is a kind of encryption extraneous data queue figure improving the message handling system of server end concurrency performance of one embodiment of the invention.
Embodiment
Below in conjunction with accompanying drawing, to above-mentioned being described in more detail with other technical characteristic and advantage of the present invention.
Whole system of the present invention adopts Transmission Control Protocol to communicate.Data server monitors the connection from data transmitting equipment and data encryption equipment at two different ports respectively, sets up two corresponding threads, in order to check from the data interaction on data transmitting equipment and data encryption equipment simultaneously.
For the data interaction between data transmitting equipment and data server, the thread supposing corresponding reception data is thread A, whether thread A cycle detection has the data from data transmitting equipment, when having detected that data are readable, thread A receives data, preserves data to data storehouse, then sends data to data encryption equipment.
Owing to resolve and to preserve the operation in data to data storehouse more consuming time comparatively speaking, if so carry out the operation of preserving data to data storehouse in thread A, when the equipment of concurrent transmission data is more, the method of this Message Processing will have a strong impact on data server to the reception of data and process, especially the wait timeout after data sending terminal sends data arranges and talks about improperly, if again send data to data server after wait timeout, the vicious cycle of data server process data delay will be caused in this case.
The solution of the present invention is on the basis of thread A, increases a corresponding thread B and message queue MQ.When thread A detects that data are readable, read corresponding data, and organize data into the message of certain format, message is inserted the afterbody of queue MQ.Whether thread B cycle detection message queue MQ is empty, when MQ is not empty, takes out the message of MQ head, resolves and preserves encryption extraneous data.Flow chart of data processing as shown in Figure 2.
A kind of message treatment method process flow diagram improving server end concurrency performance that Fig. 2 provides for the embodiment of the present invention, message treatment method of the present invention sets up data receiver thread A, sets up Message Processing thread B and message queue MQ; When data receiver thread A detects that data are readable, read corresponding data, and organize data into the message of certain format, message is inserted the afterbody of message queue MQ, whether Message Processing thread B cycle detection message queue MQ is empty, when message queue MQ is not empty, take out the message of message queue MQ head, resolve and preserve encryption extraneous data.
The present invention also provides a kind of message handling system improving server end concurrency performance, it comprises data transmitting equipment, data server and data encryption equipment cluster, described data encryption equipment cluster is the set of multiple data encryption equipment, between communicated with data server by TCP network, every platform data encryption equipment all has a TCP to be connected with data server, therefore, every platform encryption device all can the combination of a corresponding IP address and port, and relative to other data encryption equipments, the combination of this IP address and port is unique.Data server program, by the IP of data encryption equipment, port and some other information, is kept in a map structure in internal memory.
Data server adopts the mode of thread pool (ThreadPool), whether each TCP connection of poll there are data to arrive, when the data from data transmitting equipment being detected, receive data, then be message by the data encapsulation received, message be saved to the tail of the queue of message queue.After data server processing messages, need result to return to data transmitting equipment, therefore, Message Processing thread needs the source can determining message, and the combination of IP+ port uniquely can determine message source.(consulting table 1)
Table 1 message format:
Consulting Fig. 3, is a kind of encryption extraneous data queue figure improving the message handling system of server end concurrency performance that the embodiment of the present invention provides, and data server adopts queue data structure to preserve message.Queue is the linear list that in STL is special, and it can carry out deletion action in the front end of linear list, and carries out update in the rear end of linear list.The rear end of carrying out update is called tail of the queue, and the front end of carrying out deletion action becomes team's head.The message inserted at first is always removed deletion at first, and the message finally inserted finally will be removed deletion.
First Message Processing thread checks whether message queue is empty, if be not empty, then take out the message being positioned at team's head, extract the message source of message, binary data, length and CRC information, whether legal according to these information check message, then resolve binary data, preserve and resolve binary data result to database, and according to real processing results tissue response data, finally by response data rreturn value message source.
Because data receiver thread (thread A) inserts message to message queue MQ, Message Processing thread (thread B) takes out message from message queue MQ, therefore, needs to carry out synchronous working, prevent message queue from causing confusion between two threads.For this reason, create a mutex CMutex, no matter be that message inserts thread or Message Processing thread, before to message queue operation, need first to get mutex; After end of operation, discharge mutex immediately.Code between acquisition and release mutex is accomplished to simplify most as far as possible, namely reduces the holding time at every turn operated mutex as far as possible.
Delaying the abnormal conditions such as machine owing to may there is power down or server, is the integrality ensureing data, takes binary file and preserves the strategy that data and Message queue synchronously carry out.Principle of work is: after tax control server receives be-encrypted data, encryption related data is sent to encryption device and is encrypted, and data is inserted message queue tail of the queue simultaneously, and preserves a copy to binary file.After message queue processes a piece of news, the pointer of corresponding mobile binary file, and the pointer preserving binary file is in another file.If there is abnormal conditions such as power down, when again starting shooting, tax control server reads out current location, and data still untreated in binary file are read in message queue, to process.
In sum, tool of the present invention has the following advantages:
It is short that data transmitting equipment waits for that enciphered message postpones: because the transition of operation of data being preserved has arrived in independent thread, the performance of data server network data is greatly improved, postpone almost negligible in LAN (Local Area Network), the delay of such data encryption equals the time needed for data encryption equipment hardware encipher substantially, so just to be dropped to the times to be encrypted such as data transmitting equipment minimum.
Data server utilization factor is high: the raising of concurrency performance makes same data server can manage more data encryption equipment and data transmitting equipment, while making to increase data encryption equipment and data transmitting equipment, the not corresponding increase of data server quantity, effectively reduces the cost of enterprise.
More than illustrate just illustrative for the purpose of the present invention; and nonrestrictive, those of ordinary skill in the art understand, when not departing from the spirit and scope that claim limits; many amendments, change or equivalence can be made, but all will fall within protection scope of the present invention.

Claims (10)

1. improve a message treatment method for server end concurrency performance, it is characterized in that, it comprises: set up data receiver thread A, set up Message Processing thread B and message queue MQ; When data receiver thread A detects that data are readable, read corresponding data, and organize data into the message of certain format, message is inserted the afterbody of message queue MQ, whether Message Processing thread B cycle detection message queue MQ is empty, when message queue MQ is not empty, take out the message of message queue MQ head, resolve and preserve encryption extraneous data.
2. a kind of message treatment method improving server end concurrency performance according to claim 1, is characterized in that, by the combination of IP+ port, determines message source to enable Message Processing thread B.
3. a kind of message treatment method improving server end concurrency performance according to claim 1, it is characterized in that, described Message Processing thread B takes out the message being positioned at team's head, extract the message source of message, binary data, length and CRC information, whether legal according to these information check message, then resolve binary data, preserve and resolve binary data result to database, and according to real processing results tissue response data, finally by response data rreturn value message source.
4. a kind of message treatment method improving server end concurrency performance according to claim 1, is characterized in that, described data receiver thread A and described Message Processing thread B is synchronous working.
5. a kind of message treatment method improving server end concurrency performance according to claim 4, is characterized in that, by creating a mutex CMutex, makes described data receiver thread A and described Message Processing thread B be synchronous working.
6. one kind is improved the message handling system of server end concurrency performance, it is characterized in that, it comprises data transmitting equipment, data server and data encryption equipment cluster, described data encryption equipment cluster is the set of multiple data encryption equipment, between communicated with data server by TCP network, data server adopts the mode of thread pool, and it comprises data receiver thread A, Message Processing thread B and message queue MQ; When data receiver thread A detects that data are readable, read corresponding data, and organize data into the message of certain format, message is inserted the afterbody of message queue MQ, whether Message Processing thread B cycle detection message queue MQ is empty, when message queue MQ is not empty, take out the message of message queue MQ head, resolve and preserve encryption extraneous data.
7. a kind of message handling system improving server end concurrency performance according to claim 6, it is characterized in that, described data server adopts queue data structure to preserve message, described queue data structure is the linear list that in STL is special, deletion action can be carried out in the front end of linear list, and update is carried out in the rear end of linear list, the message inserted at first is always removed deletion at first, and the message finally inserted finally will be removed deletion.
8. a kind of message treatment method improving server end concurrency performance according to claim 1, is characterized in that, by the combination of IP+ port, determines message source to enable Message Processing thread B.
9. a kind of message handling system improving server end concurrency performance according to claim 6, is characterized in that, described data receiver thread A and described Message Processing thread B is synchronous working.
10. a kind of message treatment method improving server end concurrency performance according to claim 9, is characterized in that, by creating a mutex CMutex, makes described data receiver thread A and described Message Processing thread B be synchronous working.
CN201310632566.1A 2013-12-02 2013-12-02 Message processing method and system for improving concurrence performance of server-side Pending CN104679596A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310632566.1A CN104679596A (en) 2013-12-02 2013-12-02 Message processing method and system for improving concurrence performance of server-side

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310632566.1A CN104679596A (en) 2013-12-02 2013-12-02 Message processing method and system for improving concurrence performance of server-side

Publications (1)

Publication Number Publication Date
CN104679596A true CN104679596A (en) 2015-06-03

Family

ID=53314687

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310632566.1A Pending CN104679596A (en) 2013-12-02 2013-12-02 Message processing method and system for improving concurrence performance of server-side

Country Status (1)

Country Link
CN (1) CN104679596A (en)

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105938438A (en) * 2015-11-24 2016-09-14 杭州迪普科技有限公司 Processing method and device for data messages
CN107391657A (en) * 2017-07-18 2017-11-24 百望电子发票数据服务有限公司 A kind of method and system for generating electronic invoice layout files
CN107678856A (en) * 2017-09-20 2018-02-09 苏宁云商集团股份有限公司 The method and device of increment information in a kind of processing business entity
CN107958398A (en) * 2016-10-14 2018-04-24 北京京东尚科信息技术有限公司 A kind of method and system to issue invoice
CN108009005A (en) * 2016-10-31 2018-05-08 北京优朋普乐科技有限公司 A kind of thread pool management method and device
CN108243220A (en) * 2016-12-26 2018-07-03 航天信息股份有限公司 A kind of invoice issuing method and system of the support polymorphic type invoice terminal based on tax control server
CN108667725A (en) * 2018-04-25 2018-10-16 哈尔滨电气股份有限公司 A kind of industrial AnyRouter and implementation method based on a variety of accesses and edge calculations
CN111737030A (en) * 2020-06-24 2020-10-02 广东浪潮大数据研究有限公司 Control instruction processing method, device and equipment and computer storage medium
CN115118676A (en) * 2022-08-29 2022-09-27 科来网络技术股份有限公司 Heterogeneous system data communication interaction method, system and terminal based on central platform

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030159083A1 (en) * 2000-09-29 2003-08-21 Fukuhara Keith T. System, method and apparatus for data processing and storage to provide continuous operations independent of device failure or disaster
CN1561043A (en) * 2004-02-20 2005-01-05 中兴通讯股份有限公司 Multi-user concurrent insertion device and its method
CN101540780A (en) * 2004-12-29 2009-09-23 国家广播电影电视总局广播科学研究院 Processing method of data request message based on data/video service system
CN101567873A (en) * 2008-04-25 2009-10-28 凤凰微电子(中国)有限公司 Multitask Parallel processing method and multitask parallel processing system
CN102360307A (en) * 2011-08-17 2012-02-22 中兴通讯股份有限公司 Device driver message processing method and device
US20130041969A1 (en) * 2011-05-16 2013-02-14 Oracle International Corporation System and method for providing a messaging application program interface

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030159083A1 (en) * 2000-09-29 2003-08-21 Fukuhara Keith T. System, method and apparatus for data processing and storage to provide continuous operations independent of device failure or disaster
CN1561043A (en) * 2004-02-20 2005-01-05 中兴通讯股份有限公司 Multi-user concurrent insertion device and its method
CN101540780A (en) * 2004-12-29 2009-09-23 国家广播电影电视总局广播科学研究院 Processing method of data request message based on data/video service system
CN101567873A (en) * 2008-04-25 2009-10-28 凤凰微电子(中国)有限公司 Multitask Parallel processing method and multitask parallel processing system
US20130041969A1 (en) * 2011-05-16 2013-02-14 Oracle International Corporation System and method for providing a messaging application program interface
CN102360307A (en) * 2011-08-17 2012-02-22 中兴通讯股份有限公司 Device driver message processing method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
单芳芳等: "面向集群的数据加密系统", 《微计算机信息》 *

Cited By (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105938438A (en) * 2015-11-24 2016-09-14 杭州迪普科技有限公司 Processing method and device for data messages
CN107958398A (en) * 2016-10-14 2018-04-24 北京京东尚科信息技术有限公司 A kind of method and system to issue invoice
CN108009005A (en) * 2016-10-31 2018-05-08 北京优朋普乐科技有限公司 A kind of thread pool management method and device
CN108243220A (en) * 2016-12-26 2018-07-03 航天信息股份有限公司 A kind of invoice issuing method and system of the support polymorphic type invoice terminal based on tax control server
CN108243220B (en) * 2016-12-26 2021-04-16 航天信息股份有限公司 Tax control server-based invoice issuing method and system supporting multi-type invoice terminal
CN107391657A (en) * 2017-07-18 2017-11-24 百望电子发票数据服务有限公司 A kind of method and system for generating electronic invoice layout files
CN107678856A (en) * 2017-09-20 2018-02-09 苏宁云商集团股份有限公司 The method and device of increment information in a kind of processing business entity
CN108667725A (en) * 2018-04-25 2018-10-16 哈尔滨电气股份有限公司 A kind of industrial AnyRouter and implementation method based on a variety of accesses and edge calculations
CN111737030A (en) * 2020-06-24 2020-10-02 广东浪潮大数据研究有限公司 Control instruction processing method, device and equipment and computer storage medium
WO2021258750A1 (en) * 2020-06-24 2021-12-30 广东浪潮智慧计算技术有限公司 Control instruction processing method, apparatus and device, and computer storage medium
CN115118676A (en) * 2022-08-29 2022-09-27 科来网络技术股份有限公司 Heterogeneous system data communication interaction method, system and terminal based on central platform

Similar Documents

Publication Publication Date Title
CN104679596A (en) Message processing method and system for improving concurrence performance of server-side
CN101873259B (en) SCTP (Stream Control Transmission Protocol) message identification method and device
CN104092717A (en) Message processing method and system, message destination end device and distributed message system
US20200192718A1 (en) Method and device for handling multi-tenant request
CN101877659A (en) Method, device and system for monitoring packet loss
CN107798039B (en) Data synchronization method and device
CN113835902B (en) Data processing method, device, computer equipment and storage medium
CN104796327A (en) Message receiving method and device and message transmitting method and system
CN106034113A (en) Data processing method and data processing device
CN105162702A (en) AC current guide method and device
CN102497427A (en) Method and device for realizing data acquisition services of renewable energy source monitoring system
CN106997394B (en) A kind of data random ordering arrival processing method and system
CN104243610A (en) Distributed file transmission service method
CN102497297A (en) System and method for realizing deep packet inspection technology based on multi-core and multi-thread
CN105302486A (en) Virtual offline desktop block device storage synchronization method
CN111367916B (en) Data storage method and device
CN102523112B (en) Information processing method and equipment
CN110932393B (en) Substation information protection master station system and data initialization method thereof
EP2690560A2 (en) Method of benchmarking the behaviour of a replacement information system with the old system
CN101827068A (en) Business scenario reduction method and device
CN102427405A (en) Ticket association method, system and associated equipment thereof
CN104468569A (en) Integrity detection method and device of distributed data
CN114785805A (en) Data transmission method and device, electronic equipment and storage medium
CN113132273B (en) Data forwarding method and device
CN105656769A (en) Service data processing method, apparatus and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication
RJ01 Rejection of invention patent application after publication

Application publication date: 20150603