WO2014187412A1 - 消息处理线程的控制方法及装置 - Google Patents

消息处理线程的控制方法及装置 Download PDF

Info

Publication number
WO2014187412A1
WO2014187412A1 PCT/CN2014/079636 CN2014079636W WO2014187412A1 WO 2014187412 A1 WO2014187412 A1 WO 2014187412A1 CN 2014079636 W CN2014079636 W CN 2014079636W WO 2014187412 A1 WO2014187412 A1 WO 2014187412A1
Authority
WO
WIPO (PCT)
Prior art keywords
service
processing
thread
type
message
Prior art date
Application number
PCT/CN2014/079636
Other languages
English (en)
French (fr)
Inventor
张舰
郑平
罗秋野
Original Assignee
中兴通讯股份有限公司
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 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2014187412A1 publication Critical patent/WO2014187412A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/10Office automation; Time management
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/50Queue scheduling
    • H04L47/56Queue scheduling implementing delay-aware scheduling

Definitions

  • the present invention relates to the field of service system message processing, and in particular, to a message processing thread control method and apparatus.
  • BACKGROUND OF THE INVENTION nowadays, the business system is becoming more and more huge. The tens of thousands of users are online at the same time, and the response speed of the request is higher and higher, and the application server supporting the operation of the business system is also proposed to be higher. Requirements, you need to make full use of the physical performance of the server to handle a large number of client-concurrent business request messages. Referring to FIG. 1, the process of the application server processing the client concurrent transaction request message in the related art is as follows:
  • the application server 100 receives the service request message transmitted from the client 101, 102, 103, and hands the service request message to the message distributor 104.
  • the message distributor 104 dispatches the received service request messages to the message processor 105 for processing, allocates a thread pool to process the received service request messages, and each received service request message is processed using one thread. Release the thread back to the thread pool after the business request has been processed.
  • the request response time includes: the actual processing time of the service request plus the waiting time in the message queue. If there are too many concurrent user service requests, more than the number of threads in the service request processing thread pool, then there will be a service request waiting state, until the other service requests are processed, the thread is released, and the service request in the wait state can be processed. In the case of a large-scale user concurrent service request message, the service request message waits longer in the message queue, and the response time of the service request increases sharply.
  • the asynchronous 10 (Input/Output, Input/Output) mechanism provided by the system cannot be effectively utilized. Because the thread entry is synchronous, it needs to get the return result to the client when the service request message returns, so even if the business system provides Asynchronous 10 mechanism, you also need to wait until the asynchronous callback, the thread can continue to run.
  • the related technologies in the related art to solve the impact of large-scale user concurrent service requests on the business system mainly include: 1. As the number of threads increases, the business system allocates a thread stack for each thread, and the thread Increasing the number will occupy a large part of the system memory, resulting in a reduction in the available memory resources for real business processing.
  • the present invention provides a method and apparatus for controlling a message processing thread, which can reduce the waiting time of a service request message in a message queue, thereby reducing the response time of a service request and improving the service processing efficiency of the service system.
  • the present invention provides a method for controlling a message processing thread, the method comprising: determining a service content in a received service request message when receiving a service request message; and classifying the determined service content into different types of services according to a type, Each different type of service is sent to the corresponding thread for processing.
  • the service type includes a calculation type and a 10 operation type
  • the determined service content is divided into different types of services according to the type, and each different type of service is separately sent to the corresponding thread for processing, including: determining the determined
  • the service content is divided into a computing service and a 10 operation service according to the type, and 10 operation services are classified into 10 operation services of different operation types according to the operation type; the classified calculation service is sent to the calculation thread for processing, and 10 of different operation types are The operation services are respectively sent to the corresponding 10 operation threads for processing.
  • the method includes: after completing the 10 operations When the business content needs to perform a computing service, the business content after the completion of the 10 operations is sent to the computing thread for processing.
  • the method further includes: completing the computing operation When the subsequent business content needs to perform 10 operation services, the business content after the completion of the calculation operation is sent to the 10 operation threads of the corresponding type for processing.
  • the method when receiving a plurality of service request messages, the method further includes: sending the same type of computing services in the plurality of service request messages to the same computing thread for processing.
  • the present invention also provides a control device for a message processing thread, the device comprising: a processing module, configured to determine a service content in a received service request message when receiving a service request message; and classify the determined service content according to a type For different types of services; the data transmission module is set to send each different type of service to the corresponding thread for processing.
  • the service type includes a calculation type and a 10 operation type
  • the processing module is configured to divide the determined service content into a calculation service and a 10 operation service according to the type, and divide the 10 operation services into different operation types according to the operation type.
  • the data processing module is configured to send the classified computing service to the computing thread for processing, and send 10 operation services of different operation types to the 10 operation threads of the corresponding type for processing.
  • the data transmission module is further configured to send the service content after the completion of the 10 operations to the calculation thread for processing when the service content after the completion of the 10 operation needs to perform the calculation service.
  • the data transmission module is further configured to perform service content after the calculation operation is completed.
  • the service content after the completion of the calculation operation is sent to the 10 operation threads of the corresponding type for processing.
  • the data transmitting module is further configured to send the same type of computing services in the plurality of service request messages to the same computing thread for processing.
  • the present invention divides the service content in the received service request message into different types of services according to types, and sends different types of service content to corresponding different threads for processing, and concurrently requests service messages in large-scale users. In this case, the time that the service request message waits in the message queue is reduced, thereby reducing the response time of the service request, and improving the service processing efficiency of the service system.
  • FIG. 1 is a structural diagram of a service system
  • FIG. 2 is a schematic flowchart of a first embodiment of a method for controlling a message processing thread according to the present invention
  • FIG. 3 is a schematic flowchart of a second embodiment of a method for controlling a message processing thread according to the present invention
  • 4 is a schematic flowchart of a third embodiment of a method for controlling a message processing thread according to the present invention
  • FIG. 5 is a specific structural diagram of a preferred embodiment of a control device for a message processing thread according to the present invention.
  • FIG. 2 is a schematic flowchart diagram of a first embodiment of a method for controlling a message processing thread according to the present invention. It should be emphasized that the flowchart shown in FIG. 2 is only a preferred embodiment, and those skilled in the art will recognize that any embodiment constructed around the inventive concept should not be deviated from the scope of the following technical solutions:
  • Step S11 When receiving the service request message, determine the service content in the received service request message.
  • step S12 the determined service content is divided into different types of services according to the type, and each different type of service is separately sent to the corresponding thread for processing.
  • the service system may include other service devices such as a client and an application server, and the application server includes a message distributor and a message processor, and the message processor includes a message queue and a thread for processing different types of services, in a preferred implementation.
  • the thread that processes the business content in the business system can be divided into a computing thread and a 10 operating business thread.
  • the service type is preferably a calculation type and a 10 operation type.
  • Other embodiments of the present invention may further include any other applicable service type, such as a calculation type and a 10 operation type, which are not limited herein.
  • the calculation type may be a logical class operation, a summation of data, etc.
  • the 10 operations may be a file operation, a Socket (Socket) operation, or a database operation.
  • the service request message may be sent by the client, or may be a service request message (up report information) of other service devices in the service system, and determine the service content in the received service request message. Divide the determined service content into different types of services according to the type, and send each different type of service to the corresponding thread for processing.
  • the determined service content is divided into a calculation type and a 10 operation type, and the service content determined as the calculation type is sent to the calculation thread for processing, and the data processing of the calculation type of the service content is processed;
  • the service content determined to be of the 10 operation type is sent to the 10 operation thread for processing to perform file operation processing, Socket operation processing, or database operation processing on the business content determined to be the 10 operation type.
  • the implementation of the method of sending the different types of services to the corresponding types of threads for processing may preferably be: when programming the service, editing the corresponding interface identifiers for each different type of service, and passing each of the delivered service types
  • the carried interface identifier is scheduled to the thread of the corresponding interface for calculation or 10 operation processing; the determined service content is divided into the calculation type and the 10 operation type are also identified according to the interface identifier carried by the interface, and the scheduling of the corresponding interface is performed, for example, Calculate the service programming as "0", program the 10 operation service as "1”, and send the service content carrying the "1" logo by sending the service content carrying the "0" identifier to the calculation thread for processing.
  • the content is sent to the 10 operation thread for processing.
  • the number of different types of threads can be configured according to the business needs and the processing capabilities of the own business system.
  • the number of processing threads of the application server is 100
  • the number of operating threads is 500
  • 100 computing threads are configured for the application server
  • 10 operating threads are 500, wherein 10 operating threads can operate according to the file operation type and Socket in the service.
  • Types and database operation types are subdivided, for example, 150, 200, 150 threads, etc., respectively.
  • the number of threads configured is only an example, and the number of threads configured in each business system is not limited to this.
  • the service content in the received service request message is divided into different types of services by type, and different types of service content are sent to corresponding different threads for processing, and in the case of large-scale users concurrently requesting service messages, the service request is reduced.
  • the time that the message waits in the message queue which reduces the response time of the service request and improves the service processing efficiency of the service system.
  • FIG. 3 is a schematic flowchart diagram of a second embodiment of a method for controlling a message processing thread according to the present invention.
  • the service type may include a calculation type and a 10 operation type.
  • Step S12 includes: Step S13, dividing the determined service content into a computing service and a 10 operation service according to the type, and 10 operating services according to the operation type.
  • the operation service is divided into 10 operation services of different operation types.
  • Step S14: The classified calculation service is sent to the calculation thread for processing, and 10 operation services of different operation types are respectively sent to the 10 operation threads of the corresponding type for processing.
  • the 10 operation threads for processing 10 operations in the service system are classified according to the operation type, and the 10 operation threads after each classification are only responsible for the operation processing of the corresponding 10 operation types, and each type of 10 operation threads is required according to the business. Configure it.
  • the service content in the received service request message is determined, and the determined service content is divided into different types of services according to the type, and each different type of service is separately sent to the corresponding thread for processing.
  • the determined service content is divided into a calculation type and a 10 operation type, and the service content determined to be the calculation type is sent to the calculation thread for processing, and the data processing of the calculation type of the service content is performed, and the like;
  • the service content determined to be 10 operation types is divided into 10 operations of different operation types according to the operation type, for example, divided into a file operation type, a Socket operation type, or a database operation type, etc., and 10 operation services of different operation types are respectively sent to
  • the 10 types of operation threads of the corresponding type are processed, that is, each of the 10 types of operation services of different types is sent to the 10 devices of the corresponding type for processing; the file operation operation is performed on the 10 service contents determined as the file operation type by the file operation thread, and the Socket operation is performed.
  • the thread performs a Socket operation process on the 10 service contents determined to be the Socket operation type or performs a database operation process on the 10 service contents determined to be the database operation type through the database operation thread.
  • the service content determined to be 10 operation types is divided into 10 operations of different operation types according to the operation type, and 10 operations of different operation types are respectively sent to the corresponding 10 operation threads for corresponding operation processing, thereby effectively avoiding the cause.
  • FIG. 4 is a schematic flowchart diagram of a third embodiment of a method for controlling a message processing thread according to the present invention.
  • the method may further include: Step S15: When the service content after the completion of the 10 operation needs to perform the calculation service, send the service content after the completion of the 10 operation to the calculation thread. deal with. Specifically, when the 10 operation service content included in the service request message has been completed in its corresponding 10 operation thread, for example, after the file operation thread performs file operation processing on the 10 service contents determined as the file operation type, the file operation service is constructed. The return message is returned to the computing thread, and the operation of the thread of the 10 operation type is completed, and the thread of the 10 operation type is released, and the file operation processing is performed for the 10 operations of the type in the other service request message.
  • the return message of the constructed file operation service is sent to the calculation thread, where the calculation thread is the service request message corresponding to the service of the 10 operation type, including
  • the calculation thread that calculates the business type for calculation processing that is, the calculation service involved in the same service request message is processed by a calculation thread, so that the problem of thread synchronization is not considered in the service coding process, and the development efficiency of the business system is improved.
  • the computing service involved in the service content is very large, multiple computing threads are required to process, and the user ensures that the computing service included in the service request message is a stateless feature when the user sends the service request message to ensure multiple Computational threads can be executed concurrently.
  • the service content after the completion of the calculation operation needs to perform the 10 operation service, the service content after the completion of the calculation operation is sent to the 10 operation threads of the corresponding type for processing.
  • the same type of the multiple service request messages are received.
  • the calculation service is sent to the same calculation thread for processing.
  • a plurality of service request messages include an alarm type calculation service, and the calculation services that are all of the alarm type are sent to the same calculation thread for processing.
  • the following describes the process of processing the service content in the service request message by the service system by using a specific example.
  • the application server of the service system is configured with message loop A (message queue A, compute thread A), message loop B (message queue B, compute thread B), message loop C (message queue C, compute thread C) according to business requirements;
  • the configuration has 10 operation thread pools, and the 10 operation thread pools are configured with a file operation queue and its corresponding file operation thread, a Socket operation queue and its corresponding Socket operation thread and a database operation queue and corresponding database operation threads.
  • the new service request message is sent to the message loop B, and the service request message in the message loop A has been processed, and the next service request message can be processed, and the message loop is processed.
  • the message queue B in B receives the service request message sent by the message loop A, and the calculation thread B performs calculation processing on the received service request message.
  • the calculation process needs to read the file content
  • the file access service is constructed, and the service request is made.
  • the message is sent to the file operation queue, The operation thread reads the file content.
  • the build return message is sent to the message loop B, and the file operation thread is released, and the file operation operation is performed for the next file operation type 10 operation; the message in the message loop B Queue B obtains the return message after the file operation is completed.
  • a new service request message is constructed, and the constructed new service request message is sent to the message loop C, in the message loop B.
  • the service request message has been processed, and the next service request message can be processed.
  • the calculation thread C performs calculation processing on the received service request message.
  • the database access service is constructed, and the database access service is constructed.
  • the request message is sent to the database operation queue, and the database operation thread executes the data query.
  • the build return message is sent to the message loop C, and the database operation thread is released, and the next database operation type 10 operation is performed for the database operation type operation.
  • the message queue C obtains the return message of the database query service, calls the calculation thread C to process the return message, constructs a return message, sends it to the message loop B, and the message queue B acquires the return message sent by the message loop C, and calls the calculation thread B.
  • the return message is processed, the return message is constructed, sent to the message loop A, the message queue A obtains the return message sent by the message loop B, the call calculation thread A is processed to process the return message, and the packet is forwarded after being processed by the calculation thread A. , complete the business request processing process of the business message request.
  • FIG. 5 is a specific structural diagram of a preferred embodiment of a control device for a message processing thread according to the present invention.
  • the device includes a processing module 10, a data transmitting module 20, and a configuration module 30.
  • the processing module 10 is configured to: when receiving a service request message, determine a service content in the received service request message; and determine the service content.
  • the data transmission module 20 is configured to send each different type of service to a corresponding thread for processing.
  • the service system may include other service devices such as a client and an application server, where the application server includes a message distributor and a message processor, and the message processor includes a message queue and a thread for processing different types of services, in this embodiment.
  • the service type is preferably a calculation type and a 10 operation type.
  • inventions may further include any other applicable service type, such as a calculation type and a 10 operation type, which are not limited herein.
  • the calculation type may be a logical class operation, a summation of data, etc.
  • the 10 operations may be File operations, Socket operations, or database operations.
  • the service request message may be sent by the client, or may be a service request message (up report information) of other service devices in the service system, and the processing module 10 determines to receive the message.
  • the service content in the service request message is divided into different types of services according to the type, and each different type of service is separately sent to the corresponding thread for processing.
  • the processing module 10 divides the determined service content into a calculation type and a 10 operation type, and the data transmission module 20 sends the service content determined to be a calculation type to the calculation thread for processing to calculate the type of service.
  • the content performs data summation and the like; the data transmission module 20 sends the service content determined to be 10 operation types to the 10 operation thread for processing, and performs file operation processing, Socket operation processing, or database on the business content determined to be the 10 operation type. Operation processing.
  • the implementation of the method of sending the different types of services to the corresponding types of threads for processing may preferably be: when programming the service, editing the corresponding interface identifiers for each different type of service, and passing each of the delivered service types
  • the carried interface identifier is scheduled to the thread of the corresponding interface for calculation or 10 operation processing; the determined service content is divided into the calculation type and the 10 operation type is also identified according to the interface identifier carried by the interface, and the scheduling of the corresponding interface is performed, for example, Calculate the service programming as "0", program the 10 operation service as "1”, and send the service content carrying the "1" logo by sending the service content carrying the "0" identifier to the calculation thread for processing.
  • the content is sent to 10 operating threads for processing.
  • the configuration module 30 can configure the number of different types of threads according to the business needs and the processing capabilities of the own business system.
  • the configuration of the calculation thread and the size of the 10 thread pool is relatively high in technical level. It can be considered that the test data of several common servers is collected by a specific business system, and the empirical configuration parameters are given or a tool for automatically configuring is developed, for example, The number of processing threads of the service requirement and the application server is 100, and the number of operating threads is 500.
  • the configuration module 30 configures 100 computing threads for the application server, and 500 operating threads, of which 10 operating threads can be based on the service.
  • the file operation type, the Socket operation type, and the database operation type are subdivided. For example, 150, 200, and 150 threads are respectively configured.
  • the number of threads configured is only an example, and the number of threads configured in each service system is not limited. herein.
  • the service content in the service request message received by the data transmission module 20 is divided into different types of services by the processing module 10, and the data transmission module 20 sends different types of service content to corresponding threads for processing.
  • the service type may include a calculation type and a 10 operation type
  • the processing module 10 is configured to divide the determined service content into a calculation service and a 10 operation service according to the type, and divide the 10 operation services into different types according to the operation type.
  • the data transmission module 20 is configured to send the classified computing service to the computing thread for processing, and send 10 operation services of different operation types to the 10 operation threads of the corresponding type for processing.
  • the 10 operation threads for processing 10 operations in the service system are classified according to the operation type, and the 10 operation threads after each classification are only responsible for the operation processing of the corresponding 10 operation types, and each type of 10 operation threads is required according to the business. Configure it.
  • the processing module 10 determines the service content in the received service request message, and divides the determined service content into different types of services according to the type, and the data transmission module 20 Each different type of service is separately sent to a corresponding thread for processing.
  • the processing module 10 divides the determined service content into a calculation type and a 10 operation type, and the data transmission module 20 sends the service content determined to be a calculation type to the calculation thread for processing, for the calculation type of service.
  • the content performs data summation and the like; the processing module 10 divides the service content determined to be 10 operation types into 10 operations of different operation types according to the operation type, for example, is divided into a file operation type, a Socket operation type, or a database operation type, and the like.
  • the sending and receiving module 20 sends the 10 operation services of the different operation types to the 10 operation threads of the corresponding type for processing, that is, each 10 different types of operation services are sent to the corresponding type 10 devices for processing; Performing file operation processing for the 10 business contents of the file operation type, performing Socket operation processing on the 10 business contents determined to be the Socket operation type through the Socket operation thread, or performing database operation processing on the 10 business contents determined as the database operation type through the database operation thread .
  • the processing module 10 divides the service content determined to be 10 operation types into 10 operations of different operation types according to the operation type, and the data transmission module 20 sends 10 operations of different operation types to the corresponding 10 operation threads respectively to perform corresponding operations.
  • the operation processing effectively avoids the fact that multiple service requests contend for a certain type of 10 devices, and subsequent service requests of other 10 devices are not processed in time, thereby further improving the service processing efficiency of the service system.
  • the data transmission module 20 is further configured to send the service content after the completion of the 10 operations to the calculation thread for processing when the service content after the completion of the 10 operation needs to perform the calculation service. Specifically, when the 10 operation service content included in the service request message has been completed in its corresponding 10 operation thread, for example, after the file operation thread performs file operation processing on the 10 service contents determined as the file operation type, the file operation service is constructed.
  • the return message is returned to the computing thread, and the operation of the thread of the 10 operation type is completed, and the thread of the 10 operation type is released, and the file operation processing is performed for the 10 operations of the type in the other service request message.
  • the return message of the constructed file operation service is sent to the calculation thread, where the calculation thread is a service request message corresponding to the service of the 10 operation type, and the calculation included
  • the computing thread that performs the calculation processing of the service type that is, the computing service involved in the same service request message is processed by a computing thread, which can make the business encoding process There is no need to consider the issue of thread synchronization, and improve the development efficiency of business systems.
  • the computing service involved in the service content is very large, multiple computing threads are required to process, and the user ensures that the computing service included is a stateless feature when the user sends the service request message through the UE to ensure multiple Computational threads can be executed concurrently.
  • the data transmission module 20 is further configured to send the service content after the completion of the calculation operation to the 10 operation threads of the corresponding type for processing when the service content needs to perform 10 operation services after the completion of the calculation operation.
  • the same type of the multiple service request messages are received.
  • the calculation service is sent to the same calculation thread for processing.
  • a plurality of service request messages include an alarm type calculation service, and the data transmission module 20 sends the calculation services that are all alarm types to the same calculation thread for processing.
  • the following describes the process of processing the service content in the service request message by the service system by using a specific example.
  • the application server of the service system is configured with message loop A (message queue A, compute thread A), message loop B (message queue B, compute thread B), message loop C (message queue C, compute thread C) according to business requirements;
  • the configuration has 10 operation thread pools, and the 10 operation thread pools are configured with a file operation queue and its corresponding file operation thread, a Socket operation queue and its corresponding Socket operation thread and a database operation queue and corresponding database operation threads.
  • the new service request message is sent to the message loop B, and the service request message in the message loop A has been processed, and the next service request message can be processed, and the message loop is processed.
  • the message queue B in B receives the service request message sent by the message loop A, and the calculation thread B performs calculation processing on the received service request message.
  • the calculation process needs to read the file content
  • the file access service is constructed, and the service request is made.
  • the message is sent to the file operation queue, and the file operation thread reads the file content.
  • the build return message is sent to the message loop B, and the file operation thread is released, and the file operation operation is performed for the next file operation type 10 operation.
  • Message queue B in message loop B gets The return message after the operation, when the calculation process needs to involve the message loop C, construct a new service request message, and send the constructed new service request message to the message loop C, the service request message in the message loop B. After the processing is completed, the next service request message can be processed, and the calculation thread C calculates and processes the received service request message.
  • the database access service When the calculation process needs to query the database, the database access service is constructed, and the request message for constructing the database access service is sent to The database operation queue, the database operation thread executes the data query, after the data query is completed, the construction return message is sent to the message loop C, and the database operation thread is released, and the operation of the database operation type is performed for the next operation of the database operation type;
  • the database queries the return message of the service, and calls the calculation thread C to process the return message.
  • the service system Constructs a return message, sends it to message loop B, message queue B gets the return message sent by message loop C, calls computation thread B to process the return message, constructs a return message, sends it to message loop A, and message queue A gets the message loop
  • the return message sent by B is called by the calculation thread A to process the return message, and after the processing thread A processes, the packet is forwarded out, and the service request processing process of the service message request is completed.
  • the thread is released for the next computing service to perform processing, and in the case of a large-scale user concurrent service request message, the waiting time of the service request message is reduced.
  • the service system is configured with three message loops.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Strategic Management (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Human Resources & Organizations (AREA)
  • Economics (AREA)
  • Data Mining & Analysis (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer And Data Communications (AREA)

Abstract

本发明公开了一种消息处理线程的控制方法及装置,本发明通过将接收的业务请求消息中的业务内容按类型分为不同类型的业务,将不同类型的业务内容发送至对应的不同线程进行处理,在大规模用户并发业务请求消息的情况下,降低业务请求消息在消息队列中等待的时间,进而降低业务请求的响应时间,提高业务系统的业务处理效率。

Description

消息处理线程的控制方法及装置 技术领域 本发明涉及到业务系统消息处理领域, 特别涉及到一种消息处理线程的控制方法 及装置。 背景技术 现在业务系统越来越庞大, 动辄就是成千上万的用户同时在线, 对请求的响应速 度要求也越来越高, 对支撑业务系统运行的应用服务器来说也就提出了更高的要求, 需要充分利用服务器的物理性能, 来处理大量客户端并发的业务请求消息。 参照图 1, 相关技术中应用服务器处理客户端并发的业务请求消息的过程如下:
1、 应用服务器 100接收从客户端 101、 102、 103发送来的业务请求消息, 并将业 务请求消息交给消息分发器 104。
2、消息分发器 104将接收到的各个业务请求消息分派给消息处理器 105处理,分 配一个线程池来处理接收到的各个业务请求消息, 且每一个接收到的业务请求消息使 用一个线程来处理, 在该业务请求处理完后将该线程释放回线程池。
3、 通过业务请求处理线程池的大小来控制并发处理业务请求的数量。 但是, 由于并发用户的数量越来越多, 业务请求响应时间又不能降低, 在这种传 统模式下的业务请求消息的处理遇到了一些问题:
A、 传统模式下, 请求响应时间包括: 业务请求的真正处理时间加上在消息队列 中的等待时间。如果并发用户业务请求太多,超过业务请求处理线程池中的线程数量, 那么就会有业务请求处于等待状态, 直到其他业务请求处理完之后释放线程, 处于等 待状态的业务请求才能够获得处理。 在大规模用户并发业务请求消息的情况下, 业务 请求消息在消息队列中等待的时间就会更长, 业务请求的响应时间就会急剧增加。
B、 如果扩大线程池, 增加线程的数量, 在线程数量不超过 1000的情况下还能解 决一部分问题。 如果数量再大一些, 到几千、 上万, 业务系统的处理能力就会开始下 C、 传统的多线程模式下, 随着业务逻辑越来越复杂, 编程的难度大幅增加, 导 致编程效率的下降。 经常在编写一段代码时, 要反复的思考、 模拟多线程情况下可能 遇到的多线程之间的同步问题。
D、 不能有效地利用的系统提供的异步 10 (Input/Output, 输入 /输出)机制, 因为 线程入口是同步的, 需要在业务请求消息返回时获得返回结果给客户端, 所以即使业 务系统提供了异步 10机制, 也需要等到异步回调以后, 线程才能继续往下运行。 基于上述分析, 相关技术中通过增加线程数量的方式来解决大规模用户并发业务 请求对业务系统的影响主要包括: 一、 随着线程数量的增加, 业务系统会为每个线程分配线程堆栈, 线程数量增多 就会占用很大部分的系统内存, 从而导致真正的业务处理可用的内存资源减少; 二、 线程数量增加之后, 线程调度所消耗的 CPU开销明显增多, 又会与业务处理 争用 CPU资源, 造成业务处理速度降低。 发明内容 本发明提供了一种消息处理线程的控制方法及装置, 能够降低业务请求消息在消 息队列中等待的时间,进而降低业务请求的响应时间,提高业务系统的业务处理效率。 本发明提出一种消息处理线程的控制方法, 该方法包括: 当接收到业务请求消息时, 确定接收的业务请求消息中的业务内容; 将确定的业务内容按照类型分为不同类型的业务, 将各个不同类型的业务分别发 送至对应的线程进行处理。 优选地,所述业务类型包括计算类型和 10操作类型,所述将确定的业务内容按照 类型分为不同类型的业务, 将各个不同类型的业务分别发送至对应的线程进行处理包 括: 将确定的业务内容按照类型分为计算业务和 10操作业务, 将 10操作业务按照操 作类型分为不同操作类型的 10操作业务; 将分类后的计算业务发送至计算线程进行处理,将各个不同操作类型的 10操作业 务分别发送至对应类型的 10操作线程进行处理。 优选地, 在所述将分类后的计算业务发送至计算线程进行处理, 将各个不同操作 类型的 10操作业务分别发送至对应类型的 10操作线程进行处理之后, 该方法包括: 在完成 10操作之后的业务内容需要进行计算业务时, 将完成 10操作之后的业务 内容发送至所述计算线程进行处理。 优选地, 在所述将分类后的计算业务发送至计算线程进行处理, 将各个不同操作 类型的 10操作业务分别发送至对应类型的 10操作线程进行处理之后,该方法还包括: 在完成计算操作之后的业务内容需要进行 10操作业务时,将完成计算操作之后的 业务内容发送至对应类型的 10操作线程进行处理。 优选地, 当接收到多个业务请求消息时, 该方法还包括: 将多个业务请求消息中的同一类型的计算业务发送至同一个计算线程进行处理。 本发明还提出一种消息处理线程的控制装置, 该装置包括: 处理模块, 设置为当接收到业务请求消息时, 确定接收的业务请求消息中的业务 内容; 及将确定的业务内容按照类型分为不同类型的业务; 数据接发模块, 设置为将各个不同类型的业务分别发送至对应的线程进行处理。 优选地, 所述业务类型包括计算类型和 10操作类型, 所述处理模块, 设置为将确定的业务内容按照类型分为计算业务和 10操作业务, 将 10操作业务按照操作类型分为不同操作类型的 10操作业务; 所述数据接发模块, 设置为将分类后的计算业务发送至计算线程进行处理, 将各 个不同操作类型的 10操作业务分别发送至对应类型的 10操作线程进行处理。 优选地,所述数据接发模块,还设置为在完成 10操作之后的业务内容需要进行计 算业务时, 将完成 10操作之后的业务内容发送至所述计算线程进行处理。 优选地, 所述数据接发模块, 还设置为在完成计算操作之后的业务内容需要进行
10操作业务时, 将完成计算操作之后的业务内容发送至对应类型的 10操作线程进行 处理。 优选地, 当接收到多个业务请求消息时, 所述数据接发模块, 还设置为将多个业 务请求消息中的同一类型的计算业务发送至同一个计算线程进行处理。 相对相关技术, 本发明通过将接收的业务请求消息中的业务内容按类型分为不同 类型的业务, 将不同类型的业务内容发送至对应的不同线程进行处理, 在大规模用户 并发业务请求消息的情况下, 降低业务请求消息在消息队列中等待的时间, 进而降低 业务请求的响应时间, 提高业务系统的业务处理效率。 附图说明 图 1为业务系统结构图; 图 2为本发明消息处理线程的控制方法的第一实施例的流程示意图; 图 3为本发明消息处理线程的控制方法的第二实施例的流程示意图; 图 4为本发明消息处理线程的控制方法的第三实施例的流程示意图; 图 5为本发明消息处理线程的控制装置的较佳实施例的具体架构图。 本发明目的的实现、 功能特点及优点将结合实施例, 参照附图做进一步说明。 具体实施方式 应当理解,此处所描述的具体实施例仅仅用以解释本发明, 并不用于限定本发明。 如图 2所示, 为本发明消息处理线程的控制方法的第一实施例的流程示意图。 需要强调的是: 图 2所示流程图仅为一个较佳实施例, 本领域的技术人员当知, 任何围绕本发明思想构建的实施例都不应脱离于如下技术方案涵盖的范围: 当接收到客户端发送来的业务请求消息时, 确定接收的业务请求消息中的业务内 容; 将确定的业务内容按照类型分为不同类型的业务, 将各个不同类型的业务分别发 送至对应的线程进行处理。 以下是本实施例逐步实现消息处理线程的控制的具体步骤: 步骤 Sll, 当接收到业务请求消息时, 确定接收的业务请求消息中的业务内容。 步骤 S12, 将确定的业务内容按照类型分为不同类型的业务, 将各个不同类型的 业务分别发送至对应的线程进行处理。 在具体实施过程中, 业务系统中可能包括客户端和应用服务器等其他业务设备, 应用服务器包括消息分发器和消息处理器, 消息处理器包括消息队列及处理不同类型 业务的线程, 在一个优选实施方式中, 可以将业务系统中处理业务内容的线程分为计 算线程和 10操作业务线程。 在本实施例中, 所述业务类型优选为包括计算类型和 10 操作类型,在本发明其他实施例还可以包括计算类型和 10操作类型等其他任意适用的 业务类型, 在此不作一一限定。 所述计算类型可以是逻辑类运算, 数据的求和等, 所 述 10操作可以是文件操作、 Socket (套接口)操作或数据库操作等。 当接收到业务请 求消息时, 所述业务请求消息可以是客户端发送过来的, 也可以是业务系统中的其他 业务设备的业务请求消息(上报信息), 确定接收的业务请求消息中的业务内容, 将确 定的业务内容按照类型分为不同类型的业务, 将各个不同类型的业务分别发送至对应 的线程进行处理。在该优选实施方式中,将确定的业务内容分为计算类型和 10操作类 型, 将确定为计算类型的业务内容发送至计算线程进行处理, 以对计算类型的业务内 容进行数据求和等处理; 将确定为 10操作类型的业务内容发送至 10操作线程进行处 理, 以对确定为 10操作类型的业务内容进行文件操作处理、 Socket操作处理或数据库 操作处理。 所述将不同类型的业务发送至对应类型的线程进行处理的实现方式优选可 以为: 在对业务进行编程时, 给各个不同类型的业务编辑相对应的接口标识, 并通过 各个下发的业务类型所携带的接口标识调度至对应接口的线程进行计算或 10 操作处 理;将确定的业务内容分为计算类型和 10操作类型也是根据其携带的接口标识来识别 并进行对应接口的调度, 例如, 为计算业务编程为 "0" 的标识, 将 10操作业务编程 为 " 1 " 的标识, 通过将携带有 "0" 的标识的业务内容发送至计算线程进行处理, 将 携带有 " 1 "标识的业务内容发送至 10操作线程进行处理, 在实际应用中, 根据需要 也还可以使用其他适用的可以区分计算业务和 10操作业务的标识。为了进一步提高业 务系统处理业务内容的效率, 可以根据业务需要和本身业务系统的处理能力来配置不 同类型线程的数量。在对计算线程和 10线程池大小进行配置时,可以考虑由具体的业 务系统收集几种常用服务器的测试数据后, 给出经验配置参数或者是开发一个自动进 行配置的工具,例如,该业务需求和应用服务器的处理能力计算线程的数量为 100, 10 操作线程的数量 500, 为该应用服务器配置计算线程 100个, 10操作线程 500个, 其 中 10操作线程可以根据业务中文件操作类型、 Socket操作类型及数据库操作类型进行 细分, 例如分别配置 150、 200、 150个线程等, 在此, 线程的配置数量仅举例说明, 并不将各个业务系统中配置的线程数量局限于此。 通过将接收的业务请求消息中的业务内容按类型分为不同类型的业务, 将不同类 型的业务内容发送至对应的不同线程进行处理, 在大规模用户并发业务请求消息的情 况下, 降低业务请求消息在消息队列中等待的时间, 进而降低业务请求的响应时间, 提高业务系统的业务处理效率。 如图 3所示, 为本发明消息处理线程的控制方法的第二实施例的流程示意图。 基于上述第一实施例, 所述业务类型可以包括计算类型和 10操作类型, 步骤 S12 包括: 步骤 S13, 将确定的业务内容按照类型分为计算业务和 10操作业务, 将 10操作 业务按照操作类型分为不同操作类型的 10操作业务; 步骤 S14, 将分类后的计算业务发送至计算线程进行处理, 将各个不同操作类型 的 10操作业务分别发送至对应类型的 10操作线程进行处理。 具体的, 将业务系统中用于处理 10操作的 10操作线程按照操作类型进行分类, 各个分类后的 10操作线程只负责对应的 10操作类型的操作处理, 而各个类型的 10 操作线程根据业务需要进行配置。 当接收到业务请求消息时, 确定接收的业务请求消 息中的业务内容, 将确定的业务内容按照类型分为不同类型的业务, 将各个不同类型 的业务分别发送至对应的线程进行处理。 在该优选实施方式中, 将确定的业务内容分 为计算类型和 10操作类型, 将确定为计算类型的业务内容发送至计算线程进行处理, 以对计算类型的业务内容进行数据求和等处理;将确定为 10操作类型的业务内容按照 操作类型分为不同操作类型的 10操作, 例如, 分为文件操作类型、 Socket操作类型或 数据库操作类型等, 将各个不同操作类型的 10操作业务分别发送至对应类型的 10操 作线程进行处理, 即将各个不同类型的 10操作业务发送至对应类型的 10设备进行处 理; 以通过文件操作线程对确定为文件操作类型的 10业务内容进行文件操作处理、通 过 Socket操作线程对确定为 Socket操作类型的 10业务内容进行 Socket操作处理或通 过数据库操作线程对确定为数据库操作类型的 10业务内容进行数据库操作处理。 本实施例通过对确定为 10 操作类型的业务内容按照操作类型分为不同操作类型 的 10操作, 并将不同操作类型的 10操作分别发送至对应的 10操作线程进行对应的 操作处理, 有效避免因多个业务请求争用某种类型的 10设备而导致后续使用其他 10 设备的业务请求得不到及时处理, 进一步提高业务系统的业务处理效率。 如图 4所示, 为本发明消息处理线程的控制方法的第三实施例的流程示意图。 基于上述第二实施例, 在步骤 S14之后, 该方法还可以包括: 步骤 S15, 在完成 10操作之后的业务内容需要进行计算业务时, 将完成 10操作 之后的业务内容发送至所述计算线程进行处理。 具体的, 在业务请求消息包括的 10操作业务内容已在其对应的 10操作线程中完 成时,例如,文件操作线程对确定为文件操作类型的 10业务内容进行文件操作处理之 后,构建文件操作业务的返回消息返回至所述计算线程,在该 10操作类型的线程的操 作完成, 将该 10操作类型的线程释放, 供其他业务请求消息中的本类型的 10操作进 行文件操作处理。在完成 10操作之后的业务内容需要进行计算业务时,将该构建的文 件操作业务的返回消息发送至所述计算线程,该计算线程为该 10操作类型的业务对应 的业务请求消息中, 包括的计算业务类型进行计算处理的计算线程, 即对于同一个业 务请求消息中涉及的计算业务都通过一个计算线程进行处理, 可以使得在业务编码过 程中无须考虑线程同步的问题, 提高业务系统的开发效率。 在本发明其他实施例中, 若业务内容涉及的计算业务非常大, 需要多个计算线程来处理, 用户在通过用户端发 送业务请求消息时保证包括的计算业务为无状态特性, 以确保多个计算线程能并发进 行。 同样, 在执行完步骤 S14之后, 还可以是在完成计算操作之后的业务内容需要进 行 10操作业务时, 将完成计算操作之后的业务内容发送至对应类型的 10操作线程进 行处理。 在本发明其他实施例中, 为了使得在业务编码过程中无须考虑线程同步的问题, 提高业务系统的开发效率, 当接收到多个业务请求消息时, 将多个业务请求消息中的 同一类型的计算业务发送至同一个计算线程进行处理。 例如, 多个业务请求消息中都 包括告警类型的计算业务, 将这些都为告警类型的计算业务发送至同一个计算线程进 行处理。 下面以具体实例来说明业务系统对业务请求消息中的业务内容进行处理的过程。 该业务系统的应用服务器根据业务需求配置有消息循环 A (消息队列 A、 计算线 程 A)、 消息循环 B (消息队列 B、 计算线程 B)、 消息循环 C (消息队列 C、 计算线程 C); 配置有 10操作线程池, 该 10操作线程池配置有文件操作队列及其对应的文件操 作线程、 Socket操作队列及其对应的 Socket操作线程及数据库操作队列及其对应的数 据库操作线程。 当接收到客户端发送来的业务请求消息时, 将该业务请求消息放入消 息循环 A的消息队列 A中, 消息循环 A的计算线程 A从消息队列中获取该业务请求 消息的计算业务进行计算处理, 当计算过程需要涉及到消息循环 B时, 构建新的业务 请求消息发送至消息循环 B, 消息循环 A中的该业务请求消息已经处理完成, 可以进 行下一条业务请求消息的处理, 消息循环 B中的消息队列 B接收到消息循环 A发送过 来的业务请求消息, 计算线程 B对接收的业务请求消息进行计算处理, 当计算过程需 要读取文件内容时, 构造文件访问业务, 将该业务请求消息发送至文件操作队列, 文 件操作线程读取文件内容, 文件内容读取完毕之后, 构建返回消息发送至消息循环 B, 释放文件操作线程,供下一个文件操作类型的 10操作进行文件类型的操作; 消息循环 B中的消息队列 B获取到文件操作完后的返回消息, 当计算过程需要涉及到消息循环 C时, 构建一个新的业务请求消息, 将构建的新的业务请求消息发送至消息循环 C, 消息循环 B中的该业务请求消息已经处理完成,可以进行下一条业务请求消息的处理, 计算线程 C对接收的业务请求消息进行计算处理, 当计算过程需要查询数据库时, 构 造数据库访问业务, 将构造数据库访问业务的请求消息发送至数据库操作队列, 数据 库操作线程执行数据查询, 数据查询完毕之后, 构建返回消息发送至消息循环 C, 释 放数据库操作线程, 供下一个数据库操作类型的 10操作进行数据库操作类型的操作; 消息队列 C获取数据库查询业务的返回消息,调用计算线程 C对该返回消息进行处理, 构造返回消息, 发送至消息循环 B, 消息队列 B获取消息循环 C发送来的返回消息, 调用计算线程 B对该返回消息进行处理, 构造返回消息, 发送至消息循环 A, 消息队 列 A获取消息循环 B发送来的返回消息, 调用计算线程 A对该返回消息进行处理, 经计算线程 A处理之后转发出包, 完成该业务消息请求的业务请求处理过程。 在每一 个计算线程或 10操作线程处理完一个计算业务后,释放该线程供下一个计算业务进行 计算处理,在大规模用户并发业务请求消息的情况下,减少业务请求消息的等待时间。 在本实施例中, 该业务系统配置有 3个消息循环, 为了最大限度的利用 CPU资源, 也 还可以是在一个消息循环即可满足所有的计算业务, 配置一个消息循环。 通过将同一个业务请求消息中涉及的计算业务都通过一个计算线程进行处理, 可 以使得在业务编码过程中无须考虑线程同步的问题, 提高业务系统的开发效率。 如图 5所示, 为本发明消息处理线程的控制装置的较佳实施例具体架构图。 该装 置包括处理模块 10, 数据接发模块 20及配置模块 30, 所述处理模块 10, 设置为当接收到业务请求消息时, 确定接收的业务请求消息中 的业务内容; 及将确定的业务内容按照类型分为不同类型的业务; 所述数据接发模块 20, 设置为将各个不同类型的业务分别发送至对应的线程进行 处理。 在具体实施过程中, 业务系统中可能包括客户端和应用服务器等其他业务设备, 应用服务器包括消息分发器和消息处理器, 消息处理器包括消息队列及处理不同类型 业务的线程, 在本实施例中, 所述业务类型优选为包括计算类型和 10操作类型, 在本 发明其他实施例还可以包括计算类型和 10操作类型等其他任意适用的业务类型,在此 不作一一限定。所述计算类型可以是逻辑类运算, 数据的求和等, 所述 10操作可以是 文件操作、 Socket操作或数据库操作等。 当数据接发模块 20接收到业务请求消息时, 所述业务请求消息可以是客户端发送过来的, 也可以是业务系统中的其他业务设备的 业务请求消息 (上报信息), 处理模块 10确定接收的业务请求消息中的业务内容, 将 确定的业务内容按照类型分为不同类型的业务, 将各个不同类型的业务分别发送至对 应的线程进行处理。在该优选实施方式中,处理模块 10将确定的业务内容分为计算类 型和 10操作类型, 数据接发模块 20将确定为计算类型的业务内容发送至计算线程进 行处理,以对计算类型的业务内容进行数据求和等处理;数据接发模块 20将确定为 10 操作类型的业务内容发送至 10操作线程进行处理, 以对确定为 10操作类型的业务内 容进行文件操作处理、 Socket操作处理或数据库操作处理。 所述将不同类型的业务发 送至对应类型的线程进行处理的实现方式优选可以为: 在对业务进行编程时, 给各个 不同类型的业务编辑相对应的接口标识, 并通过各个下发的业务类型所携带的接口标 识调度至对应接口的线程进行计算或 10操作处理;将确定的业务内容分为计算类型和 10操作类型也是根据其携带的接口标识来识别并进行对应接口的调度, 例如, 为计算 业务编程为 "0" 的标识, 将 10操作业务编程为 " 1 " 的标识, 通过将携带有 "0" 的 标识的业务内容发送至计算线程进行处理, 将携带有 " 1 "标识的业务内容发送至 10 操作线程进行处理, 在实际应用中, 根据需要也还可以使用其他适用的可以区分计算 业务和 10操作业务的标识。为了进一步提高业务系统处理业务内容的效率,配置模块 30可以根据业务需要和本身业务系统的处理能力来配置不同类型线程的数量。计算线 程和 10线程池大小的配置对技术水平要求比较高,可以考虑由具体的业务系统收集几 种常用服务器的测试数据后,给出经验配置参数或者是开发一个自动进行配置的工具, 例如, 该业务需求和应用服务器的处理能力计算线程的数量为 100, 10操作线程的数 量 500, 配置模块 30为该应用服务器配置计算线程 100个, 10操作线程 500个, 其中 10操作线程可以根据业务中文件操作类型、 Socket操作类型及数据库操作类型进行细 分, 例如分别配置 150、 200、 150个线程等, 在此, 线程的配置数量仅举例说明, 并 不将各个业务系统中配置的线程数量局限于此。 通过处理模块 10将数据接发模块 20接收的业务请求消息中的业务内容按类型分 为不同类型的业务,数据接发模块 20将不同类型的业务内容发送至对应的不同线程进 行处理, 在大规模用户并发业务请求消息的情况下, 降低业务请求消息在消息队列中 等待的时间, 进而降低业务请求的响应时间, 提高业务系统的业务处理效率。 优选地, 所述业务类型可以包括计算类型和 10操作类型, 所述处理模块 10, 设置为将确定的业务内容按照类型分为计算业务和 10操作业 务, 将 10操作业务按照操作类型分为不同操作类型的 10操作业务; 所述数据接发模块 20, 设置为将分类后的计算业务发送至计算线程进行处理, 将 各个不同操作类型的 10操作业务分别发送至对应类型的 10操作线程进行处理。 具体的, 将业务系统中用于处理 10操作的 10操作线程按照操作类型进行分类, 各个分类后的 10操作线程只负责对应的 10操作类型的操作处理, 而各个类型的 10 操作线程根据业务需要进行配置。当数据接发模块 20接收到客户端发送来的业务请求 消息时, 处理模块 10确定接收的业务请求消息中的业务内容,将确定的业务内容按照 类型分为不同类型的业务,数据接发模块 20将各个不同类型的业务分别发送至对应的 线程进行处理。在该优选实施方式中,处理模块 10将确定的业务内容分为计算类型和 10操作类型, 数据接发模块 20将确定为计算类型的业务内容发送至计算线程进行处 理, 以对计算类型的业务内容进行数据求和等处理; 处理模块 10将确定为 10操作类 型的业务内容按照操作类型分为不同操作类型的 10操作, 例如, 分为文件操作类型、 Socket操作类型或数据库操作类型等, 数据接发模块 20将各个不同操作类型的 10操 作业务分别发送至对应类型的 10操作线程进行处理, 即将各个不同类型的 10操作业 务发送至对应类型的 10设备进行处理;以通过文件操作线程对确定为文件操作类型的 10业务内容进行文件操作处理、 通过 Socket操作线程对确定为 Socket操作类型的 10 业务内容进行 Socket操作处理或通过数据库操作线程对确定为数据库操作类型的 10 业务内容进行数据库操作处理。 本实施例通过处理模块 10对确定为 10操作类型的业务内容按照操作类型分为不 同操作类型的 10操作, 数据接发模块 20将不同操作类型的 10操作分别发送至对应 的 10操作线程进行对应的操作处理, 有效避免因多个业务请求争用某种类型的 10设 备而导致后续使用其他 10设备的业务请求得不到及时处理,进一步提高业务系统的业 务处理效率。 进一步地, 所述数据接发模块 20, 还设置为在完成 10操作之后的业务内容需要 进行计算业务时, 将完成 10操作之后的业务内容发送至所述计算线程进行处理。 具体的, 在业务请求消息包括的 10操作业务内容已在其对应的 10操作线程中完 成时,例如,文件操作线程对确定为文件操作类型的 10业务内容进行文件操作处理之 后,构建文件操作业务的返回消息返回至所述计算线程,在该 10操作类型的线程的操 作完成, 将该 10操作类型的线程释放, 供其他业务请求消息中的本类型的 10操作进 行文件操作处理。在完成 10操作之后的业务内容需要进行计算业务时,将该构建的文 件操作业务的返回消息发送至所述计算线程,该计算线程为该 10操作类型的业务对应 的业务请求消息, 包括的计算业务类型进行计算处理的计算线程, 即对于同一个业务 请求消息中涉及的计算业务都通过一个计算线程进行处理, 可以使得在业务编码过程 中无须考虑线程同步的问题, 提高业务系统的开发效率。 在本发明其他实施例中, 若 业务内容涉及的计算业务非常大, 需要多个计算线程来处理, 用户在通过用户端发送 业务请求消息时保证包括的计算业务为无状态特性,以确保多个计算线程能并发进行。 所述数据接发模块 20, 还设置为在完成计算操作之后的业务内容需要进行 10操 作业务时, 将完成计算操作之后的业务内容发送至对应类型的 10操作线程进行处理。 在本发明其他实施例中, 为了使得在业务编码过程中无须考虑线程同步的问题, 提高业务系统的开发效率, 当接收到多个业务请求消息时, 将多个业务请求消息中的 同一类型的计算业务发送至同一个计算线程进行处理。 例如, 多个业务请求消息中都 包括告警类型的计算业务,数据接发模块 20将这些都为告警类型的计算业务发送至同 一个计算线程进行处理。 下面以具体实例来说明业务系统对业务请求消息中的业务内容进行处理的过程。 该业务系统的应用服务器根据业务需求配置有消息循环 A (消息队列 A、 计算线 程 A)、 消息循环 B (消息队列 B、 计算线程 B)、 消息循环 C (消息队列 C、 计算线程 C); 配置有 10操作线程池, 该 10操作线程池配置有文件操作队列及其对应的文件操 作线程、 Socket操作队列及其对应的 Socket操作线程及数据库操作队列及其对应的数 据库操作线程。 当接收到客户端发送来的业务请求消息时, 将该业务请求消息放入消 息循环 A的消息队列 A中, 消息循环 A的计算线程 A从消息队列中获取该业务请求 消息的计算业务进行计算处理, 当计算过程需要涉及到消息循环 B时, 构建新的业务 请求消息发送至消息循环 B, 消息循环 A中的该业务请求消息已经处理完成, 可以进 行下一条业务请求消息的处理, 消息循环 B中的消息队列 B接收到消息循环 A发送过 来的业务请求消息, 计算线程 B对接收的业务请求消息进行计算处理, 当计算过程需 要读取文件内容时, 构造文件访问业务, 将该业务请求消息发送至文件操作队列, 文 件操作线程读取文件内容, 文件内容读取完毕之后, 构建返回消息发送至消息循环 B, 释放文件操作线程,供下一个文件操作类型的 10操作进行文件类型的操作; 消息循环 B中的消息队列 B获取到文件操作完后的返回消息, 当计算过程需要涉及到消息循环 C时, 构建一个新的业务请求消息, 将构建的新的业务请求消息发送至消息循环 C, 消息循环 B中的该业务请求消息已经处理完成,可以进行下一条业务请求消息的处理, 计算线程 C对接收的业务请求消息进行计算处理, 当计算过程需要查询数据库时, 构 造数据库访问业务, 将构造数据库访问业务的请求消息发送至数据库操作队列, 数据 库操作线程执行数据查询, 数据查询完毕之后, 构建返回消息发送至消息循环 C, 释 放数据库操作线程, 供下一个数据库操作类型的 10操作进行数据库操作类型的操作; 消息队列 C获取数据库查询业务的返回消息,调用计算线程 C对该返回消息进行处理, 构造返回消息, 发送至消息循环 B, 消息队列 B获取消息循环 C发送来的返回消息, 调用计算线程 B对该返回消息进行处理, 构造返回消息, 发送至消息循环 A, 消息队 列 A获取消息循环 B发送来的返回消息, 调用计算线程 A对该返回消息进行处理, 经计算线程 A处理之后转发出包, 完成该业务消息请求的业务请求处理过程。 在每一 个计算线程或 10操作线程处理完一个计算业务后,释放该线程供下一个计算业务进行 计算处理,在大规模用户并发业务请求消息的情况下,减少业务请求消息的等待时间。 在本实施例中, 该业务系统配置有 3个消息循环, 为了最大限度的利用 CPU资源, 也 还可以是在一个消息循环即可满足所有的计算业务, 配置一个消息循环。 通过将同一个业务请求消息中涉及的计算业务都通过一个计算线程进行处理, 可 以使得在业务编码过程中无须考虑线程同步的问题, 提高业务系统的开发效率。 以上所述仅为本发明的优选实施例, 并非因此限制本发明的专利范围, 凡是利用 本发明说明书及附图内容所作的等效结构或等效流程变换, 或直接或间接运用在其他 相关的技术领域, 均同理包括在本发明的专利保护范围内。

Claims

权 利 要 求 书 、 一种消息处理线程的控制方法, 包括:
当接收到业务请求消息时, 确定接收的业务请求消息中的业务内容; 将确定的业务内容按照类型分为不同类型的业务, 将各个不同类型的业务 分别发送至对应的线程进行处理。 、 根据权利要求 1所述的消息处理线程的控制方法, 其中, 所述业务类型包括计 算类型和 10操作类型, 所述将确定的业务内容按照类型分为不同类型的业务, 将各个不同类型的业务分别发送至对应的线程进行处理包括: 将确定的业务内容按照类型分为计算业务和 10操作业务, 将 10操作业务 按照操作类型分为不同操作类型的 10操作业务;
将分类后的计算业务发送至计算线程进行处理,将各个不同操作类型的 10 操作业务分别发送至对应类型的 10操作线程进行处理。 、 根据权利要求 2所述的消息处理线程的控制方法, 其中, 在所述将分类后的计 算业务发送至计算线程进行处理, 将各个不同操作类型的 10操作业务分别发 送至对应类型的 10操作线程进行处理之后, 该方法包括:
在完成 10操作之后的业务内容需要进行计算业务时, 将所述完成 10操作 之后的业务内容发送至所述计算线程进行处理。 、 根据权利要求 2所述的消息处理线程的控制方法, 其中, 在所述将分类后的计 算业务发送至计算线程进行处理, 将各个不同操作类型的 10操作业务分别发 送至对应类型的 10操作线程进行处理之后, 该方法还包括:
在完成计算操作之后的业务内容需要进行 10操作业务时, 将所述完成计 算操作之后的业务内容发送至对应类型的 10操作线程进行处理。 、 根据权利要求 1所述的消息处理线程的控制方法, 其中, 当接收到多个业务请 求消息时, 该方法还包括:
将多个业务请求消息中的同一类型的计算业务发送至同一个计算线程进行 处理。 、 一种消息处理线程的控制装置, 包括: 处理模块, 设置为当接收到业务请求消息时, 确定接收的业务请求消息中 的业务内容; 及将确定的业务内容按照类型分为不同类型的业务; 数据接发模块, 设置为将各个不同类型的业务分别发送至对应的线程进行 处理。 、 根据权利要求 6所述的消息处理线程的控制装置, 其中, 所述业务类型包括计 算类型和 10操作类型,
所述处理模块, 设置为将确定的业务内容按照类型分为计算业务和 10操 作业务, 将 10操作业务按照操作类型分为不同操作类型的 10操作业务; 所述数据接发模块,设置为将分类后的计算业务发送至计算线程进行处理, 将各个不同操作类型的 10操作业务分别发送至对应类型的 10操作线程进行处 理。 、 根据权利要求 7所述的消息处理线程的控制装置, 其中, 所述数据接发模块, 还设置为在完成 10操作之后的业务内容需要进行计 算业务时, 将完成 10操作之后的业务内容发送至所述计算线程进行处理。 、 根据权利要求 7所述的消息处理线程的控制装置, 其中, 所述数据接发模块,还设置为在完成计算操作之后的业务内容需要进行 10 操作业务时, 将完成计算操作之后的业务内容发送至对应类型的 10操作线程 进行处理。 0、 根据权利要求 6所述的消息处理线程的控制装置, 其中, 当接收到多个业务请 求消息时,
所述数据接发模块, 还设置为将多个业务请求消息中的同一类型的计算业 务发送至同一个计算线程进行处理。
PCT/CN2014/079636 2013-10-11 2014-06-10 消息处理线程的控制方法及装置 WO2014187412A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201310474533.9A CN104572290A (zh) 2013-10-11 2013-10-11 消息处理线程的控制方法及装置
CN201310474533.9 2013-10-11

Publications (1)

Publication Number Publication Date
WO2014187412A1 true WO2014187412A1 (zh) 2014-11-27

Family

ID=51932958

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2014/079636 WO2014187412A1 (zh) 2013-10-11 2014-06-10 消息处理线程的控制方法及装置

Country Status (2)

Country Link
CN (1) CN104572290A (zh)
WO (1) WO2014187412A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107464088A (zh) * 2016-06-02 2017-12-12 北京京东尚科信息技术有限公司 基于消息队列的业务处理系统及方法

Families Citing this family (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105159774B (zh) * 2015-07-08 2018-06-12 清华大学 一种api请求保序处理方法及系统
CN105187519B (zh) * 2015-08-26 2019-01-08 福建星网锐捷通讯股份有限公司 一种基于AIO的socket传输系统
CN105071976B (zh) * 2015-09-08 2019-05-03 安一恒通(北京)科技有限公司 数据传输方法和装置
CN105590253A (zh) * 2016-01-12 2016-05-18 上海携程商务有限公司 基于多线程的并行财务流水生成方法及系统
CN106095546A (zh) * 2016-06-01 2016-11-09 深圳市永兴元科技有限公司 云计算平台的任务管理方法及装置
CN106330769B (zh) * 2016-11-15 2022-03-08 腾讯科技(深圳)有限公司 一种业务处理方法及服务器
CN106533961B (zh) * 2016-12-30 2020-08-28 中国农业银行股份有限公司 一种流量控制方法及装置
CN106790632B (zh) * 2017-01-03 2020-07-14 北京奇虎科技有限公司 一种流数据的并发传输方法和装置
CN106909613B (zh) * 2017-01-11 2020-05-22 华南理工大学 一种自适应均衡数据库访问服务的方法
CN106953857B (zh) * 2017-03-16 2020-03-10 郑州云海信息技术有限公司 一种基于cs架构的服务器端多线程管理方法
CN108628636A (zh) * 2017-03-24 2018-10-09 北京京东尚科信息技术有限公司 系统业务隔离的方法、装置、电子设备和可读存储介质
CN107423085B (zh) * 2017-04-24 2020-07-28 北京百度网讯科技有限公司 用于部署应用的方法和装置
CN107341056A (zh) * 2017-07-05 2017-11-10 郑州云海信息技术有限公司 一种基于网络文件系统的线程分配的方法及装置
CN108681481B (zh) * 2018-03-13 2021-10-15 创新先进技术有限公司 业务请求的处理方法及装置
CN110413419A (zh) * 2018-04-28 2019-11-05 北京京东尚科信息技术有限公司 一种规则执行的方法和装置
CN109032452A (zh) * 2018-08-14 2018-12-18 北京大米科技有限公司 页面操作内容同步系统及方法
CN109240831A (zh) * 2018-09-21 2019-01-18 郑州云海信息技术有限公司 一种操作请求处理方法、装置、设备及可读存储介质
CN109451035A (zh) * 2018-12-04 2019-03-08 宁波耘瑞智能科技有限公司 一种分离式集群代理与服务的方法、装置及系统
CN109976891B (zh) * 2019-03-28 2020-11-03 北京网聘咨询有限公司 基于任务线程配置的服务器任务处理方法
CN111866039A (zh) * 2019-04-28 2020-10-30 中国移动通信集团上海有限公司 企业服务系统及请求处理方法
CN110351342A (zh) * 2019-06-20 2019-10-18 平安科技(深圳)有限公司 业务指令处理方法、装置、计算机设备和存储介质
CN111737012B (zh) * 2020-07-31 2020-12-04 腾讯科技(深圳)有限公司 数据包的同步方法、装置、设备及存储介质
CN115396285B (zh) * 2022-08-25 2024-03-01 中国工商银行股份有限公司 消息中间件的性能监控方法和系统

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102447628A (zh) * 2011-12-22 2012-05-09 苏州阔地网络科技有限公司 一种数据包传输处理方法及系统
CN102868600A (zh) * 2012-09-10 2013-01-09 北京用友政务软件有限公司 一种多线程报文转发方法及系统
US8504691B1 (en) * 2010-12-29 2013-08-06 Amazon Technologies, Inc. System and method for allocating resources for heterogeneous service requests

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102025649A (zh) * 2010-06-04 2011-04-20 西本新干线股份有限公司 企业服务总线的消息处理方法
CN102541653B (zh) * 2010-12-24 2013-12-25 新奥特(北京)视频技术有限公司 一种多任务线程池调度方法和系统
CN102902512B (zh) * 2012-08-31 2015-12-16 浪潮电子信息产业股份有限公司 一种基于多线程编程及消息队列的多线程并行处理方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8504691B1 (en) * 2010-12-29 2013-08-06 Amazon Technologies, Inc. System and method for allocating resources for heterogeneous service requests
CN102447628A (zh) * 2011-12-22 2012-05-09 苏州阔地网络科技有限公司 一种数据包传输处理方法及系统
CN102868600A (zh) * 2012-09-10 2013-01-09 北京用友政务软件有限公司 一种多线程报文转发方法及系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107464088A (zh) * 2016-06-02 2017-12-12 北京京东尚科信息技术有限公司 基于消息队列的业务处理系统及方法
CN107464088B (zh) * 2016-06-02 2020-09-29 北京京东尚科信息技术有限公司 基于消息队列的业务处理系统及方法

Also Published As

Publication number Publication date
CN104572290A (zh) 2015-04-29

Similar Documents

Publication Publication Date Title
WO2014187412A1 (zh) 消息处理线程的控制方法及装置
US11868163B2 (en) Efficient loop execution for a multi-threaded, self-scheduling reconfigurable computing fabric
US20220188265A1 (en) Loop Thread Order Execution Control of a Multi-Threaded, Self-Scheduling Reconfigurable Computing Fabric
US11119768B2 (en) Conditional branching control for a multi-threaded, self-scheduling reconfigurable computing fabric
US11010161B2 (en) Multiple types of thread identifiers for a multi-threaded, self-scheduling reconfigurable computing fabric
US20210224067A1 (en) Backpressure Control Using a Stop Signal for a Multi-Threaded, Self-Scheduling Reconfigurable Computing Fabric
US11635959B2 (en) Execution control of a multi-threaded, self-scheduling reconfigurable computing fabric
TWI502511B (zh) 用於管理多核心架構之資源的方法和設備
US20230153258A1 (en) Multi-Threaded, Self-Scheduling Reconfigurable Computing Fabric
US8108571B1 (en) Multithreaded DMA controller
WO2012037760A1 (zh) 提升告警处理效率的方法、服务器及系统
US20060026169A1 (en) Communication method with reduced response time in a distributed data processing system
WO2014110702A1 (zh) 协同并发式消息总线、主动构件组装模型及构件拆分方法
CN110795254A (zh) 一种基于php处理高并发io的方法
CN114579285B (zh) 一种任务运行系统、方法及计算设备
CN104714838A (zh) 一种任务调度方法及装置
WO2022257247A1 (zh) 数据处理方法、装置及计算机可读存储介质
CN101976206A (zh) 一种中断处理方法和装置
CN110032455A (zh) 通过运行时间合作进行高效通信重叠
CN112114955B (zh) Windows平台下实现单进程单线程完成端口的方法
CN115344370A (zh) 任务调度方法、装置、设备及存储介质
CN105808585B (zh) 一种流式数据的处理方法和装置
CN111290868A (zh) 任务处理方法、装置和系统以及流程引擎
WO2014110701A1 (zh) 独立主动构件和可运行主动构件组装模型及构件拆分方法
JP6413817B2 (ja) 会話管理システム、会話管理方法及び会話管理プログラム

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 14801351

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 14801351

Country of ref document: EP

Kind code of ref document: A1