CN114513504A - Message queue multi-cloud adaptation method, device and equipment and readable storage medium - Google Patents

Message queue multi-cloud adaptation method, device and equipment and readable storage medium Download PDF

Info

Publication number
CN114513504A
CN114513504A CN202210357772.5A CN202210357772A CN114513504A CN 114513504 A CN114513504 A CN 114513504A CN 202210357772 A CN202210357772 A CN 202210357772A CN 114513504 A CN114513504 A CN 114513504A
Authority
CN
China
Prior art keywords
message
cloud
target
message queue
consumer
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210357772.5A
Other languages
Chinese (zh)
Inventor
王晓旭
黄鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Glodon Co Ltd
Original Assignee
Glodon Co 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 Glodon Co Ltd filed Critical Glodon Co Ltd
Priority to CN202210357772.5A priority Critical patent/CN114513504A/en
Publication of CN114513504A publication Critical patent/CN114513504A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/06Protocols specially adapted for file transfer, e.g. file transfer protocol [FTP]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • H04L67/306User profiles

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The invention discloses a method, a device, equipment and a readable storage medium for multi-cloud adaptation of a message queue, wherein the method comprises the following steps: receiving cloud migration instructions for switching an existing cloud docked with the target object to a target cloud; analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction; configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance; performing, by the producer instance and the consumer instance, a message processing operation between the target object and a message queue on the target cloud; the invention can efficiently and flexibly adapt to the message queues on various clouds under the condition of not modifying the product code.

Description

Message queue multi-cloud adaptation method, device and equipment and readable storage medium
Technical Field
The invention relates to the technical field of computers, in particular to a method, a device and equipment for multi-cloud adaptation of a message queue and a readable storage medium.
Background
With the development of cloud environment service technology, many companies need to interface cloud environment services of private cloud, shared cloud, or hybrid cloud, and message queues are used depending on cloud environments, and different types of message queues are deployed on different cloud environments, for example: in Alice cloud, there is RockettMQ, in Hua cloud, there is RabbitMQ.
In addition, although a binding device of Spring Cloud Stream can be used for solving the problem of Cloud environment migration in the prior art, the method has the disadvantages of high learning cost, complex operation and poor universality.
Therefore, how to efficiently and flexibly adapt message queues on various clouds without modifying product codes becomes a technical problem that needs to be solved by technical personnel in the field.
Disclosure of Invention
The invention aims to provide a method, a device and equipment for multi-cloud adaptation of a message queue and a readable storage medium, which can efficiently and flexibly adapt the message queue on various clouds under the condition of not modifying a product code.
According to one aspect of the invention, a method for multi-cloud adaptation of a message queue is provided, which is applied to a target object needing to use the message queue on a cloud, and the method comprises the following steps:
receiving cloud migration instructions for switching an existing cloud docked with the target object to a target cloud;
analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction;
configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance;
performing message processing operations between the target object and a message queue on the target cloud via the producer instance and the consumer instance.
Optionally, the configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance include:
acquiring a target producer template and a target consumer template corresponding to the type of the message queue on the target cloud from a preset template library;
adding configuration parameters of each configuration item in the configuration file to the target producer template to obtain one or more producer instances;
and adding the configuration parameters of the configuration items in the configuration file to the target consumer template to obtain one or more consumer instances.
Optionally, the performing, by the producer instance and the consumer instance, a message processing operation between the target object and a message queue on the target cloud includes:
acquiring a message to be sent generated by the target object; wherein the message to be sent comprises: the message body comprises a message body and a message header, wherein the message body comprises a message subject and a message label;
and sending the message to be sent to a message queue on the target cloud through the producer instance.
Optionally, the sending the message to be sent to the message queue on the target cloud through the producer instance includes:
judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
if so, acquiring a message theme and a message label in the message to be sent, and acquiring a group number of a consumer for consuming the message to be sent;
searching a target message queue with a queue name comprising the message subject, the message label and the grouping number from the target cloud through the producer instance; wherein the target cloud comprises a plurality of message queues;
and sending the message to be sent to the target message queue through the producer instance.
Optionally, the performing, by the producer instance and the consumer instance, a message processing operation between the target object and a message queue on the target cloud includes:
obtaining a message to be consumed from a message queue on the target cloud through the consumer instance;
and sending the message to be consumed to the target object.
Optionally, the obtaining, by the consumer instance, a message to be consumed from a message queue on the target cloud includes:
judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
if yes, acquiring a message theme and a message label subscribed by the target object, and acquiring a group number of the target object;
finding a target message queue with a queue name comprising the message topic, the message label and the grouping number from the target cloud through the consumer instance; wherein the target cloud comprises a plurality of message queues;
and acquiring the message to be consumed from the target message queue through the consumer instance.
Optionally, the message queue on the target cloud includes the following types:
RocktMQ, RabbitMQ, Kafka, TDMQ of Tencent cloud, SQS of AWS, and EMQ of IOT.
In order to achieve the above object, the present invention further provides a device for multi-cloud adaptation of a message queue, which is applied to a target object that needs to use the message queue on a cloud, and the device includes:
a receiving module, configured to receive a cloud migration instruction for switching an existing cloud docked with the target object to a target cloud;
the analysis module is used for analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction;
the configuration module is used for configuring a preset producer template according to the configuration file to obtain a producer example and configuring a preset consumer template according to the configuration file to obtain a consumer example;
a processing module to perform message processing operations between the target object and a message queue on the target cloud via the producer instance and the consumer instance.
In order to achieve the above object, the present invention further provides a computer device, which specifically includes: a memory, a processor and a computer program stored on the memory and executable on the processor, the processor implementing the above introduced steps of the method of message queue multi-cloud adaptation when executing the computer program.
In order to achieve the above object, the present invention further provides a computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, implements the above-introduced steps of the method for message queue multi-cloud adaptation.
According to the message queue multi-cloud adaptation method, the message queue multi-cloud adaptation device, the message queue multi-cloud adaptation equipment and the readable storage medium, when a target product needs to be migrated in a cloud environment, the configuration file of the message queue on the migrated target cloud is obtained, and the corresponding producer instance and consumer instance are generated according to the configuration file, so that the target product can be communicated with the message queue on the target cloud through the producer instance and the consumer instance, product codes of the target product do not need to be modified, the message queue can be switched to different types of message queues on different clouds only by using the configuration file, and a flexible adaptation effect is achieved; the format of the queue name of the message queue in the point-to-point mode is set so that the message queue in the point-to-point mode can be compatible with the message generated according to the message queue in the publish-subscribe mode, and therefore the message queue in the publish-subscribe mode and the message queue in the point-to-point mode are compatible simultaneously under the condition that the bottom service code of the target object is not changed.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is an alternative flowchart of a method for adapting a message queue to multiple clouds according to an embodiment;
FIG. 2 is a schematic diagram of a point-to-point model production consumption process according to an embodiment;
FIG. 3 is a schematic diagram illustrating a production and consumption process of a publish-subscribe pattern according to an embodiment;
fig. 4 is a schematic flowchart of another alternative method for adapting a message queue to multiple clouds according to the second embodiment;
FIG. 5 is a schematic diagram of a configuration file of a RockketMQ provided in example two;
fig. 6 is a schematic diagram of a configuration file of a RabbitMQ provided in the second embodiment;
fig. 7 is an alternative structural diagram of a message queue multi-cloud adaptation apparatus provided in the third embodiment;
fig. 8 is an alternative hardware architecture diagram of the computer device according to the fourth embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. 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.
Example one
The embodiment of the invention provides a method for multi-cloud adaptation of a message queue, which is applied to a target object needing to use the message queue on a cloud, and as shown in figure 1, the method specifically comprises the following steps:
step S101: receiving cloud migration instructions for switching an existing cloud docked with the target object to a target cloud.
The cloud migration instruction is used for switching an existing cloud currently used by the target object to the target cloud, and the type of a message queue on the existing cloud is different from that on the target cloud.
A message queue is a queued carrier that holds messages in the form of queues during the transmission of messages.
In this embodiment, based on the requirement of the user, it is necessary to switch from the message queue on the existing cloud to the message queue on the target cloud, and different types of message queues exist on different clouds, for example: the type of a message queue on the Alice cloud currently used by a user is RockettMQ, and the message queue needs to be switched to the Huawei cloud with the message queue type of RabbitMQ.
Specifically, the message queue on the target cloud includes the following types:
RocktMQ, RabbitMQ, Kafka, TDMQ of Tencent cloud, SQS of AWS, and EMQ of IOT.
Step S102: and analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction.
The system loads different configuration files to instantiate corresponding message queue service, so that the target object uses various types of message queues.
In addition, the configuration file template comprises a plurality of configuration items, the configuration items in the configuration file templates corresponding to different types of message queues are also different, and the configuration files are generated by adding configuration parameters to the configuration items in the configuration file templates.
In the embodiment, corresponding configuration file templates are configured in advance for different types of message queues, when the message queue on the target cloud needs to be switched, the configuration file template corresponding to the message queue on the target cloud is obtained, modifying the configuration item parameters in the configuration file template to form a configuration file, generating a producer instance and a consumer instance for a preset producer template and a preset consumer template according to the configuration file, further, the message transmission is carried out on the target cloud through the producer instance and the consumer instance, the message queue of the existing cloud can be switched to the message queue of the target cloud without changing the code of the target object, flexible adaptation and modification are achieved, in addition, when the message queue on the third cloud needs to be switched, the switching can be performed only by acquiring the configuration file corresponding to the message queue on the third cloud, and flexible switching can be performed among the clouds.
Step S103: and configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance.
Specifically, step S103 includes:
step A1: acquiring a target producer template and a target consumer template corresponding to the type of the message queue on the target cloud from a preset template library;
the message transmission mode in the message queue is that the producer produces the message and sends the message to the message queue, and then the consumer consumes the message in the message queue.
And setting corresponding producer templates and consumer templates for different types of message queues in advance so as to obtain producer instances and consumer instances of corresponding message queue types by using the producer templates and the consumer templates.
Step A2: adding configuration parameters of each configuration item in the configuration file to the target producer template to obtain one or more producer instances;
step A3: and adding the configuration parameters of the configuration items in the configuration file to the target consumer template to obtain one or more consumer instances.
In the embodiment, a plurality of producer instances and a plurality of consumer instances can be generated through a configuration file to realize multi-instance deployment; specifically, when the configuration file is in the form of a unit number, one producer instance and one consumer instance are generated, and when the configuration file is in the form of an array, a plurality of producer instances and a plurality of consumer instances are generated.
Step S104: performing message processing operations between the target object and a message queue on the target cloud via the producer instance and the consumer instance.
Specifically, step S104 includes:
step B1: acquiring a message to be sent generated by the target object; wherein the message to be sent comprises: the message body comprises a message body and a message header, wherein the message body comprises a message subject and a message label;
in practical application, the message transmitted in the message queue includes a message header and a message body, the message header is used for specifying a path for the message to be consumed, so that a consumer can subscribe to and consume the message according to the message header, and the message body is used for carrying message content.
In addition, only the message topic is stored in the message header part of the existing message, and in the embodiment, the message tag is added in the message header of the message, so that a consumer can find out the specified information for consumption according to the message topic and the message tag, and a deeper secondary tag subscription function is realized.
Step B2: and sending the message to be sent to a message queue on the target cloud through the producer instance.
Specifically, step B2 includes:
step C1: judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
in this embodiment, the transmission mode of the message queue includes a point-to-point mode and a publish-subscribe mode, where the publish-subscribe mode is that a producer transmits a message to a message queue on a target cloud in the form of a message topic and a message tag, a consumer can consume messages in the message queue on the target cloud in the form of the message topic and the message tag, and each message can be a plurality of consumer messages; in the point-to-point mode, the producer transmits the message to the message queue on the target cloud, the consumer consumes the message in the specified message queue on the target cloud, and the consumed message is eliminated from the message queue on the target cloud, so that one message can be consumed by only one consumer.
Step C2: if so, acquiring a message theme and a message label in the message to be sent, and acquiring a group number of a consumer for consuming the message to be sent;
the method comprises the steps of setting a corresponding group number for each consumer in advance, and combining the group number with a message theme and a message label in a message to be sent so as to search a target information queue conveniently.
Step C3: searching a target message queue with a queue name comprising the message subject, the message label and the grouping number from the target cloud through the producer instance; wherein the target cloud comprises a plurality of message queues;
step C4: and sending the message to be sent to the target message queue through the producer instance.
In order to implement compatibility between two message transmission modes, namely a point-to-point mode and a publish-and-subscribe mode, in the cloud migration process, as shown in fig. 2, in this embodiment, the point-to-point mode is improved so that messages meeting the publish-and-subscribe mode can be used by message queues in the point-to-point mode, specifically, a plurality of message queues are created on a target cloud in the point-to-point mode, and a queue name is set for each created message queue according to a naming mode of "message Topic + message Tag + Group number Group ID", so that messages generated by a target object can be stored not only on the target cloud in the publish-and-subscribe mode but also on the target cloud in the point-to-point mode. In addition, the consumer also finds out a corresponding message queue on the target cloud according to the message topic, the message label and the grouping number so as to consume the messages in the message queue.
As shown in fig. 3, the publish-subscribe pattern in this embodiment still adopts the existing publish-subscribe pattern, and the difference is that the existing publish-subscribe pattern only sorts messages according to the message Topic, but in this embodiment, sorts the messages on the target cloud according to the message Topic and the message Tag, and the manner of adding the message Tag can enable the consumer to subscribe and consume the messages in the message queue with finer granularity.
Further, step S104 further includes:
step D1: obtaining a message to be consumed from a message queue on the target cloud through the consumer instance;
step D2: and sending the message to be consumed to the target object.
Specifically, the step D1 includes:
step E1: judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
step E2: if yes, acquiring a message theme and a message label subscribed by the target object, and acquiring a group number of the target object;
step E3: finding a target message queue with a queue name comprising the message topic, the message label and the grouping number from the target cloud through the consumer instance; wherein the target cloud comprises a plurality of message queues;
step E4: and acquiring the message to be consumed from the target message queue through the consumer instance.
In practical application, according to the requirement of the target object on the message, the message can be produced by using the producer instance, and the message can also be consumed by using the consumer instance, so that no matter whether the requirement of the target object is to produce the message or consume the message, the message can be adaptively converted according to the transmission mode of the message queue on the target cloud after cloud migration, and the requirement of the target object on transmitting the message can be met.
In this embodiment, when a target product needs to be migrated in a cloud environment, the target product is communicated with a message queue on a target cloud through a producer instance and a consumer instance by acquiring a configuration file of the message queue on the migrated target cloud and generating a corresponding producer instance and consumer instance according to the configuration file, without modifying a product code of the target product, and the target product can be switched to different types of message queues on different clouds by using the configuration file, so that a flexible adaptation effect is achieved; the format of the queue name of the message queue in the point-to-point mode is set so that the message queue in the point-to-point mode can be compatible with the message generated according to the message queue in the publish-subscribe mode, and therefore the message queue in the publish-subscribe mode and the message queue in the point-to-point mode are compatible simultaneously under the condition that the bottom service code of the target object is not changed.
Example two
The embodiment of the present invention provides a message queue multi-cloud adaptation method, which is included in a message-queue-timer software development kit (jar package) shown in fig. 4, and is used by a callee (equivalent to a target object in the first embodiment) of the message-queue-timer software development kit, where the caller may be a product or a certain service that needs to send and receive a message, and the message-queue-timer software development kit is introduced into a code of the caller and different configuration file templates are used to switch and use different message queues, where the method specifically includes the following steps:
step S201: receiving cloud migration instructions for switching an existing cloud interfaced with the caller to a target cloud.
The cloud migration instruction is used for switching an existing cloud used by a caller to a target cloud, and the type of a message queue on the existing cloud is different from that on the target cloud.
Step S202: and analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction.
In this embodiment, corresponding configuration file templates are configured for different types of message queues in advance, so as to distinguish different configuration files by different prefixes in the configuration file templates, and the system loads different configuration files to instantiate corresponding message queue services, thereby implementing that the target object uses various types of message queues.
As shown in fig. 5, which is a configuration file of a rockmq, and as shown in fig. 6, which is a configuration file of a RabbitMQ, prefixes of different configuration file templates are different, and the type of a message queue corresponding to the configuration file template is determined by the prefixes of the configuration file templates, for example: as shown in fig. 5, the configuration file template of rockmq is prefixed with paas: mq: ons: and as shown in fig. 6, the configuration file of RabbitMQ is prefixed by paas: mq: rabbitmq: . Further, a plurality of configuration items are included in the profile template, and the configuration items of different profile templates are different, for example, as shown in fig. 5, an address (namesrv-addr) is included in the profile template of rocktmq, and a domain name (host) is included in the profile template of RabbitMQ as shown in fig. 6. And adding configuration parameters to each configuration item in the configuration file template to form a configuration file.
In this embodiment, corresponding configuration file templates are pre-configured for different types of message queues, when a message queue on a target cloud needs to be switched to, a configuration file template corresponding to the message queue on the target cloud is obtained, configuration item parameters in the configuration file template are modified to form a configuration file, a producer instance and a consumer instance are generated according to the configuration file for a preset producer template and a consumer template, and then message transmission is performed on the target cloud through the producer instance and the consumer instance, so that the message queue of the existing cloud can be switched to the message queue of the target cloud without changing a code of a target object, flexible adaptive modification is achieved, and when the message queue on another cloud needs to be switched to, the switching can be performed only by obtaining a configuration file corresponding to the message queue on another cloud, and the switching can be performed on the message queue of the existing cloud, And flexibly switching between the target cloud and the other cloud.
Step S203: and configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance.
Specifically, step S03 includes:
step F1: acquiring a target producer template and a target consumer template corresponding to the type of the message queue on the target cloud from a preset template library;
step F2: adding configuration parameters of each configuration item in the configuration file to the target producer template to obtain one or more producer instances;
step F3: adding the configuration parameters of each configuration item in the configuration file to the target consumer template to obtain one or more consumer instances.
In practical applications, as shown in fig. 4, the message-queue-timer software development kit may start a corresponding AutoConfiguration (i.e., an automatic assembly component in the spring boot) according to the type of the message queue corresponding to the configuration file, so as to complete the assembly of the target producer template and the target consumer template through the AutoConfiguration.
In this embodiment, an automatic assembly mode of the SpringBoot is used, where the SpringBoot is a Java Web application development framework and can support automatic assembly of configuration files, and a specific instance can be automatically assembled only by changing configuration item parameters of the configuration files.
In the present embodiment, the configuration file is automatically assembled by the SpringBoot to configure the producer template and the consumer template; for example: when the RabbitMQ is automatically assembled, the RabbitMQAuutoconfiguration is started, a RabbitMQ producer template and a RabbitMQ consumer template are obtained from a preset template library, and configuration parameters of each configuration item in the configuration file are added to the RabbitMQ producer template and the RabbitMQ consumer template through the RabbitMQAuutoconfiguration.
As shown in fig. 4, corresponding autoconfigurations are set for the rockmq, RabbitMQ, Kafka, TDMQ of the tenuous cloud, SQS of the AWS, and EMQ of the IOT, and corresponding producer instances and consumer instances are generated by using the autoconfigurations corresponding to each message queue according to the configuration file; since the producer and consumer instances corresponding to the EMQ of Kafka, TDMQ of tengement cloud, SQS of AWS, and IOT, respectively, are the same form as the producer and consumer instances corresponding to rocktmq, RabbitMQ, respectively, in fig. 4, the producer and consumer instances corresponding to the EMQ of Kafka, TDMQ of tengement cloud, SQS of AWS, and IOT, respectively, are not exhibited.
In this embodiment, the automatic assembly type AutoConfiguration of various types of message queues utilizes an automatic assembly mechanism of a spring boot object, and can instantiate a message queue instance according to a configuration item in a configuration file, so as to switch the message queues.
Further, as shown in fig. 4, in the present embodiment, multi-instance deployment may be implemented, that is, multiple producer instances and multiple consumer instances are generated through a configuration file. Typically, when a configuration file is a single element, one producer instance and one consumer instance are generated; when the configuration file is in array form, multiple producer instances and multiple consumer instances are generated.
Step S204: when the caller is a generator role, acquiring information to be sent generated by the caller; wherein the information to be transmitted includes: a message header and a message body, wherein the message header comprises an information subject Topic and a message Tag.
In practical application, a message transmitted in a message queue includes a message header and a message body, wherein the message header is used for specifying a path for the message to be consumed, and includes a message Topic and a message Tag, so that a consumer can subscribe and consume according to the message header, and the message body is used for carrying message content.
In addition, only the message topic is stored in the message header part of the existing message, and in the embodiment, the message tag is added to the message header of the message to realize a deeper secondary tag subscription function, so that a consumer can find out the specified information according to the message topic and the message tag for consumption.
Specifically, the present embodiment includes two types of Message messages: the message to be sent and the message to be consumed both comprise a message head and a message body, wherein the message head comprises a message subject Topic and a message Tag, and the message body is uniformly converted into a byte array, so that the compatibility of different message formats is realized.
In this embodiment, the common field is abstracted according to the Message formats of the six Message queues and added to the Message, that is, the field content and format of the Message are redefined in this embodiment, so as to be compatible with the six different types of Message queues.
Step S205: and calling the Producer instance through a preset Producer interface to send the message to be sent to a message queue on the target cloud.
In the present embodiment, a message-queue-timer software development kit encapsulates a general outgoing interface (i.e., Producer interface) and a receiving interface (i.e., Consumer interface) for a caller, so as to call a specific Producer instance through the outgoing interface and call a specific Consumer instance through the receiving interface.
In addition, in this embodiment, the producer instance also performs adaptive conversion on the message to be sent, so that the converted message to be sent meets the requirement of the message queue on the target cloud.
Specifically, step S205 includes:
step G1: judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
step G2: if so, acquiring a message theme and a message label in the message to be sent, and acquiring a group number of a consumer for consuming the message to be sent;
step G3: searching a target message queue with a queue name containing the message subject, the message label and the grouping number from the target cloud through the producer instance; wherein the target cloud comprises a plurality of message queues;
step G4: and sending the message to be sent to the target message queue through the producer instance.
In this embodiment, as shown in fig. 2, the message-queue-initiator software development kit creates a redundant queue group on the target cloud, where the redundant queue group includes a plurality of message queues, and queue names of each message queue in the redundant queue group are named according to a format of "message Topic + message Tag + group number GroupID". Since the message Topic and the message Tag may exist in the message queue in the publish-subscribe mode, and the message Topic and the message Tag may not exist in the message queue in the peer-to-peer mode, in this embodiment, in order to allow the message queue in the peer-to-peer mode to process the message with the message Topic and the message Tag (i.e., the message conforming to the message queue in the publish-subscribe mode), the message Topic and the message Tag are added to the message queue name in the peer-to-peer mode, so that the message queue in the peer-to-peer mode is compatible with the message queue in the publish-subscribe mode.
In addition, when the transmission mode of the message queue on the target cloud is a publish-subscribe mode, the message to be sent is sent to the target message queue through the producer instance according to the existing publish-subscribe model. Specifically, as shown in fig. 3, in this embodiment, the message-queue-timer software development kit creates different message topics Topic in the Broker service on the target cloud, and sets a plurality of message tags Tag for each message Topic. As shown in fig. 3, according to the Topic and the Tag in the message to be sent, the message to be sent is stored in a target message queue corresponding to the Topic and the Tag in the Broker server on the target cloud.
In this embodiment, according to the requirement of the caller, the caller can serve as a producer role to store the message to be sent into the message queue on the target cloud, and can also serve as a consumer role to consume the message stored in the message queue on the target cloud. Here, the steps S204 and S05 are executed when the caller is the producer role.
Further, the method further comprises:
step S206: and when the caller is in a Consumer role, calling the Consumer instance through a preset Consumer interface to acquire the message to be consumed from the message queue on the target cloud.
Specifically, step S206 includes:
step H1: judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
step H2: if yes, obtaining the message theme and the message label subscribed by the caller, and obtaining the group number of the caller;
step H3: searching a target message queue with a queue name comprising the message topic, the message label and the grouping number from the redundant queue group on the target cloud through the consumer instance; wherein the target cloud comprises a plurality of message queues;
step H4: and acquiring the message to be consumed from the target message queue through the consumer instance.
Step S207: sending the message to be consumed to the caller by the consumer instance.
In addition, in this embodiment, the consumer instance also performs adaptive conversion on the message to be consumed, so that the converted message to be consumed meets the requirement of the caller.
In addition, in this embodiment, when the transmission mode of the message queue on the target cloud is the publish-subscribe mode, as shown in fig. 3, the consumer instance finds a corresponding target message queue from the Broker server on the target cloud according to the message Topic and the message Tag, and then obtains the message to be consumed from the target queue.
Here, the steps S206 and S207 are executed when the caller is the producer role.
In this embodiment, a caller refers to a message-queue-timer software development kit, and performs automatic assembly according to a configuration file of a message queue on a target cloud to generate a corresponding Producer instance and a corresponding Consumer instance, and meanwhile, the message-queue-timer software development kit encapsulates a general Producer interface and a Consumer interface for the caller, and calls a specific Producer instance through the Producer interface and a specific Consumer instance through the Consumer interface according to a role corresponding to the caller, so that compatibility of different message queues on the corresponding target cloud is improved, and an efficient message queue multi-cloud adaptation effect is achieved.
EXAMPLE III
An embodiment of the present invention provides a device for adapting a message queue to multiple clouds, as shown in fig. 7, and the device is applied to a target object that needs to use a message queue on a cloud, and specifically includes the following components:
a receiving module 701, configured to receive a cloud migration instruction for switching an existing cloud docked with the target object to a target cloud;
an analyzing module 702, configured to analyze a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction;
a configuration module 703, configured to configure a preset producer template according to the configuration file to obtain a producer instance, and configure a preset consumer template according to the configuration file to obtain a consumer instance;
a processing module 704 configured to perform a message processing operation between the target object and the message queue on the target cloud through the producer instance and the consumer instance.
Specifically, the configuration module 703 is configured to:
acquiring a target producer template and a target consumer template corresponding to the type of the message queue on the target cloud from a preset template library;
adding configuration parameters of each configuration item in the configuration file to the target producer template to obtain one or more producer instances;
and adding the configuration parameters of the configuration items in the configuration file to the target consumer template to obtain one or more consumer instances.
Further, the processing module 704 specifically includes:
a first obtaining unit, configured to obtain a message to be sent, which is generated by the target object; wherein the message to be sent comprises: the message body comprises a message body and a message header, wherein the message body comprises a message subject and a message label;
and the first sending unit is used for sending the message to be sent to a message queue on the target cloud through the producer instance.
Further, the first sending unit is specifically configured to:
judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
if so, acquiring a message theme and a message label in the message to be sent, and acquiring a group number of a consumer for consuming the message to be sent;
searching a target message queue with a queue name comprising the message subject, the message label and the grouping number from the target cloud through the producer instance; wherein the target cloud comprises a plurality of message queues;
and sending the message to be sent to the target message queue through the producer instance.
Further, the processing module 704 further includes:
the second acquisition unit is used for acquiring the message to be consumed from the message queue on the target cloud through the consumer instance;
and the second sending unit is used for sending the message to be consumed to the target object.
Further, the second obtaining unit is specifically configured to:
judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
if yes, acquiring a message theme and a message label subscribed by the target object, and acquiring a group number of the target object;
finding a target message queue with a queue name comprising the message topic, the message label and the grouping number from the target cloud through the consumer instance; wherein the target cloud comprises a plurality of message queues;
and acquiring the message to be consumed from the target message queue through the consumer instance.
Further, the message queue on the target cloud includes the following types:
RocktMQ, RabbitMQ, Kafka, TDMQ of Tencent cloud, SQS of AWS, and EMQ of IOT.
Example four
The embodiment also provides a computer device, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server or a rack server (including an independent server or a server cluster composed of a plurality of servers) capable of executing programs, and the like. As shown in fig. 8, the computer device 80 of the present embodiment at least includes but is not limited to: a memory 801, a processor 802, communicatively coupled to each other via a system bus. It is noted that FIG. 8 only illustrates computer device 80 having components 801-802, but it is to be understood that not all illustrated components are required to be implemented and that more or fewer components can alternatively be implemented.
In this embodiment, the memory 801 (i.e., a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a magnetic disk, an optical disk, and the like. In some embodiments, the storage 801 may be an internal storage unit of the computer device 80, such as a hard disk or a memory of the computer device 80. In other embodiments, the memory 801 may be an external storage device of the computer device 80, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, provided on the computer device 80. Of course, the memory 801 may also include both internal and external memory units of the computer device 80. In the present embodiment, the memory 801 is generally used for storing an operating system and various types of application software installed in the computer device 80. In addition, the memory 801 can also be used to temporarily store various types of data that have been output or are to be output.
Processor 802 may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor, or other data Processing chip in some embodiments. The processor 802 generally operates to control the overall operation of the computer device 80.
Specifically, in this embodiment, the processor 802 is configured to execute the program of the message queue multi-cloud adaptation method stored in the memory 801, and when executed, the program of the message queue multi-cloud adaptation method implements the following steps:
receiving cloud migration instructions for switching an existing cloud docked with the target object to a target cloud;
analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction;
configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance;
performing message processing operations between the target object and a message queue on the target cloud via the producer instance and the consumer instance.
The specific embodiment process of the above method steps can be referred to as embodiment one, and the detailed description of this embodiment is not repeated herein.
EXAMPLE five
The present embodiments also provide a computer readable storage medium, such as a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a Random Access Memory (RAM), a Static Random Access Memory (SRAM), a Read Only Memory (ROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a Programmable Read Only Memory (PROM), a magnetic memory, a magnetic disk, an optical disk, a server, an App application mall, etc., having stored thereon a computer program that when executed by a processor implements the method steps of:
receiving cloud migration instructions for switching an existing cloud docked with the target object to a target cloud;
analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction;
configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance;
performing message processing operations between the target object and a message queue on the target cloud via the producer instance and the consumer instance.
The specific embodiment process of the above method steps can be referred to as embodiment one, and the detailed description of this embodiment is not repeated herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A method for multi-cloud adaptation of a message queue is applied to a target object needing to use the message queue on a cloud, and the method comprises the following steps:
receiving cloud migration instructions for switching an existing cloud docked with the target object to a target cloud;
analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction;
configuring a preset producer template according to the configuration file to obtain a producer instance, and configuring a preset consumer template according to the configuration file to obtain a consumer instance;
performing message processing operations between the target object and a message queue on the target cloud via the producer instance and the consumer instance.
2. The method for adapting message queue according to claim 1, wherein the configuring a preset producer template according to the configuration file to obtain a producer instance and configuring a preset consumer template according to the configuration file to obtain a consumer instance comprises:
acquiring a target producer template and a target consumer template corresponding to the type of the message queue on the target cloud from a preset template library;
adding configuration parameters of each configuration item in the configuration file to the target producer template to obtain one or more producer instances;
and adding the configuration parameters of the configuration items in the configuration file to the target consumer template to obtain one or more consumer instances.
3. The method for message queue multi-cloud adaptation according to claim 1 or 2, wherein the performing, by the producer instance and the consumer instance, a message processing operation between the target object and the message queue on the target cloud comprises:
acquiring a message to be sent generated by the target object; wherein the message to be sent comprises: the message body comprises a message body and a message header, wherein the message body comprises a message subject and a message label;
and sending the message to be sent to a message queue on the target cloud through the producer instance.
4. The method for adapting the message queue to be cloudy according to claim 3, wherein the sending the message to be sent to the message queue on the target cloud via the producer instance comprises:
judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
if so, acquiring a message theme and a message label in the message to be sent, and acquiring a group number of a consumer for consuming the message to be sent;
searching a target message queue with a queue name comprising the message subject, the message label and the grouping number from the target cloud through the producer instance; wherein the target cloud comprises a plurality of message queues;
and sending the message to be sent to the target message queue through the producer instance.
5. The method for message queue multi-cloud adaptation according to claim 1 or 2, wherein the performing, by the producer instance and the consumer instance, a message processing operation between the target object and the message queue on the target cloud comprises:
obtaining a message to be consumed from a message queue on the target cloud through the consumer instance;
and sending the message to be consumed to the target object.
6. The method for adapting the message queue to the multiple clouds according to claim 5, wherein the obtaining the message to be consumed from the message queue on the target cloud by the consumer instance comprises:
judging whether the transmission mode of the message queue on the target cloud is a point-to-point mode or not;
if yes, acquiring a message theme and a message label subscribed by the target object, and acquiring a group number of the target object;
finding a target message queue with a queue name comprising the message topic, the message label and the grouping number from the target cloud through the consumer instance; wherein the target cloud comprises a plurality of message queues;
and acquiring the message to be consumed from the target message queue through the consumer instance.
7. The method of message queue multi-cloud adaptation of claim 1, wherein the message queue on the target cloud comprises the following types:
RocktMQ, RabbitMQ, Kafka, TDMQ of Tencent cloud, SQS of AWS, and EMQ of IOT.
8. An apparatus for multi-cloud adaptation of a message queue, applied to a target object requiring use of the message queue on a cloud, the apparatus comprising:
a receiving module, configured to receive a cloud migration instruction for switching an existing cloud docked with the target object to a target cloud;
the analysis module is used for analyzing a configuration file corresponding to the type of the message queue on the target cloud from the cloud migration instruction;
the configuration module is used for configuring a preset producer template according to the configuration file to obtain a producer example and configuring a preset consumer template according to the configuration file to obtain a consumer example;
a processing module to perform message processing operations between the target object and a message queue on the target cloud via the producer instance and the consumer instance.
9. A computer device, the computer device comprising: memory, processor and computer program stored on the memory and executable on the processor, characterized in that the processor implements the steps of the method of any of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 7.
CN202210357772.5A 2022-04-06 2022-04-06 Message queue multi-cloud adaptation method, device and equipment and readable storage medium Pending CN114513504A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210357772.5A CN114513504A (en) 2022-04-06 2022-04-06 Message queue multi-cloud adaptation method, device and equipment and readable storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210357772.5A CN114513504A (en) 2022-04-06 2022-04-06 Message queue multi-cloud adaptation method, device and equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114513504A true CN114513504A (en) 2022-05-17

Family

ID=81554612

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210357772.5A Pending CN114513504A (en) 2022-04-06 2022-04-06 Message queue multi-cloud adaptation method, device and equipment and readable storage medium

Country Status (1)

Country Link
CN (1) CN114513504A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979257A (en) * 2022-05-24 2022-08-30 树根互联股份有限公司 Message pushing method and device, computer equipment and computer readable storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107835203A (en) * 2017-08-09 2018-03-23 平安壹钱包电子商务有限公司 Method, apparatus, storage medium and the terminal of message delivery of packets
CN107945031A (en) * 2017-12-25 2018-04-20 泰康保险集团股份有限公司 Data handling system and unit of risk data creation method is protected again
CN110311803A (en) * 2019-05-20 2019-10-08 平安科技(深圳)有限公司 Implementation method, device, computer equipment and the storage medium of software defined network
US10554604B1 (en) * 2017-01-04 2020-02-04 Sprint Communications Company L.P. Low-load message queue scaling using ephemeral logical message topics
CN113626211A (en) * 2021-06-29 2021-11-09 欧电云信息科技(江苏)有限公司 Switching method and switching system of message queue, electronic equipment and storage medium
CN113743879A (en) * 2020-05-28 2021-12-03 华为技术有限公司 Automatic rule processing method, system and related equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10554604B1 (en) * 2017-01-04 2020-02-04 Sprint Communications Company L.P. Low-load message queue scaling using ephemeral logical message topics
CN107835203A (en) * 2017-08-09 2018-03-23 平安壹钱包电子商务有限公司 Method, apparatus, storage medium and the terminal of message delivery of packets
CN107945031A (en) * 2017-12-25 2018-04-20 泰康保险集团股份有限公司 Data handling system and unit of risk data creation method is protected again
CN110311803A (en) * 2019-05-20 2019-10-08 平安科技(深圳)有限公司 Implementation method, device, computer equipment and the storage medium of software defined network
CN113743879A (en) * 2020-05-28 2021-12-03 华为技术有限公司 Automatic rule processing method, system and related equipment
CN113626211A (en) * 2021-06-29 2021-11-09 欧电云信息科技(江苏)有限公司 Switching method and switching system of message queue, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
潘慧芳: "基于混合通信模式的消息中间件设计与实现", 计算机工程, 5 February 2006 (2006-02-05) *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114979257A (en) * 2022-05-24 2022-08-30 树根互联股份有限公司 Message pushing method and device, computer equipment and computer readable storage medium

Similar Documents

Publication Publication Date Title
CN108449410B (en) Message management method, system and related device in cloud platform
US11561835B2 (en) Unified container orchestration controller
CN110636124B (en) VPP cluster management method and device, electronic equipment and storage medium
CA2540361A1 (en) System and method for extending capabilities and execution efficiency of script based applications
CN104750528A (en) Management method and device for components in Android program
CN111400005A (en) Data processing method and device and electronic equipment
CN110875935A (en) Message publishing, processing and subscribing method, device and system
CN109039730B (en) Server cluster and server cluster configuration information management method
CN112507005A (en) Method and device for processing message
CN105793839B (en) Execute unloading
CN114513504A (en) Message queue multi-cloud adaptation method, device and equipment and readable storage medium
CN109327321B (en) Network model service execution method and device, SDN controller and readable storage medium
CN109343970B (en) Application program-based operation method and device, electronic equipment and computer medium
CN112925586B (en) Applet routing method, device, computer equipment and storage medium
CN114710549A (en) Dynamic management method, system and service node of network card in container platform
CN114064328A (en) Message queue cluster migration method and device
CN112099930A (en) Quantum computer cluster distributed queue scheduling method
CN112882794A (en) pod capacity expansion method, device, node and storage medium
CN114020453A (en) Service bus message processing method, service bus system, electronic device, and medium
CN114675940A (en) Application instance construction method, device and equipment
CN111459981A (en) Query task processing method, device, server and system
CN115934384B (en) Method, system, electronic device and readable storage medium for implementing message queue
CN109388536B (en) Data collection method and device
CN113805958A (en) Third-party service access method and system based on OSB API specification
CN115237722A (en) Asynchronous message monitoring method and device, storage medium and electronic equipment

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