CN110618881B - Method and system for simulating message queue - Google Patents

Method and system for simulating message queue Download PDF

Info

Publication number
CN110618881B
CN110618881B CN201910887938.2A CN201910887938A CN110618881B CN 110618881 B CN110618881 B CN 110618881B CN 201910887938 A CN201910887938 A CN 201910887938A CN 110618881 B CN110618881 B CN 110618881B
Authority
CN
China
Prior art keywords
target
message queue
message
receiving end
sending
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201910887938.2A
Other languages
Chinese (zh)
Other versions
CN110618881A (en
Inventor
陈涵辉
郑骁
张小翠
赵毅佳
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Bank of China Ltd
Original Assignee
Bank of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Bank of China Ltd filed Critical Bank of China Ltd
Priority to CN201910887938.2A priority Critical patent/CN110618881B/en
Publication of CN110618881A publication Critical patent/CN110618881A/en
Application granted granted Critical
Publication of CN110618881B publication Critical patent/CN110618881B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/54Interprogram communication
    • G06F9/546Message passing systems or structures, e.g. queues

Abstract

The invention discloses a method and a system for simulating a message queue, which comprises the following steps: acquiring configuration parameters, wherein the configuration parameters comprise file path information and receiving end identification information; acquiring a target file based on the file path information, wherein a plurality of texts are stored in the target file, and each text represents construction information; constructing a target message according to each text, and generating a message queue according to the target message; and sending the message queue to the receiving end according to the receiving end identification information, so that the receiving end performs testing according to the message queue. On one hand, the invention can realize the construction of the message queue without using commercial message middleware, thereby realizing the purpose of reducing the system test cost; on the other hand, the constructed message can be generated into a message queue and sent to a receiving end in the form of the message queue, and the requirement based on high-concurrency message testing is met.

Description

Method and system for simulating message queue
Technical Field
The invention relates to the technical field of testing, in particular to a method and a system for simulating a message queue.
Background
With the development of internet technology, frequent communication is performed between systems, which makes a great challenge to the design and performance of system architecture. In the process of system development and test, if a plurality of message accesses in unit time after the system is on line can be simulated, whether the target application or the system meets the performance requirement can be verified in advance.
The communication performance of the system is usually tested by transmitting message queues, and in the prior art, commercial message middleware is generally used to simulate and generate the message queues, for example, by adopting an IBM MQ implementation. However, the commercial message middleware needs to invest high cost on one hand, and can only simulate the sending process of a single message, so that the problem of simulating the test process of a high-concurrency message queue cannot be solved.
Disclosure of Invention
In view of the above problems, the present invention provides a method and a system for simulating a message queue, which achieve the purpose of low cost and being capable of simulating a high-concurrency message queue.
In order to achieve the purpose, the invention provides the following technical scheme:
a method of emulating a message queue, comprising:
acquiring configuration parameters, wherein the configuration parameters comprise file path information and receiving end identification information;
acquiring a target file based on the file path information, wherein a plurality of texts are stored in the target file, and each text represents construction information;
constructing a target message according to each text, and generating a message queue according to the target message;
and sending the message queue to the receiving end according to the receiving end identification information, so that the receiving end performs testing according to the message queue.
Optionally, the obtaining the configuration parameter includes:
judging whether a configuration file exists or not, and if so, acquiring configuration parameters in the configuration file;
if not, generating configuration parameters.
Optionally, the constructing a target message according to each text, and generating a message queue according to the target message includes:
analyzing the receiving end identification information to obtain a target message format;
constructing the text into a target message according to the target message format;
and generating a message queue according to the target message.
Optionally, the generating a message queue according to the target message includes:
when the message queue is sent to a target end through a multithread sending mode, the number of threads in the multithread sending mode is obtained;
determining the target number of the target messages written into the message queue according to the thread number;
and writing the target messages of the target quantity into the message queue to obtain the message queue.
Optionally, the method further comprises:
acquiring a sending instruction, and analyzing the sending instruction to obtain a sending mode;
and if the sending mode is the single-stroke sending mode, sending the target messages to the receiving end one by one.
A system for modeling a message queue, comprising:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring configuration parameters, and the configuration parameters comprise file path information and receiving end identification information;
a second obtaining unit, configured to obtain a target file based on the file path information, where the target file stores multiple texts, and each text represents structure information;
the generating unit is used for constructing a target message according to each text and generating a message queue according to the target message;
and the sending unit is used for sending the message queue to the receiving end according to the receiving end identification information so that the receiving end tests according to the message queue.
Optionally, the first obtaining unit includes:
the first judging subunit is used for judging whether a configuration file exists or not, and if so, acquiring configuration parameters in the configuration file;
if not, generating configuration parameters.
Optionally, the generating unit includes:
the analysis subunit is used for analyzing the receiving end identification information to obtain a target message format;
a constructing subunit, configured to construct the text into a target message according to the target message format;
and the generating subunit is used for generating a message queue according to the target message.
Optionally, the generating subunit includes:
the quantity obtaining subunit is used for obtaining the thread quantity in the multithreading sending mode when the message queue is sent to the target end through the multithreading sending mode;
the quantity determining subunit is used for determining the target quantity of the target messages written into the message queue according to the thread quantity;
and the writing subunit is used for writing the target messages with the target quantity into the message queue to obtain the message queue.
Optionally, the system further comprises:
the mode analysis subunit is used for acquiring a sending instruction and analyzing the sending instruction to obtain a sending mode;
and the single-stroke sending subunit is configured to send the target message to the receiving end one by one if the sending mode is the single-stroke sending mode.
Compared with the prior art, the invention provides a method and a system for simulating a message queue, which are used for acquiring a target file based on configuration parameters, constructing a target message, generating the message queue, and then sending the message queue to a receiving end according to identification information of the receiving end, so that the purpose that the receiving end tests based on the message queue is realized. On one hand, the invention can realize the construction of the message queue without using commercial message middleware, thereby realizing the purpose of reducing the system test cost; on the other hand, the constructed message can be generated into a message queue and sent to a receiving end in the form of the message queue, and the requirement based on high-concurrency message testing is met.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
Fig. 1 is a schematic flowchart illustrating a method for simulating a message queue according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a system for simulating a message queue according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The terms "first" and "second," and the like in the description and claims of the present invention and the above-described drawings are used for distinguishing between different objects and not for describing a particular order. Furthermore, the terms "comprising" and "having," as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not set forth for a listed step or element but may include steps or elements not listed.
The embodiment of the invention provides a method for simulating a message queue, wherein the message queue is a queue formed by messages for testing the communication performance of a system, and the message queue is simulated, namely the message queue is generated for testing and is not generated by actual communication between systems.
Referring to fig. 1, which is a flowchart illustrating a method for simulating a message queue according to an embodiment of the present invention, the method may include the following steps:
s101, acquiring configuration parameters;
the configuration parameters represent test parameters and test content information of a system to be tested, for example, the configuration parameters include file path information and receiving end identification information, wherein the receiving end identification information identifies relevant information of the system to be tested, such as a test port, a test thread and the like, and the file path information represents a file test storage position capable of generating a test message queue.
In the embodiment of the present invention, two ways are provided to obtain the configuration parameters, wherein one way is to store the configuration parameters in a configuration file and directly obtain the configuration file before the test, and the other way is to generate the configuration parameters according to the relevant parameters of the system under test based on the relevant parameters input by the user. When the configuration parameters are stored in the mode of configuration files, subsequent repeated use can be facilitated, the configuration parameters can be generated by the relevant test information input by a user, and the purpose of flexibly processing the configuration parameters can be achieved.
S102, acquiring a target file based on the file path information;
a plurality of texts are stored in the target file, and each text represents construction information;
s103, constructing a target message according to each text, and generating a message queue according to the target message;
in order to generate the message queue quickly and efficiently, the tested message file can be stored in the corresponding folder in advance, and when the test is needed, the corresponding target file or text can be acquired to construct the target message based on the file path information. And organizing the target message according to the identification information of the tested system, such as the thread identification representing the number of threads of the tested system, to generate a message queue.
And S104, sending the message queue to the receiving end according to the receiving end identification information, so that the receiving end performs testing according to the message queue.
And sending the message queue to a receiving end to realize the test of the receiving end.
On the basis of the above embodiment, another embodiment of the present invention further provides a method for generating a message queue, where the method includes:
analyzing the receiving end identification information to obtain a target message format;
constructing the text into a target message according to the target message format;
and generating a message queue according to the target message.
Because different tested systems, namely receiving ends, the interface formats of the received data are different. The message queue meeting the receiving end is obtained by analyzing the identification information of the receiving end. Generally, the text stored in the target file is in a general format, and the text in the general format needs to be constructed into a target message meeting the message format of the receiving end, and then a message queue is generated according to the target message.
Specifically, when a message queue is sent to a target end through a multi-thread sending mode, the number of threads in the multi-thread sending mode is obtained; determining the target number of the target messages written into the message queue according to the thread number; and writing the target messages of the target quantity into the message queue to obtain the message queue.
In the test method provided in the embodiment of the present invention, in addition to the test process capable of simulating the message queue, a simulation test process of single-stroke transmission may be performed, which specifically includes:
acquiring a sending instruction, and analyzing the sending instruction to obtain a sending mode;
and if the sending mode is the single-stroke sending mode, sending the target messages to the receiving end one by one.
The target message can be sent one by one, or the message content input by the user can be directly obtained, then the message is sent in a single-stroke sending mode, and then the sent message can be written into a message queue by adopting a message processing module.
The invention provides a method for simulating a message queue, which is characterized in that a target file is obtained based on configuration parameters, a target message is constructed, a message queue is generated, and then the message queue is sent to a receiving end according to identification information of the receiving end, so that the aim of testing the receiving end based on the message queue is fulfilled. On one hand, the invention can realize the construction of the message queue without using commercial message middleware, thereby realizing the purpose of reducing the system test cost; on the other hand, the constructed message can be generated into a message queue and sent to a receiving end in the form of the message queue, and the requirement based on high-concurrency message testing is met.
Correspondingly, the embodiment of the present invention may create a message queue high concurrency reporting tool based on the above message queue simulation method and related content, where the tool may include an information acquisition module, and the information acquisition module may generate an information frame for a user to fill in configuration parameters of a target application, i.e., a test application, such as an IP, a port, a queue management name, and a target queue parameter, and store the configuration parameters. And then loading a configuration file based on a loading module, reading the information of the configuration file, or manually modifying the configuration information on a message queue high concurrent reporting tool interface by a user, then selecting a folder of a system drive letter on the interface, selecting a tested message file, loading the selected file, reading the content of the file, clicking a plurality of times on the tool interface for sending, triggering the processing logic of the multithreading pooling module, and sending the message in the message queue to a target test application at the same time.
Therefore, the message queue high-concurrency report sending tool provided by the embodiment of the invention comprises a multi-thread pool technology, realizes high concurrency, ensures that messages are not repeated and sequenced, and meets the requirements of a test scene; the method has the advantages of no need of installation, simple configuration of target application parameters, reduction of learning cost, provision of single-stroke and multi-stroke message sending functions and satisfaction of various test requirements.
Correspondingly, in an embodiment of the present invention, a system for simulating a message queue is further provided, and referring to fig. 2, the system includes:
a first obtaining unit 10, configured to obtain configuration parameters, where the configuration parameters include file path information and receiving end identification information;
a second obtaining unit 20, configured to obtain a target file based on the file path information, where the target file stores multiple texts, and each text represents structure information;
a generating unit 30, configured to construct a target message according to each text, and generate a message queue according to the target message;
a sending unit 40, configured to send the message queue to the receiving end according to the receiving end identification information, so that the receiving end performs a test according to the message queue.
The invention provides a system for simulating a message queue, which is characterized in that a target file is obtained based on configuration parameters, a target message is constructed, a message queue is generated, and then the message queue is sent to a receiving end according to identification information of the receiving end, so that the aim of testing the receiving end based on the message queue is fulfilled. On one hand, the invention can realize the construction of the message queue without using commercial message middleware, thereby realizing the purpose of reducing the system test cost; on the other hand, the constructed message can be generated into a message queue and sent to a receiving end in the form of the message queue, and the requirement based on high-concurrency message testing is met.
On the basis of the above embodiment, the first acquisition unit includes:
the first judging subunit is used for judging whether a configuration file exists or not, and if so, acquiring configuration parameters in the configuration file;
if not, generating configuration parameters.
On the basis of the above embodiment, the generating unit includes:
the analysis subunit is used for analyzing the receiving end identification information to obtain a target message format;
a constructing subunit, configured to construct the text into a target message according to the target message format;
and the generating subunit is used for generating a message queue according to the target message.
On the basis of the above embodiment, the generating subunit includes:
the quantity obtaining subunit is used for obtaining the thread quantity in the multithreading sending mode when the message queue is sent to the target end through the multithreading sending mode;
the quantity determining subunit is used for determining the target quantity of the target messages written into the message queue according to the thread quantity;
and the writing subunit is used for writing the target messages with the target quantity into the message queue to obtain the message queue.
On the basis of the above embodiment, the system further includes:
the mode analysis subunit is used for acquiring a sending instruction and analyzing the sending instruction to obtain a sending mode;
and the single-stroke sending subunit is configured to send the target message to the receiving end one by one if the sending mode is the single-stroke sending mode.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. The device disclosed by the embodiment corresponds to the method disclosed by the embodiment, so that the description is simple, and the relevant points can be referred to the method part for description.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (8)

1. A method for emulating a message queue, comprising:
acquiring configuration parameters, wherein the configuration parameters comprise file path information and receiving end identification information; the receiving end identification information at least identifies a testing port and a testing thread of a system to be tested; the file path information represents a file storage position capable of generating a test message queue;
acquiring a target file based on the file path information, wherein a plurality of texts are stored in the target file, and each text represents construction information;
analyzing the receiving end identification information to obtain a target message format;
constructing the text into a target message according to the target message format;
generating a message queue according to the target message;
and sending the message queue to the receiving end according to the receiving end identification information, so that the receiving end performs testing according to the message queue.
2. The method of claim 1, wherein the obtaining the configuration parameters comprises:
judging whether a configuration file exists or not, and if so, acquiring configuration parameters in the configuration file;
if not, generating configuration parameters.
3. The method of claim 1, wherein generating a message queue from the target message comprises:
when the message queue is sent to a target end through a multithread sending mode, the number of threads in the multithread sending mode is obtained;
determining the target number of the target messages written into the message queue according to the thread number;
and writing the target messages of the target quantity into the message queue to obtain the message queue.
4. The method of claim 1, further comprising:
acquiring a sending instruction, and analyzing the sending instruction to obtain a sending mode;
and if the sending mode is the single-stroke sending mode, sending the target messages to the receiving end one by one.
5. A system for modeling a message queue, comprising:
the device comprises a first acquisition unit, a second acquisition unit and a third acquisition unit, wherein the first acquisition unit is used for acquiring configuration parameters, and the configuration parameters comprise file path information and receiving end identification information; the receiving end identification information at least identifies a testing port and a testing thread of a system to be tested; the file path information represents a file storage position capable of generating a test message queue;
a second obtaining unit, configured to obtain a target file based on the file path information, where the target file stores multiple texts, and each text represents structure information;
the generation unit includes: the analysis subunit, the construction subunit and the generation subunit;
the analysis subunit is configured to analyze the receiving end identification information to obtain a target message format;
the constructing subunit is used for constructing the text into the target message according to the target message format;
the generating subunit is configured to generate a message queue according to the target message;
and the sending unit is used for sending the message queue to the receiving end according to the receiving end identification information so that the receiving end tests according to the message queue.
6. The system of claim 5, wherein the first obtaining unit comprises:
the first judging subunit is used for judging whether a configuration file exists or not, and if so, acquiring configuration parameters in the configuration file;
if not, generating configuration parameters.
7. The system of claim 5, wherein the generating subunit comprises:
the quantity obtaining subunit is used for obtaining the thread quantity in the multithreading sending mode when the message queue is sent to the target end through the multithreading sending mode;
the quantity determining subunit is used for determining the target quantity of the target messages written into the message queue according to the thread quantity;
and the writing subunit is used for writing the target messages with the target quantity into the message queue to obtain the message queue.
8. The system of claim 5, further comprising:
the mode analysis subunit is used for acquiring a sending instruction and analyzing the sending instruction to obtain a sending mode;
and the single-stroke sending subunit is configured to send the target message to the receiving end one by one if the sending mode is the single-stroke sending mode.
CN201910887938.2A 2019-09-19 2019-09-19 Method and system for simulating message queue Active CN110618881B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910887938.2A CN110618881B (en) 2019-09-19 2019-09-19 Method and system for simulating message queue

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910887938.2A CN110618881B (en) 2019-09-19 2019-09-19 Method and system for simulating message queue

Publications (2)

Publication Number Publication Date
CN110618881A CN110618881A (en) 2019-12-27
CN110618881B true CN110618881B (en) 2022-04-12

Family

ID=68923608

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910887938.2A Active CN110618881B (en) 2019-09-19 2019-09-19 Method and system for simulating message queue

Country Status (1)

Country Link
CN (1) CN110618881B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112202636B (en) * 2020-09-29 2022-06-17 中国银行股份有限公司 Communication test method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6363414B1 (en) * 1998-12-29 2002-03-26 Pitney Bowes Ltd. Method for converting an email message to a different format and retransmitting to a location other than recipient address information in the email message
CN104348805A (en) * 2013-07-31 2015-02-11 南京中兴力维软件有限公司 Asynchronous file transmission method, apparatus and system
CN105472042A (en) * 2016-01-15 2016-04-06 中煤电气有限公司 WEB terminal controlled message middleware system and data transmission method thereof
CN106484652A (en) * 2016-10-26 2017-03-08 郑州云海信息技术有限公司 A kind of many queue communication method and system based on NTB hardware
CN109729003A (en) * 2018-12-28 2019-05-07 济南铁路信息技术有限公司 A kind of passenger train time data transmission method and system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20030036966A1 (en) * 2001-08-16 2003-02-20 International Business Machines Corporation Computer system, method, and business method for integrating an e-commerce application with a back-end business processing application
JP2017111581A (en) * 2015-12-15 2017-06-22 キヤノン株式会社 Information processing system, and control method

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US6363414B1 (en) * 1998-12-29 2002-03-26 Pitney Bowes Ltd. Method for converting an email message to a different format and retransmitting to a location other than recipient address information in the email message
CN104348805A (en) * 2013-07-31 2015-02-11 南京中兴力维软件有限公司 Asynchronous file transmission method, apparatus and system
CN105472042A (en) * 2016-01-15 2016-04-06 中煤电气有限公司 WEB terminal controlled message middleware system and data transmission method thereof
CN106484652A (en) * 2016-10-26 2017-03-08 郑州云海信息技术有限公司 A kind of many queue communication method and system based on NTB hardware
CN109729003A (en) * 2018-12-28 2019-05-07 济南铁路信息技术有限公司 A kind of passenger train time data transmission method and system

Also Published As

Publication number Publication date
CN110618881A (en) 2019-12-27

Similar Documents

Publication Publication Date Title
CN109302522B (en) Test method, test device, computer system, and computer medium
CN107436844B (en) Method and device for generating interface use case aggregate
CN107526676B (en) Cross-system test method and device
US8660833B2 (en) Method, computer program product and apparatus for providing an interactive network simulator
CN107957940B (en) Test log processing method, system and terminal
CN111159049A (en) Automatic interface testing method and system
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
CN106357719A (en) Page-based incident correlation for network applications
CN107045475B (en) Test method and device
CN115065652B (en) Message reply method and device, storage medium and computer equipment
CN111258913A (en) Automatic algorithm testing method and device, computer system and readable storage medium
CN109739704A (en) A kind of interface test method, server-side and computer readable storage medium
CN111737125A (en) Method and device for generating market data of quantitative transaction and server
CN112148580A (en) Test method and device and electronic equipment
CN110515514B (en) Data processing method, device and storage medium
CN108965274A (en) The analysis method and device of DBC file
CN110618881B (en) Method and system for simulating message queue
CN109587351B (en) Call testing method, device, equipment and storage medium
CN109460365B (en) A kind of system performance testing method, apparatus, equipment and storage medium
CN112965711A (en) Job test method and apparatus, electronic device, and storage medium
CN111488731A (en) File generation method and device, computer equipment and storage medium
CN115118687B (en) Message pushing method and device, storage medium and computer equipment
CN106294104B (en) Test case execution method and mobile terminal
CN115145777A (en) Test method, system, device and storage medium
CN111294250B (en) Pressure testing method, device and system

Legal Events

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