Disclosure of Invention
In view of the above, an aspect of the present invention provides a system for recording a ticket, which can reduce the time of call queuing.
The invention also provides a system for recording the call ticket, which can reduce the waiting time of call queuing.
The invention finally provides a method for recording the call ticket, and the method can reduce the time of call queuing and waiting.
The first system for recording the call ticket provided by the invention is realized by the following technical scheme:
the system comprises: at least one service unit and a call ticket data storage unit, wherein the service unit comprises:
the service operation module is used for recording the call ticket of the operated service and outputting the recorded call ticket data to the cache module;
the buffer module is used for buffering the ticket data output by the service operation module;
the sending module is used for reading the cached ticket data from the caching module and sending the ticket data to the ticket data storage unit;
the call ticket data storage unit comprises:
a receiving module for receiving the call ticket data from the sending module and outputting the call ticket data;
a call ticket writing module for receiving call ticket data and storing the call ticket data in a database or a file;
wherein,
the sending module comprises: a sending submodule and a connection monitoring submodule;
the receiving module includes: a receiving submodule and a monitoring submodule; and is
The connection monitoring submodule is used for sending a connection request to the monitoring submodule when the connection is initially established, and forwarding the ticket data of the sending submodule after the connection is established;
the sending submodule is used for sending the ticket data read from the cache module of the business unit to the receiving submodule through the connection monitoring submodule after the connection is successfully established; and is
The monitoring submodule is used for monitoring the connection request of the connection monitoring submodule and informing the receiving submodule to establish connection with the connection monitoring submodule after the connection request is monitored;
and the receiving submodule is used for establishing connection with the connection monitoring submodule according to the notice of the monitoring submodule, receiving the call ticket data forwarded by the connection monitoring submodule after the connection is successfully established, and outputting the received call ticket data to a call ticket writing module in a call ticket data storage unit.
Preferably, the call ticket data storage unit further comprises: the buffer module is used for outputting the received call ticket data to the buffer module in the call ticket data storage unit; the buffer module of the call ticket data storage unit is used for buffering the call ticket data output by the receiving module; and the ticket writing module is used for reading the ticket data from the cache module of the ticket data storage unit and storing the ticket data into a database or a file.
Preferably, the receiving module further comprises: the heartbeat detection sub-module is used for periodically sending a heartbeat detection request to the connection monitoring sub-module through the receiving sub-module when detecting that the receiving sub-module is connected with the connection monitoring sub-module, adding 1 to the number of unresponsive heartbeat times if the receiving sub-module does not receive the notification of the received heartbeat response signal in the period, detecting whether the number of unresponsive heartbeat times reaches a preset value, and notifying the receiving sub-module to disconnect the connection with the connection monitoring sub-module when the preset value is reached; if the notice is received in the period, setting the number of times of heartbeat unresponsiveness to 0, and restarting counting;
the connection monitoring sub-module is further configured to: after the connection is established, receiving a heartbeat detection request sent by a heartbeat detection submodule through a receiving submodule, generating a heartbeat response signal and sending the heartbeat response signal to the receiving submodule;
the receiving submodule is further configured to: after the connection is established, the heartbeat detection sub-module transmits a heartbeat detection request sent by the heartbeat detection sub-module to the connection monitoring sub-module, receives a heartbeat response signal from the connection monitoring sub-module, and sends a notice of the received heartbeat response signal to the heartbeat detection sub-module after receiving the heartbeat response signal.
Preferably, the sending module further comprises: and the alarm submodule is used for monitoring the condition that the call ticket data occupies the storage area in the cache module of the service unit at regular time, and sending alarm information when the proportion of the call ticket data occupying the storage area reaches a preset alarm point.
Preferably, the alarm sub-module is further configured to: and when the proportion of the storage area occupied by the ticket data reaches a preset recording point, writing the ticket data into a local ticket file.
Wherein, the cache module comprises: one or more circular queues; and each circular queue includes: a head of line pointer and a tail of line pointer, wherein,
the sending module reads the call ticket data from the position pointed by the head of line pointer of the circular queue in the service unit buffer module each time; the call ticket writing module reads call ticket data from a position pointed by a queue head pointer of a circular queue in the call ticket data storage unit caching module each time;
the service operation module stores the call list data into the position pointed by the queue tail pointer of the circular queue in the service unit buffer module each time; and the receiving module stores the call ticket data into the position pointed by the queue tail pointer of the circular queue in the call ticket data storage unit caching module each time.
The method for recording the call ticket provided by the invention is realized by the following technical scheme:
in a system for recording a ticket, the system for recording a ticket comprises: at least one service unit and a call ticket data storage unit, wherein the service unit comprises: the system comprises a service operation module, a cache module and a sending module, wherein the sending module comprises a connection monitoring submodule and a sending submodule; the call ticket data storage unit comprises: the system comprises a receiving module and a ticket writing module, wherein the receiving module comprises a receiving submodule and a monitoring submodule;
the method comprises the steps of (1) carrying out,
creating and initializing a buffer area in the buffer module, starting the sending module,
when the connection is initially established, the connection monitoring submodule sends a connection request to the monitoring submodule; the monitoring submodule monitors a connection request of the connection monitoring submodule, and informs the receiving submodule to establish connection with the connection monitoring submodule and continue monitoring after the connection request is monitored; the receiving submodule establishes connection with the connection monitoring submodule according to the notice of the monitoring submodule;
when a service occurs, the service operation module records the call ticket of the operated service and caches the recorded call ticket data to the cache module;
after the connection is successfully established, the sending submodule reads the cached call ticket data from the caching module and sends the call ticket data to the receiving submodule through the connection monitoring submodule; the receiving sub-module receives the call ticket data forwarded by the connection monitoring sub-module, and stores the received call ticket data in a database or a file through the call ticket writing module. The caching is as follows: storing the call ticket data into a cache region in a cache module; the reading of the cached ticket data is as follows: and reading the ticket data from the buffer area.
Wherein, the creating and initializing the cache area in the cache module comprises: designing the buffer area into one or more than one circular queues, wherein the head pointer of each circular queue points to the position to be read next, and the tail pointer points to the position to be written next;
the step of storing the ticket data into the cache area comprises the following steps: writing the ticket data into the position pointed by the circular queue tail pointer in the buffer area, and changing the queue tail pointer to point to the next position to be written;
the reading of the ticket data from the buffer area comprises the following steps: the ticket data is read from the position pointed by the circular queue head pointer in the buffer area, and the head of queue pointer is changed to point to the position to be read next.
Preferably, after reading the cached ticket data and before storing the ticket data in the database or the file, the method further includes: writing the received call ticket data into another buffer area; then, the ticket data is read from the cache area and stored in a database or a file.
Preferably, the method further comprises: the occupation condition of the call ticket data in the cache region is detected regularly, and when the proportion of the call ticket data occupying the cache region reaches a preset alarm point, alarm information is sent out; if the recording point exists, when the proportion of the storage area occupied by the call ticket data reaches the preset recording point, the alarm module writes the call ticket data into a local call ticket file.
According to the scheme, the recorded call ticket data is firstly cached, and then the cached call ticket data is stored in the database or the file, so that the asynchronous access to the service call ticket is realized, and the call queuing waiting time increased due to the time consumption of database operation or file I/O operation is avoided. Furthermore, after receiving the call ticket data and before writing the call ticket data into a database or a file, the system and the method ensure the smoothness of the call ticket data in the reading and sending processes, namely double asynchronous operation, fully reduce the time of call queuing waiting, avoid the occurrence of blocking and have no influence on the communication performance while recording the call ticket.
In addition, the buffer area is set into one or more than one circular queue, so that the buffer area can be recycled, and the plurality of circular queues are set, so that the blockage caused when a plurality of service ticket data are competitively written into one circular queue can be avoided; and the use condition of the cache region is supervised and alarmed by further setting an alarm link, so that smooth communication is ensured to the maximum extent, and the time of call queuing is shortened.
Therefore, the invention can reduce the waiting time of call queuing to the maximum extent, avoid the occurrence of blocking and the like and ensure the communication performance by adopting asynchronous thought and multiple protection measures.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is further described in detail with reference to the following examples.
The basic idea of the invention is: the recorded call ticket data is firstly cached, and then the cached call ticket data is stored in a database or a file, so that asynchronous operation of storing the service call ticket record and the call ticket data in the database or the file is realized, and the defects of call queuing waiting time delay, blocking and the like caused by time consumption of database operation or file I/O operation are avoided.
During specific implementation, the method can be realized by setting at least one service unit and one ticket data storage unit, wherein the service unit and the ticket data storage unit can be respectively arranged in two independent devices, and each service unit is used for caching the recorded ticket data and sending the cached ticket data to the ticket data storage unit; the call ticket data storage unit is used for receiving call ticket data from the service unit and storing the call ticket data into a database or a file, namely a system for recording call tickets. See in particular the embodiment shown in fig. 2.
In the implementation, the interaction is performed between the service unit and the call ticket data storage unit, and the service unit and the call ticket data storage unit can be located in two devices. When the traffic is less, the invention can also directly set the database or the file in the service unit, and only one service unit is needed to complete the process, and the service unit can comprise: the business operation module is used for outputting the recorded call ticket data to the cache module; the buffer module is used for buffering the ticket data output by the service operation module; and the ticket writing module is used for reading the ticket data from the cache module and storing the ticket data into a database or a file, namely a second system for recording the ticket. See in particular the embodiment shown in fig. 6.
Furthermore, the method provided by the invention can also be used for: caching the recorded call ticket data; and reading the cached call ticket data and storing the call ticket data into a database or a file. In practical applications, the method is implemented according to actual situations, and reference may also be made to the method in the embodiment shown in fig. 7 or fig. 8.
The first ticket recording system of the present invention is described in detail with reference to the embodiments.
Referring to fig. 2, fig. 2 is a schematic structural diagram of a system for recording a ticket in the embodiment of the present invention. As shown in fig. 2, the system includes: at least one service unit 200 and a call ticket data storage unit 210, which in this embodiment are n service units 200, where n is an integer greater than 1.
Each service unit 200 is configured to operate a communication service, record a call ticket of the operated service, buffer the recorded call ticket data, and then asynchronously read the buffered call ticket data and send the buffered call ticket data to the call ticket data storage unit 210. If the shared memory is created in advance, the recorded call ticket data is written into the shared memory, and then the cached call ticket data is asynchronously read from the shared memory and sent to the call ticket data storage unit 210.
The call ticket data storage unit 210 is configured to receive call ticket data from the service unit 200, and store the received call ticket data in a database or a file. In this embodiment, in order to prevent the ticket data sent by each service unit 200 from being blocked when being written into the database, a buffer link is set in the ticket data storage unit, that is, the received ticket data from the service unit 200 is buffered first and then stored into the database or the file.
Fig. 3 shows the internal structures of the service unit 200 and the ticket data storage unit 210, and fig. 3 is a schematic diagram of a system structure after the internal structures of the service unit 200 and the ticket data storage unit 210 are subdivided based on the embodiment shown in fig. 2.
Wherein the service unit 200 comprises: a service running module 201, a caching module 202 and a sending module 203.
The service operation module 201 is configured to operate a communication service, record a call ticket of the operated service, and output the recorded call ticket data to the cache module 202. Each service operation module 201 can represent an operation service, and in the operation process, each service operation module 201 can share the cache module 202 by calling the same interface component, and write call ticket data into the cache module 202; the writing of the ticket data into the cache module 202 can also be realized by packaging the interface components of the buffer module respectively. In this embodiment, there are m1 service operation modules in the service unit 1, and there are mn service operation modules in the service unit n, where m1, the.
The caching module 202 is configured to cache the ticket data output by the service operating module 201. The cache module 202 may be disposed in a memory and may include one or more circular queues, each circular queue including a head-of-line pointer and a tail-of-line pointer. Wherein the head of line pointer points to the next location to be read, the tail of line pointer points to the next location to be written, and the tail of line pointer occupies one character of the queue. When the head of line pointer and the tail of line pointer are the same, it indicates that the queue is empty. And when the head pointer is larger than the tail pointer and has a difference of 1 with the tail pointer, or the tail pointer has a difference of 1 with the head pointer, the length of the whole queue is reduced by 1, the queue is full.
As shown in fig. 4, fig. 4 is a schematic diagram illustrating a circular queue in the buffer module 202. Assuming that the data is filled in the counterclockwise direction as shown in fig. 4, the head of line pointer points to the next location to be read and the tail of line pointer points to the next location to be written. The service operation module 201 writes the ticket data into the tail of a circular queue, that is, the position pointed by the tail pointer, and the tail pointer changes to point to the next position to be written; the sending module 203 reads the ticket data from the head of a circular queue each time, that is, reads the ticket data from the position pointed by the head pointer, and the head pointer changes to point to the next position to be read. The operations on the circular queue in the buffer module 202 are not synchronous between writing and reading, but two independent processes, which operate according to the tail pointer and the head pointer respectively. The circular queue expresses the idea of circular access in a block of storage space, and does not mean that the physical structure of the storage space is circular.
In order to avoid blocking the write operation due to the buffer module 202 falling into a "full" state, the capacity of the buffer module 202 may be set to be large enough, because the total call amount of the communication system per day is basically equivalent, as long as the set buffer capacity is enough to store the call ticket data during the peak call period per day; or when the storage space is full, the service unit 200 dynamically applies for a new space and simulates one or more circular queues, and the sending module 203 reads data from the circular queues.
The sending module 203 is configured to read the cached ticket data from the caching module 202 and send the ticket data to the ticket data storage unit 210.
The ticket data storage unit 210 includes: a receiving module 211, a buffering module 212 and a ticket writing module 213.
The receiving module 211 is configured to receive the ticket data from the service unit 210 and output the ticket data to the caching module 212.
The buffer module 212 is configured to buffer the ticket data output by the receiving module 211. The cache module 212 here may be arranged in the same structure as the cache module 202 in the service unit 200.
And the ticket writing module 213 is configured to read the ticket data from the caching module 212 and store the ticket data in a database or a file.
The internal structure and connection relationship between the sending module 203 and the receiving module 211 used for completing the sending and receiving of the ticket data between the service unit 200 and the ticket data storage unit 210 are shown in fig. 5, referring to fig. 5, where the sending module 203 includes: a sending submodule and a connection monitoring submodule; the receiving module 211 includes: the device comprises a receiving submodule, a monitoring submodule and a heartbeat detection submodule. In order to monitor the storage condition of the caching module 202 so as to avoid situations such as blocking or data loss, an alarm sub-module is further provided in the sending module 203.
And the connection monitoring submodule is used for sending a connection request to the monitoring submodule, transmitting the ticket data of the sending submodule after connection is established, receiving the heartbeat detection request transmitted by the heartbeat detection submodule through the receiving submodule, generating a heartbeat response signal and sending the heartbeat response signal to the receiving submodule.
And the sending submodule is used for sending the ticket data read from the buffer module 202 to the receiving submodule through the connection monitoring submodule after the connection is successfully established.
The alarm submodule is used for regularly detecting the condition that the storage area is occupied by the call ticket data in the cache module 202, when the proportion of the storage area occupied by the call ticket data reaches a preset alarm point, alarm information is sent out, the alarm information can be sent out by writing an alarm log or sending out an alarm through interface information, a service unit 200 can dynamically apply for a new area for the cache module 202 according to the alarm information, and the new area is initialized into one or more than one circular queue; if a recording point is preset, when the proportion of the storage area occupied by the call ticket data reaches the preset recording point, the alarm sub-module also reads the call ticket data in the cache module 202 and writes the call ticket data into a local call ticket file, and then the part of the call ticket data is stored into a database or a file manually or by other preset modules.
And the monitoring submodule is used for monitoring the connection request of the connection monitoring submodule and informing the receiving submodule to establish connection with the connection monitoring submodule after monitoring the connection request.
The heartbeat detection sub-module is used for periodically sending a heartbeat detection request to the connection monitoring sub-module through the receiving sub-module when detecting that the receiving sub-module is connected with the connection monitoring sub-module, adding 1 to the number of heartbeat unresponsive times corresponding to the connection monitoring sub-module if the receiving sub-module does not receive the notification of the received heartbeat response signal from the receiving sub-module in the period, detecting whether the number of heartbeat unresponsive times reaches a preset value or not, and notifying the receiving sub-module to disconnect the connection with the connection monitoring sub-module if the number of heartbeat unresponsive times reaches the preset value; and if the notice is received in the period, setting the number of the heartbeat unresponsive times corresponding to the connection monitoring submodule to be 0, and restarting counting.
The receiving submodule is used for establishing connection with the connection monitoring submodule according to the notice of the monitoring submodule when the connection is initially established, receiving the call ticket data and the heartbeat response signal which are sent by the connection monitoring submodule after the connection is successfully established, and sending the notice of the received heartbeat response signal to the heartbeat detection submodule after the heartbeat response signal is received; after receiving the ticket data, the ticket data is output to the buffer module 212 in the ticket data storage unit 210. And forwarding the heartbeat detection request to the heartbeat detection request of the connection monitoring submodule by the heartbeat detection submodule.
The above is a description of an embodiment of the first system for recording a ticket according to the present invention, and the following is a detailed description of the second system for recording a ticket according to the present invention in combination with the embodiment.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a second system for recording a ticket according to an embodiment of the present invention. As shown in fig. 6, the system includes: the system comprises a service operation module, a cache module and a ticket writing module.
And the service operation module is used for operating the communication service, recording the call ticket of the operated service and outputting the recorded call ticket data to the cache module. Each service operation module can represent one service to be operated, and each service operation module can share the cache module by calling the same interface component in the operation process and write call ticket data into the cache module; and ticket data can be written into the cache module by packaging the interface components of the buffer module respectively.
And the buffer module is used for buffering the ticket data output by the service operation module. The cache module may be configured in the same structure as the cache module 202 in the service unit 200 of the embodiment shown in fig. 2.
And the ticket writing module is used for reading the ticket data from the cache module and storing the ticket data into a database or a file.
In addition, the system of this embodiment may further include an alarm module, configured to detect a situation that the storage area is occupied by the ticket data in the cache module at regular time, and when a proportion of the storage area occupied by the ticket data reaches a preset alarm point, send an alarm message, where the alarm message may be sent by writing an alarm log, or may be sent by an interface message alarm, and according to the alarm message, a new area may be dynamically applied for the cache module by an interface component of the service operation module, or a new area may be dynamically applied in other manners, and the new area is initialized to one or more than one circular queues; if a recording point is preset, when the proportion of the storage area occupied by the call ticket data reaches the preset recording point, the alarm module also reads the call ticket data in the cache module and writes the call ticket data into a local call ticket file, and then the call ticket data is stored into a database or a file manually or by other preset modules.
The following describes the method for recording a ticket in the present invention in detail with reference to the embodiments.
The first embodiment is as follows:
the method in the embodiment is realized based on a first system for recording the call ticket, in the embodiment, the call ticket recording is completed by a service operation module, call-loaded interface components are used for writing call ticket data into a cache region, a sending module is responsible for establishing connection with an external call ticket data storage unit, reading the call ticket data from the cache region and sending the call ticket data to the call ticket data storage unit, the call ticket data storage unit is arranged in a single server host, and an internal receiving module is used for completing interaction with the sending module and receiving of the call ticket data. Wherein, the buffer area is created by the interface component loaded by the service operation module or created by the sending module.
Referring to fig. 7, fig. 7 is a flowchart of a method for recording call tickets according to a first embodiment of the present invention. As shown in fig. 7, the process includes the following steps:
step 701, creating and initializing a cache region.
In this step, the cache region may be created in advance, or may be created by calling a loaded interface component when the service operation module initially operates and stores the phone bill data, or may be created by the sending module, and the cache region may be set in the memory. These two ways of creation are described in detail below, respectively.
Creation of an interface component loaded by a service execution module: when the service operation module calls an interface function of the interface component for the first time, the operating system loads the interface component into the service operation module, and in the process of loading, the interface component creates a shared memory area, namely a cache area for caching the call ticket data is created by the interface component, and the cache area is initialized into one or more than one circular queues, wherein each circular queue comprises a queue head pointer and a queue tail pointer. Wherein the head of line pointer points to the next location to be read, the tail of line pointer points to the next location to be written, and the tail of line pointer occupies one character of the queue. And then executes the interface function provided by the interface component.
When the sending module is started, the sending module firstly opens the shared memory area created by the interface component, and initializes the shared memory area into one or more than one circular queues in the same way as the interface component.
Creating, by a sending module: firstly, a sending module is started, the sending module creates a shared memory area, namely, the sending module creates a buffer area for buffering the ticket data, and the buffer area is initialized into one or more than one circular queue, wherein each circular queue comprises a queue head pointer and a queue tail pointer. Wherein the head of line pointer points to the next location to be read, the tail of line pointer points to the next location to be written, and the tail of line pointer occupies one character of the queue.
When the service operation module calls the interface function of the interface component for the first time, the operating system loads the interface component into the service operation module, and in the process of loading, the interface component opens the shared memory area created by the sending module, initializes the shared memory area into one or more than one circular queue in the same way as the sending module, and then executes the interface function provided by the interface component.
Wherein initializing the shared memory area into one or more circular queues means: the corresponding address space corresponds to the address space of the circular queue according to one or more than one circular queue form, so that the circular queue of the shared memory area can be operated conveniently.
And then, when the service operation module calls the interface function of the interface component again, the loading process is not executed any more, and only the operation provided by the interface function is executed. When the other service operation module calls the interface function of the interface component, the interface component is loaded into the other service operation module, the shared memory area initially created by the interface component is opened, and the corresponding address space corresponds to the address space of the interface component according to the same form of one or more than one circular queues.
Wherein, when the head of line pointer and the tail of line pointer are the same, it indicates that the queue is empty. And when the head pointer is larger than the tail pointer and has a difference of 1 with the tail pointer, or the tail pointer has a difference of 1 with the head pointer, the length of the whole queue is reduced by 1, the queue is full. The operation of the circular queue in the buffer area is not synchronous between writing and reading, but two independent processes are used for operating according to the pointer at the tail end and the head end of the queue respectively. The circular queue expresses the idea of circular access in a block of storage space, and does not mean that the physical structure of the storage space is circular.
Step 702, recording the call ticket of the running service, and storing the recorded call ticket data into a buffer area.
In this step, the service operation module records the ticket of the operated service, and writes the recorded ticket data into the tail of the circular queue through calling the interface function of the interface component, that is, the position pointed by the write-in tail pointer, and at this time, the tail pointer changes to point to the next position to be written.
If the interface component loaded by the service running module is used to create the cache region in step 701, this step may be executed as long as the cache region is not full even if the sending module is not started at this time. Certainly, in order to ensure that the buffer area has enough space, the sending module should be started as early as possible, so as to take out the data from the buffer area in time and send the data to the call ticket data storage unit.
Step 703, reading the cached ticket data from the caching area and sending the ticket data to a ticket data storage unit.
The operations in this step may be performed by the sending module. Or the sending module may include other sub-modules such as a connection monitoring sub-module, a sending sub-module, and an alarm sub-module. After the initialization of the buffer area is completed, the three sub-modules may be started.
The connection monitoring submodule is firstly connected with a receiving module in a call ticket data storage unit and uses TCP/IP to communicate. In the process of establishing connection, the connection monitoring submodule sends a TCP/IP connection request to the receiving module, continuously receives a heartbeat detection request from the receiving module after the receiving module responds and establishes connection, generates a heartbeat response signal and sends the heartbeat response signal to the receiving module. When the connection is abnormally disconnected, the connection request is resent, and the function of maintaining the connection is achieved.
After the connection is successfully established, the sending sub-module continuously reads the ticket data from the head of the circular queue in the buffer area, namely reads the ticket data from the position pointed by the pointer of the head of the circular queue, and sends the ticket data to the receiving module through the connection monitoring sub-module with the established connection. At this point the head of line pointer changes to point to the next location to be read.
The alarm submodule can detect the condition of the occupation of the call ticket data in the circular queue at regular time, when the proportion of the call ticket data occupying the circular queue reaches a preset alarm point, alarm information is sent out, the alarm information can be sent out by writing an alarm log or sending out an alarm through interface information, a sending module or an interface component can dynamically apply for a new region for a cache region according to the alarm information, and the new region is initialized into one or more than one circular queues; if a recording point is preset, when the proportion of the call ticket data occupying the circular queue reaches the preset recording point, the alarm sub-module also reads the call ticket data in the circular queue and writes the call ticket data into a local call ticket file, and then the part of the call ticket data is stored into a database or a file manually or by other preset modules.
Step 704, the call ticket data storage unit receives the call ticket data and stores the received data in a database or a file.
The call ticket data storage unit in this step may include: the device comprises a receiving module and a ticket writing module. The receiving module receives the call ticket data and then sends the call ticket data to the call ticket writing module, and the call ticket writing module stores the call ticket data from the receiving module into a database or a file. In addition, in order to prevent queue waiting or blocking and the like caused by directly writing the received data into a database or a file, a buffer area can be set in the call ticket data storage unit, the buffer area can be created by the receiving module when the receiving module is started, and the buffer area can also be initialized into a circular queue form so as to buffer the received call ticket data in advance. Wherein, the receiving module may further include: the device comprises a monitoring submodule, a heartbeat detection submodule and a receiving submodule.
The monitoring submodule monitors a TCP/IP connection request of a connection monitoring submodule in the sending module on a designated port of the server, and after receiving the connection request, the monitoring submodule informs the receiving submodule to establish connection with the connection monitoring submodule and then continues monitoring.
When detecting that the receiving submodule is connected with the connection monitoring submodule, the heartbeat detection submodule periodically sends a heartbeat detection request to the connection monitoring submodule which establishes connection through the receiving submodule, if the receiving submodule does not receive notification of a received heartbeat response signal from the receiving submodule in the period, the heartbeat unresponsive frequency corresponding to the connection monitoring submodule is added with 1, whether the heartbeat unresponsive frequency reaches a preset value is detected, and if the heartbeat unresponsive frequency reaches the preset value, the receiving submodule is notified to disconnect the connection monitoring submodule; and if the notice is received in the period, setting the number of the heartbeat unresponsive times corresponding to the connection monitoring submodule to be 0, and restarting counting.
When the receiving submodule initially establishes connection, the receiving submodule establishes connection with the connection monitoring submodule according to the notice of the monitoring submodule, after the connection is successfully established, the heartbeat detection request sent to the connection monitoring submodule by the heartbeat detection submodule is forwarded through the established connection, the data sent by the connection monitoring submodule is read, whether the received data is a heartbeat response signal or ticket data is judged, and if the data is the heartbeat response signal, the receiving submodule sends the notice of the received heartbeat response signal to the heartbeat detection submodule; and if the received call ticket data is the call ticket data, writing the call ticket data into a buffer area established by a call ticket data storage unit. And the ticket writing module reads the ticket data from the cache area and writes the ticket data into a database or a file.
Example two:
the method in this embodiment is implemented based on a second system for recording a ticket, in this embodiment, the database or the file and the service operation module are set on the same host, and the method further includes: and a ticket writing module. The embodiment is suitable for the condition of less traffic. Referring to fig. 8, fig. 8 is a flowchart of a second embodiment of the method for recording call ticket data in the present invention, where the flowchart includes the following steps:
step 801, create and initialize a cache region.
In this step, there may be two methods for creating the cache area. The specific method may be created as the interface component called by the service execution module in the embodiment shown in fig. 7, or created in other ways.
Step 802, recording the call ticket of the running service, and storing the recorded call ticket data into a buffer area.
In this step, the service operation module records the ticket of the operated service, and writes the recorded ticket data into the tail of the circular queue through calling the interface function of the interface component, that is, writes the position pointed by the tail pointer of the queue, and at this time, the tail pointer of the queue changes and points to the next position to be written.
Step 803, the cached call ticket data is read from the caching area and stored in a database or a file.
In this step, the call ticket writing module can continuously read the call ticket data from the head of the circular queue in the buffer area, that is, the call ticket data is read from the position pointed by the pointer at the head of the circular queue and stored in the database or the file, and at this time, the pointer at the head of the queue changes and points to the next position to be read.
In addition, the method may further include: and detecting the occupation condition of the call ticket data in the buffer area at regular time, and sending alarm information and the like when the proportion of the call ticket data occupying the buffer area reaches a preset alarm point. Wherein, the operation for detecting the occupancy condition of the session data in the buffer area in a timing mode can be completed by the alarm module.
The alarm module regularly detects the condition of the occupation of the call ticket data in the circular queue, when the proportion of the call ticket data occupying the circular queue reaches a preset alarm point, the alarm information is sent out, the alarm information can be sent out by writing an alarm log or sending out an alarm through interface information, a new area can be dynamically applied for a cache area by an interface component or other modes according to the alarm information, and the new area is initialized into one or more than one circular queues; if the record point is preset, when the proportion of the call ticket data occupying the circular queue reaches the preset record point, the alarm module also reads the call ticket data in the circular queue and stores the call ticket data in a database or a file.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.