[go: up one dir, main page]

CN116506501A - Message forwarding method, device, electronic device and storage medium - Google Patents

Message forwarding method, device, electronic device and storage medium Download PDF

Info

Publication number
CN116506501A
CN116506501A CN202310436226.5A CN202310436226A CN116506501A CN 116506501 A CN116506501 A CN 116506501A CN 202310436226 A CN202310436226 A CN 202310436226A CN 116506501 A CN116506501 A CN 116506501A
Authority
CN
China
Prior art keywords
message
middleware
forwarding
information
format
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
CN202310436226.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.)
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 CN202310436226.5A priority Critical patent/CN116506501A/en
Publication of CN116506501A publication Critical patent/CN116506501A/en
Pending legal-status Critical Current

Links

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/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/14Session management

Landscapes

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

Abstract

The application provides a message forwarding method, a message forwarding device, electronic equipment and a storage medium, and can be used in the technical field of distributed middleware. The method comprises the following steps: determining message forwarding information corresponding to the first message middleware and the second message middleware, wherein the types of the first message middleware and the second message middleware are different, and the message forwarding information is used for indicating respective transmission configurations of the first message middleware and the second message middleware; based on the message forwarding information, establishing long connection with the first message middleware and the second message middleware respectively; receiving a first message sent by a first message middleware according to the long connection with the first message middleware; converting the first message into a second message according to the message format of the second message middleware; and sending the second message to the second message middleware according to the long connection with the second message middleware. According to the method, the transmission of the message in different message middleware is realized through message conversion, and the stability and reliability of message transmission are improved.

Description

消息转发方法、装置、电子设备及存储介质Message forwarding method, device, electronic device and storage medium

技术领域technical field

本申请涉及分布式中间件技术领域,尤其涉及一种消息转发方法、装置、电子设备及存储介质。The present application relates to the technical field of distributed middleware, and in particular to a message forwarding method, device, electronic equipment and storage medium.

背景技术Background technique

消息中间件(MQ,Message Queue)是一种用于实现网络通信的系统之间的通道建立、数据或文件的发送的消息队列。消息提供方可以将消息发送至消息中间件。消息消费方可以从消息中间件获取所需要的消息,并对获得的消息进行处理。较为常见的消息中间件可以包括IBMMQ(International Business Machines Corporation MQ,万国商业机器消息中间件)、TDMQ(Tencent Distributed Message Queue,腾讯云中间件)等不同类型的消息中间件。Message middleware (MQ, Message Queue) is a message queue used to establish channels between systems for network communication and send data or files. The message provider can send the message to the message middleware. The message consumer can obtain the required message from the message middleware and process the obtained message. The more common message middleware may include different types of message middleware such as IBMMQ (International Business Machines Corporation MQ, International Business Machines Message Middleware), TDMQ (Tencent Distributed Message Queue, Tencent Cloud Middleware).

而在实际应用中,不同类型的消息中间件之间不能进行消息通信,例如使用IBMMQ的节点提供的IBMMQ消息不能传输到使用TDMQ的节点,使用TDMQ的节点提供的TDMQ消息不能传输到使用IBMMQ的节点。因此,如何使不同类型的消息中间件定义的消息能够相互通信是目前亟待解决的技术问题。In practical applications, message communication cannot be performed between different types of message middleware. For example, IBMMQ messages provided by nodes using IBMMQ cannot be transmitted to nodes using TDMQ, and TDMQ messages provided by nodes using TDMQ cannot be transmitted to nodes using IBMMQ. node. Therefore, how to enable messages defined by different types of message middleware to communicate with each other is a technical problem to be solved urgently.

发明内容Contents of the invention

本申请提供一种消息转发方法、装置、电子设备及存储介质,用以解决不同类型的消息中间件定义的消息并不能够相互通信的技术问题。The present application provides a message forwarding method, device, electronic equipment and storage medium to solve the technical problem that messages defined by different types of message middleware cannot communicate with each other.

第一方面,本申请提供一种消息转发方法,包括:In a first aspect, the present application provides a message forwarding method, including:

确定第一消息中间件和第二消息中间件对应的消息转发信息,所述第一消息中间件和所述第二消息中间件类型不同,所述消息转发信息用于指示所述第一消息中间件和所述第二消息中间件各自的传输配置;Determine message forwarding information corresponding to the first message middleware and the second message middleware, the first message middleware and the second message middleware are of different types, and the message forwarding information is used to indicate that the first message middleware The respective transmission configurations of the middleware and the second message middleware;

基于所述消息转发信息,分别与所述第一消息中间件和所述第二消息中间件建立长连接;Establishing a long connection with the first message middleware and the second message middleware respectively based on the message forwarding information;

根据与所述第一消息中间件的长连接,接收所述第一消息中间件发送的第一报文;Receive the first message sent by the first message middleware according to the long connection with the first message middleware;

根据所述第二消息中间件的报文格式,将所述第一报文转换为第二报文;converting the first message into a second message according to the message format of the second message middleware;

根据与所述第二消息中间件的长连接,将所述第二报文发送至所述第二消息中间件。Send the second message to the second message middleware according to the long connection with the second message middleware.

第二方面,本申请提供一种消息转发装置,包括:In a second aspect, the present application provides a message forwarding device, including:

确定单元,用于确定第一消息中间件和第二消息中间件对应的消息转发信息,所述第一消息中间件和所述第二消息中间件类型不同,所述消息转发信息用于指示所述第一消息中间件和所述第二消息中间件各自的配置参数;A determining unit, configured to determine message forwarding information corresponding to the first message middleware and the second message middleware, where the types of the first message middleware and the second message middleware are different, and the message forwarding information is used to indicate the Respective configuration parameters of the first message middleware and the second message middleware;

建立单元,用于基于所述消息转发信息,分别与所述第一消息中间件和所述第二消息中间件建立长连接;An establishing unit, configured to respectively establish a long connection with the first message middleware and the second message middleware based on the message forwarding information;

接收单元,用于根据与所述第一消息中间件的长连接,接收所述第一消息中间件发送的第一报文;a receiving unit, configured to receive the first message sent by the first message middleware according to the long connection with the first message middleware;

转换单元,用于根据所述第二消息中间件的报文格式,将所述第一报文转换为第二报文;A conversion unit, configured to convert the first message into a second message according to the message format of the second message middleware;

发送单元,用于根据与所述第二消息中间件的长连接,将所述第二报文发送至所述第二消息中间件。A sending unit, configured to send the second message to the second message middleware according to the long connection with the second message middleware.

第三方面,本申请提供一种电子设备,包括:处理器,以及与所述处理器通信连接的存储器;In a third aspect, the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

所述存储器存储计算机执行指令;the memory stores computer-executable instructions;

所述处理器执行所述存储器存储的计算机执行指令,以实现如第一方面以及第一方面各种可能所述的方法。The processor executes the computer-executed instructions stored in the memory, so as to implement the method described in the first aspect and various possibilities of the first aspect.

第四方面,本申请提供一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机执行指令,所述计算机执行指令被处理器执行时用于实现如第一方面以及第一方面各种可能所述的方法。In a fourth aspect, the present application provides a computer-readable storage medium, where computer-executable instructions are stored in the computer-readable storage medium, and the computer-executable instructions are used to implement the first aspect and the first aspect when executed by a processor various possible methods.

第五方面,本申请提供一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现如第一方面以及第一方面各种可能涉及的方法的步骤。In a fifth aspect, the present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of the first aspect and various methods that may be involved in the first aspect are implemented.

本申请提供的技术方案,可以确定第一消息中间件和第二消息中间件的消息转发信息,消息转发信息用于指示该两个消息中间件各自的配置参数,通过该消息转发信息,可以建立与第一消息中间件和第二消息中间件之间的长连接,实现以电子设备作为传输媒介,分别与两个消息中间件分别建立长连接,进而实现两个消息中间件之间的传输同路的建立。通过该长连接,可以接收配置第一消息中间件发送的第一报文,根据第二消息中间件的报文格式将第一报文转换为第二报文,使得第二报文适配于第二消息中间件,以根据长连接,将第二报文发送至配置第二消息中间件,实现不同消息中间件之间的消息传输,提高不同消息中间件之间的消息传输的稳定性。The technical solution provided by this application can determine the message forwarding information of the first message middleware and the second message middleware. The message forwarding information is used to indicate the respective configuration parameters of the two message middleware. Through the message forwarding information, it is possible to establish The long connection with the first message middleware and the second message middleware realizes the use of electronic equipment as the transmission medium, respectively establishes long connections with the two message middleware, and then realizes the simultaneous transmission between the two message middleware. The establishment of the road. Through this long connection, it is possible to receive and configure the first message sent by the first message middleware, and convert the first message into a second message according to the message format of the second message middleware, so that the second message is adapted to The second message middleware is used to send the second message to the second message middleware according to the long connection, so as to realize message transmission between different message middlewares and improve the stability of message transmission between different message middlewares.

附图说明Description of drawings

此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description serve to explain the principles of the application.

图1为本申请实施例提供的一种用于实现消息转发方法的系统架构图;FIG. 1 is a system architecture diagram for implementing a message forwarding method provided by an embodiment of the present application;

图2为本申请实施例提供的一种消息转发方法的一个实施例的流程图;FIG. 2 is a flowchart of an embodiment of a message forwarding method provided in an embodiment of the present application;

图3为本申请实施例提供的一种消息转发方法的又一个实施例的流程图;FIG. 3 is a flow chart of another embodiment of a message forwarding method provided by an embodiment of the present application;

图4为本申请实施例提供的一种消息转发装置的一个实施例的结构示意图;FIG. 4 is a schematic structural diagram of an embodiment of a message forwarding device provided in an embodiment of the present application;

图5为本申请实施例提供的一种用于实现消息转发方法的电子设备的框图。FIG. 5 is a block diagram of an electronic device for implementing a message forwarding method provided by an embodiment of the present application.

通过上述附图,已示出本申请明确的实施例,后文中将有更详细的描述。这些附图和文字描述并不是为了通过任何方式限制本申请构思的范围,而是通过参考特定实施例为本领域技术人员说明本申请的概念。By means of the above drawings, specific embodiments of the present application have been shown, which will be described in more detail hereinafter. These drawings and text descriptions are not intended to limit the scope of the concept of the application in any way, but to illustrate the concept of the application for those skilled in the art by referring to specific embodiments.

具体实施方式Detailed ways

这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施方式并不代表与本申请相一致的所有实施方式。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with aspects of the present application as recited in the appended claims.

需要说明的是,本申请所涉及的用户信息(包括但不限于用户设备信息、用户个人信息等)和数据(包括但不限于用于分析的数据、存储的数据、展示的数据等),均为经用户授权或者经过各方充分授权的信息和数据,并且相关数据的收集、使用和处理需要遵守相关法律法规和标准,并提供有相应的操作入口,供用户选择授权或者拒绝。It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all It is information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards, and provide corresponding operation portals for users to choose to authorize or refuse.

需要说明的是,本申请提供的消息转发方法、装置、电子设备及存储介质,可用于分布式中间件技术领域,也可用于除分布式中间件技术领域之外的任意领域,本申请提供的消息转发方法、装置、电子设备及存储介质的应用领域不做限定。It should be noted that the message forwarding method, device, electronic device, and storage medium provided by this application can be used in the technical field of distributed middleware, and can also be used in any field other than the technical field of distributed middleware. The application fields of the message forwarding method, device, electronic equipment and storage medium are not limited.

相关技术中,消息中间件可以作为消息提供方和消息消费方的媒介,消息提供方可以将消息存放至消息中间件,消息消费方可以从消息中间件拉取消息并执行相应的消息处理。目前较为常见的消息中间件可以包括IBMMQ、TDMQ等,不同消息中间件的报文传输格式不同,因而导致不同消息中间件之间的消息不能相互传输。例如,存储至IBMMQ的消息不能被发送至TDMQ,存储至TDMQ的消息不能被发送至IBMMQ。In related technologies, message middleware can be used as a medium between a message provider and a message consumer. The message provider can store messages in the message middleware, and the message consumer can pull messages from the message middleware and perform corresponding message processing. At present, the more common message middleware can include IBMMQ, TDMQ, etc. The message transmission formats of different message middleware are different, so the messages between different message middleware cannot be transmitted to each other. For example, messages stored in IBMMQ cannot be sent to TDMQ, and messages stored in TDMQ cannot be sent to IBMMQ.

为了解决上述技术方案,考虑到消息中间件的消息结构差异,可以使用报文转换方式将两种不同消息中间件的消息重新进行封装,使得重新封装后的消息适用于另一个消息中间件的集群。重新封装后的消息则需要从在配置两种消息中间件的集群之间进行传输。为了实现两个消息中间件集群的消息转发,可以获取两个消息中间件的传输配置参数,并通过两个消息中间件的传输配置参数进行消息转发信息的生成,通过消息转发信息实现两个消息中间件之间的长连接,进而通过该长连接实现消息在两个消息中间件的信息传输,提高消息在两个不同消息中间件的传输可靠性。In order to solve the above technical solution, taking into account the difference in the message structure of the message middleware, the messages of the two different message middleware can be re-encapsulated using the message conversion method, so that the re-encapsulated message is suitable for another message middleware cluster . The repackaged messages need to be transmitted between the clusters configured with two kinds of message middleware. In order to realize the message forwarding of two message middleware clusters, the transmission configuration parameters of the two message middlewares can be obtained, and the message forwarding information can be generated through the transmission configuration parameters of the two message middlewares, and the two messages can be realized through the message forwarding information The long connection between the middleware, and then realize the information transmission of the message in the two message middleware through the long connection, and improve the transmission reliability of the message in the two different message middleware.

本申请实施例中,可以确定第一消息中间件和第二消息中间件的消息转发信息,消息转发信息用于指示该两个消息中间件各自的配置参数,通过该消息转发信息,可以建立与第一消息中间件和第二消息中间件之间的长连接,实现以电子设备作为传输媒介,分别与两个消息中间件分别建立长连接,进而实现两个消息中间件之间的传输同路的建立。通过该长连接,可以接收配置第一消息中间件发送的第一报文,根据第二消息中间件的报文格式将第一报文转换为第二报文,使得第二报文适配于第二消息中间件,以根据长连接,将第二报文发送至配置第二消息中间件,实现不同消息中间件之间的消息传输,提高不同消息中间件之间的消息传输的稳定性。In the embodiment of the present application, the message forwarding information of the first message middleware and the second message middleware can be determined, and the message forwarding information is used to indicate the respective configuration parameters of the two message middlewares. Through the message forwarding information, it is possible to establish a relationship with The long connection between the first message middleware and the second message middleware realizes the use of electronic equipment as the transmission medium, respectively establishes long connections with the two message middleware, and then realizes the same transmission path between the two message middleware of establishment. Through this long connection, it is possible to receive and configure the first message sent by the first message middleware, and convert the first message into a second message according to the message format of the second message middleware, so that the second message is adapted to The second message middleware is used to send the second message to the second message middleware according to the long connection, so as to realize message transmission between different message middlewares and improve the stability of message transmission between different message middlewares.

本申请提供的数据传输的方法,旨在解决现有技术的如上技术问题。The data transmission method provided in this application aims to solve the above technical problems in the prior art.

下面以具体地实施例对本申请的技术方案以及本申请的技术方案如何解决上述技术问题进行详细说明。下面这几个具体的实施例可以相互结合,对于相同或相似的概念或过程可能在某些实施例中不再赘述。下面将结合附图,对本申请的实施例进行描述。The technical solution of the present application and how the technical solution of the present application solves the above technical problems will be described in detail below with specific embodiments. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. Embodiments of the present application will be described below in conjunction with the accompanying drawings.

图1示出了本申请实施例提供的一种用于实现消息转发方法的系统架构图。该消息转发系统可以包括:第一消息中间件集群11,其中,该第一消息中间件集群11中配置第一消息中间件110。与第一消息中间件集群11连接的电子设备12。与电子设备12连接的第二消息中间件集群13,其中,该第二消息中间件集群13中配置第二消息中间件130。FIG. 1 shows a system architecture diagram for implementing a message forwarding method provided by an embodiment of the present application. The message forwarding system may include: a first message middleware cluster 11 , where a first message middleware 110 is configured in the first message middleware cluster 11 . An electronic device 12 connected to the first message middleware cluster 11 . The second message middleware cluster 13 connected to the electronic device 12, wherein the second message middleware 130 is configured in the second message middleware cluster 13 .

第一消息中间件110可以对第一消息中间件集群11中其它节点请求发送的消息或请求获取的消息进行处理。第二消息中间件130可以对第二消息中间件集群13中其它节点请求发送的消息或者请求获取的消息进行处理。The first message middleware 110 may process messages requested to be sent or obtained by other nodes in the first message middleware cluster 11 . The second message middleware 130 may process messages requested to be sent or obtained by other nodes in the second message middleware cluster 13 .

电子设备12可以获取第一消息中间件110和第二消息中间件130的消息转发信息,该消息转发信息即包括第一消息中间件的传输配置和第二消息中间件的传输配置。电子设备12可以分别建立与第一消息中间件110和第二消息中间件130的长连接,以基于该长连接接收第一消息中间件110发送的第一报文。根据第二消息中间件的报文格式将第一报文转换为第二报文之后,可以根据该长连接将第二报文发送至第二消息中间件130。The electronic device 12 may obtain message forwarding information of the first messaging middleware 110 and the second messaging middleware 130 , the message forwarding information including the transmission configuration of the first messaging middleware and the transmission configuration of the second messaging middleware. The electronic device 12 may establish a persistent connection with the first messaging middleware 110 and the second messaging middleware 130 respectively, so as to receive the first message sent by the first messaging middleware 110 based on the persistent connection. After the first message is converted into the second message according to the message format of the second message middleware, the second message may be sent to the second message middleware 130 according to the long connection.

图2为本申请实施例提供的一种消息转发方法的一个实施例的流程图,该消息转发方法可以配置为一消息转发装置,该消息转发装置可以位于电子设备中。消息转发方法可以包括下列步骤:FIG. 2 is a flow chart of an embodiment of a message forwarding method provided in an embodiment of the present application. The message forwarding method may be configured as a message forwarding device, and the message forwarding device may be located in an electronic device. The message forwarding method may include the following steps:

S201:确定第一消息中间件和第二消息中间件对应的消息转发信息,第一消息中间件和第二消息中间件类型不同,消息转发信息用于指示第一消息中间件和第二消息中间件各自的传输配置。S201: Determine the message forwarding information corresponding to the first message middleware and the second message middleware, the first message middleware and the second message middleware are of different types, and the message forwarding information is used to indicate the first message middleware and the second message middleware file's respective transport configuration.

可选地,第一消息中间件可以为IBMMQ,第二消息中间件可以为TDMQ,或者第一消息中间件可以为TDMQ,第二消息中间件可以为IBMMQ。此外,第一消息中间件和第二消息中间件还可以为其它类型的消息中间件,本实施例中对消息中间件的具体类型并不过多限定。第一消息中间件和第二消息中间件的类型不同即可。Optionally, the first message middleware may be IBMMQ, and the second message middleware may be TDMQ, or the first message middleware may be TDMQ, and the second message middleware may be IBMMQ. In addition, the first message middleware and the second message middleware may also be other types of message middleware, and the specific types of message middleware are not limited too much in this embodiment. The types of the first message middleware and the second message middleware only need to be different.

消息中间件可以为服务器集群中的任意节点,该服务器集群中的消息提供方可以将消息传输至其集群的消息中间件的节点,也即传输到该消息中间件。消息中间件可以运行在集群中的节点,消息中间件接收报文或者发送报文具体可以是其所在节点接收报文或发送报文,本实施例中的第一消息中间件可以配置于第一节点,第二消息中间件可以配置于第二节点。节点可以指服务器集群中的具备数据接收和发送、数据处理等功能的计算节点。第一消息中间件可以直接通过其第一节点发送第一报文至电子设备。第二消息中间件可以通过其第二节点接收第二报文。The message middleware can be any node in the server cluster, and the message provider in the server cluster can transmit the message to the node of the message middleware of its cluster, that is, to the message middleware. The message middleware can run on the nodes in the cluster, and the message middleware can receive or send the message. Specifically, the node where the message middleware is located can receive the message or send the message. Node, the second message middleware can be configured on the second node. A node may refer to a computing node in a server cluster that has functions such as data receiving and sending, and data processing. The first message middleware may directly send the first message to the electronic device through its first node. The second message middleware can receive the second message through its second node.

消息转发信息可以包括第一消息中间件的传输配置和第二消息中间件在第二节点得传输配置,具体可以根据第一消息中间件所在第一节点的传输配置信息和第一消息中间件所在第二节点的传输配置信息生成。The message forwarding information may include the transmission configuration of the first messaging middleware and the transmission configuration of the second messaging middleware at the second node, specifically according to the transmission configuration information of the first node where the first messaging middleware is located and the transmission configuration of the first messaging middleware at the second node. The transmission configuration information of the second node is generated.

S202:基于消息转发信息,分别与第一消息中间件和第二消息中间件建立长连接。S202: Based on the message forwarding information, establish a persistent connection with the first message middleware and the second message middleware respectively.

可选地,消息转发信息可以包括第一消息中间件的中间件标识和第二消息中间件的中间件标识。中间件标识例如可以为访问IP(Internet Protocol,网络互联协议)地址。通过第一消息中间件的中间件标识可以建立与第一消息中间件的长连接,通过第二消息中间件的中间件标识可以建立与第二消息中间件的长连接。分别建立第一消息中间件和第二消息中间件的长连接,建立了第一消息中间件和第二消息中间件之间的传输通路。Optionally, the message forwarding information may include the middleware identifier of the first messaging middleware and the middleware identifier of the second messaging middleware. The middleware identifier may be, for example, an access IP (Internet Protocol, Internet Protocol) address. A persistent connection with the first messaging middleware can be established through the middleware identifier of the first messaging middleware, and a persistent connection with the second messaging middleware can be established through the middleware identifier of the second messaging middleware. Long connections of the first message middleware and the second message middleware are respectively established, and a transmission path between the first message middleware and the second message middleware is established.

长连接是指维持第一消息中间件和第二消息中间件的传输通路的存在,具体可以是建立电子设备与第一消息中间件的长连接,和电子设备与第二消息中间件的长连接。The long connection refers to maintaining the existence of the transmission path between the first message middleware and the second message middleware, specifically, it may be to establish a long connection between the electronic device and the first message middleware, and a long connection between the electronic device and the second message middleware .

S203:根据与第一消息中间件的长连接,接收第一消息中间件发送的第一报文。S203: Receive the first packet sent by the first message middleware according to the long connection with the first message middleware.

第一报文可以是基于第一消息中间件支持的报文格式生成的。The first message may be generated based on the message format supported by the first message middleware.

S204:根据第二消息中间件的报文格式,将第一报文转换为第二报文。S204: Convert the first packet into the second packet according to the packet format of the second message middleware.

第二报文可以是按照第二消息中间件支持的报文格式生成的。The second message may be generated according to the message format supported by the second message middleware.

S205:根据与第二消息中间件的长连接,将第二报文发送至第二消息中间件。S205: Send the second packet to the second message middleware according to the long connection with the second message middleware.

可选地,步骤205可以包括:接收第二消息中间件发送的消息拉取请求;响应于消息拉取请求,根据与第二消息中间件的长连接,将第二报文发送至第二消息中间件。通过消息拉取请求可以时效第二消息中间件对第二报文的消费,提高报文发送的有效性。Optionally, step 205 may include: receiving a message pull request sent by the second message middleware; in response to the message pull request, sending the second message to the second message according to the long connection with the second message middleware middleware. The consumption of the second message by the second message middleware can be timed through the message pull request, and the effectiveness of message sending can be improved.

本申请实施例中,可以确定第一消息中间件和第二消息中间件的消息转发信息,消息转发信息用于指示该两个消息中间件各自的配置参数,通过该消息转发信息,可以建立与第一消息中间件和第二消息中间件之间的长连接,实现以电子设备作为传输媒介,分别与两个消息中间件分别建立长连接,进而实现两个消息中间件之间的传输同路的建立。通过该长连接,可以接收配置第一消息中间件发送的第一报文,根据第二消息中间件的报文格式将第一报文转换为第二报文,使得第二报文适配于第二消息中间件,以根据长连接,将第二报文发送至配置第二消息中间件,实现不同消息中间件之间的消息传输,提高不同消息中间件之间的消息传输的稳定性。In the embodiment of the present application, the message forwarding information of the first message middleware and the second message middleware can be determined, and the message forwarding information is used to indicate the respective configuration parameters of the two message middlewares. Through the message forwarding information, it is possible to establish a relationship with The long connection between the first message middleware and the second message middleware realizes the use of electronic equipment as the transmission medium, respectively establishes long connections with the two message middleware, and then realizes the same transmission path between the two message middleware of establishment. Through this long connection, it is possible to receive and configure the first message sent by the first message middleware, and convert the first message into a second message according to the message format of the second message middleware, so that the second message is adapted to The second message middleware is used to send the second message to the second message middleware according to the long connection, so as to realize message transmission between different message middlewares and improve the stability of message transmission between different message middlewares.

进一步地,在上述任一实施例的基础上,确定第一消息中间件和第二消息中间件对应的消息转发信息,包括:Further, on the basis of any of the above embodiments, determining the message forwarding information corresponding to the first messaging middleware and the second messaging middleware includes:

接收消息转发服务的启动请求,启动请求包括第一消息中间件的标识信息和第二消息中间件的标识信息;Receive an activation request of the message forwarding service, where the activation request includes identification information of the first messaging middleware and identification information of the second messaging middleware;

响应于启动请求,确定第一消息中间件的标识信息和/或第二消息中间件的标识信息对应的消息转发信息。In response to the start request, determine message forwarding information corresponding to the identification information of the first messaging middleware and/or the identification information of the second messaging middleware.

第一消息中间件的标识信息可以包括第一消息中间件的中间件名称、中间件标识等信息。第二消息中间件的标识信息可以包括第二消息中间件的中间件名称、中间件标识等信息。标识信息可以用于区别不同消息中间件,也即第一消息中间件的标识信息可以和第二消息中间件的标识信息不同。The identification information of the first messaging middleware may include information such as a middleware name and a middleware identifier of the first messaging middleware. The identification information of the second message middleware may include information such as a middleware name and a middleware identifier of the second message middleware. The identification information may be used to distinguish different message middleware, that is, the identification information of the first message middleware may be different from the identification information of the second message middleware.

消息转发服务可以面向用户提供,也即电子设备可以输出消息转发服务的启动提示信息,检测用户针对该启动提示信息执行点击操作时,可以产生启动请求。启动提示信息中可以显示若干消息中间件的标识信息,可以检测用户选择的第一消息中间件的标识信息和第二消息中间件的标识信息。The message forwarding service may be provided for users, that is, the electronic device may output message forwarding service startup prompt information, and may generate a startup request when detecting that the user performs a click operation on the startup prompt information. The identification information of several message middlewares may be displayed in the startup prompt information, and the identification information of the first message middleware and the identification information of the second message middleware selected by the user may be detected.

本实施例中,可以接收消息转发服务的启动请求,启动请求可以包括第一消息中间件的标识信息和第二消息中间件标识信息。通过启动请求可以对两个不同类型的消息中间件进行消息转发,实现消息转发信息的获取。通过及时响应启动请求,可以及时获取第一消息中间件和第二消息中间件所对应的消息转发信息,以利用消息转发信息及时实现第一消息中间件和第二消息中间件所对应的传输通路的建立,进而实现消息的稳定传输。In this embodiment, an activation request of the message forwarding service may be received, and the activation request may include identification information of the first messaging middleware and identification information of the second messaging middleware. Message forwarding can be performed on two different types of message middleware through the start request, so as to realize the acquisition of message forwarding information. By responding to the start request in time, the message forwarding information corresponding to the first message middleware and the second message middleware can be obtained in time, so that the transmission path corresponding to the first message middleware and the second message middleware can be realized in time by using the message forwarding information Establishment, and then realize the stable transmission of messages.

如图3所示,为本申请实施例提供的一种消息转发方法的又一个实施例的流程图,与前述实施例的不同之处在于,在步骤201之前,还可以包括:As shown in FIG. 3 , the flow chart of another embodiment of a message forwarding method provided by the embodiment of the present application is different from the foregoing embodiments in that, before step 201, it may also include:

S301:采集第一消息中间件对应的传输配置信息以及第二消息中间件对应的传输配置信息。S301: Collect transmission configuration information corresponding to the first messaging middleware and transmission configuration information corresponding to the second messaging middleware.

S302:根据第一消息中间件对应的传输配置信息和第二消息中间件对应的传输配置信息,生成消息转发信息。S302: Generate message forwarding information according to the transmission configuration information corresponding to the first messaging middleware and the transmission configuration information corresponding to the second messaging middleware.

S303:将消息转发信息存储至转发数据库中。S303: Store the message forwarding information in a forwarding database.

步骤201:确定第一消息中间件和第二消息中间件对应的消息转发信息,具体可以包括:Step 201: Determine the message forwarding information corresponding to the first message middleware and the second message middleware, which may specifically include:

S304:从转发数据库中查询与第一消息中间件和/或第二消息中间件关联的消息转发信息。S304: Query message forwarding information associated with the first message middleware and/or the second message middleware from the forwarding database.

可选地,消息转发信息可以包括第一消息中间件转发至第二消息中间件的第一转发信息,和/或消息转发信息还可以包括第二消息中间件转发至第一消息中间件的第二转发信息。第一转发信息和/或第二转发信息均可以通过第一消息中间件的传输配置信息和第二中间件的传输配置信息生成。Optionally, the message forwarding information may include the first forwarding information forwarded by the first messaging middleware to the second messaging middleware, and/or the message forwarding information may further include the first forwarding information forwarded by the second messaging middleware to the first messaging middleware. 2. Forward information. Both the first forwarding information and/or the second forwarding information may be generated through transmission configuration information of the first message middleware and transmission configuration information of the second middleware.

其中,第一消息中间件的传输配置信息可以包括至少一个第一传输参数分别对应的参数取值。第二消息中间件的传输配置信息可以包括至少一个第二传输参数分别对应的参数取值。至少一个第一传输参数和至少一个第二传输参数的参数类型和参数数量可以不同。Wherein, the transmission configuration information of the first message middleware may include parameter values respectively corresponding to at least one first transmission parameter. The transmission configuration information of the second message middleware may include parameter values corresponding to at least one second transmission parameter. The parameter type and the number of parameters of the at least one first transmission parameter and the at least one second transmission parameter may be different.

示例性地,以第一消息中间件为TDMQ,第二消息中间件为IBMMQ为例,对传输中间件的至少一个传输参数进行举例说明。Exemplarily, at least one transmission parameter of the transmission middleware is described by taking TDMQ as the first message middleware and IBMMQ as the second message middleware as examples.

至少一个第一传输参数可以包括:TDMQ集群访问ip、TDMQ主题访问信息、第一消息中间件的报文编码类型,主题访问信息例如可以包括:cluster-id(路由反射器)、namespace、authtoken、TDMQ主题名、TDMQ订阅名等信息中的至少一种。At least one first transmission parameter may include: TDMQ cluster access ip, TDMQ subject access information, message encoding type of the first message middleware, subject access information may include, for example: cluster-id (route reflector), namespace, authtoken, At least one of TDMQ topic name, TDMQ subscription name and other information.

至少一个第二传输参数可以包括:IBMMQ队列管理器名、IBMMQ队列管理器ip、目标IBMMQ发送队列或者目标IBMMQ接收队列、第二消息中间件的报文编码类型。At least one second transmission parameter may include: IBMMQ queue manager name, IBMMQ queue manager ip, target IBMMQ sending queue or target IBMMQ receiving queue, and message encoding type of the second message middleware.

此外,除第一消息中间件对应的传输配置信息和第二消息中间件对应的传输配置信息之外,消息转发信息还可以包括其它信息,例如第一消息中间件所支持的报文编码类型和第二消息中间件所支持的报文编码类型。In addition, in addition to the transmission configuration information corresponding to the first message middleware and the transmission configuration information corresponding to the second message middleware, the message forwarding information may also include other information, such as the message encoding type and The message encoding type supported by the second message middleware.

TDMQ转IBMMQ的消息转发信息例如可以为:TDMQ集群访问ip、TDMQ主题访问信息、报文编码类型、IBMMQ队列管理器名、IBMMQ队列管理器ip、目标IBMMQ发送队列。For example, the message forwarding information from TDMQ to IBMMQ can be: TDMQ cluster access ip, TDMQ topic access information, message encoding type, IBMMQ queue manager name, IBMMQ queue manager ip, target IBMMQ sending queue.

IBMMQ转TDMQ的消息转发信息例如可以为:TDMQ集群访问ip、TDMQ主题访问信息、报文编码类型、IBMMQ队列管理器名、IBMMQ队列管理器ip、IBMMQ接收队列。For example, the message forwarding information from IBMMQ to TDMQ can be: TDMQ cluster access ip, TDMQ topic access information, message encoding type, IBMMQ queue manager name, IBMMQ queue manager ip, IBMMQ receiving queue.

其中,消息转发信息中的报文编码类型可以包括第一消息中间件的报文编码类型和第二消息中间件的报文编码类型。Wherein, the message encoding type in the message forwarding information may include the message encoding type of the first message middleware and the message encoding type of the second message middleware.

可选地,电子设备采集第一消息中间件对应的传输配置信息以及第二消息中间件对应的传输配置信息之后,还可以在显示界面显示第一消息中间件对应的传输配置信息以及第二消息中间件对应的传输配置信息。具体可以检测用户针对第一消息中间件对应的传输配置信息以及第二消息中间件对应的传输配置信息执行的配置操作,以获得用户配置的第一消息中间件对应的传输配置信息以及第二消息中间件对应的传输配置信息。此外,具体还可以包括:从第一消息中间件读取其传输配置信息,从第二消息中间件读取其传输配置信息。此外,对于传输配置信息还可以包括消息中间件所支持的报文编码类型。Optionally, after the electronic device collects the transmission configuration information corresponding to the first message middleware and the transmission configuration information corresponding to the second message middleware, it may also display the transmission configuration information corresponding to the first message middleware and the second message on the display interface. The transmission configuration information corresponding to the middleware. Specifically, the configuration operations performed by the user on the transmission configuration information corresponding to the first message middleware and the transmission configuration information corresponding to the second message middleware may be detected, so as to obtain the transmission configuration information corresponding to the first message middleware configured by the user and the second message The transmission configuration information corresponding to the middleware. In addition, it may specifically include: reading the transmission configuration information from the first messaging middleware, and reading the transmission configuration information from the second messaging middleware. In addition, the transmission configuration information may also include message encoding types supported by the message middleware.

本申请实施例中,电子设备可以采集第一消息中间件的传输配置信息以及第二消息中间件的传输配置信息,通过第一消息中间件对应的传输配置信息和第二节点的传输配置信息,可以生成消息转发信息。消息转发信息可以存储至转发数据库中,即完成消息转发信息的预存储,以存在使用需求时,快速获取第一消息中间件和/或第二消息中间件关联的消息转发信息,提高第一消息中间件和第二消息中间件的传输通路的建立效率,进而快速而稳定地进行两个消息中间件的传输。In the embodiment of the present application, the electronic device can collect the transmission configuration information of the first message middleware and the transmission configuration information of the second message middleware, and use the transmission configuration information corresponding to the first message middleware and the transmission configuration information of the second node, Message forwarding information may be generated. The message forwarding information can be stored in the forwarding database, that is, the pre-storage of the message forwarding information is completed, so that when there is a need for use, the message forwarding information associated with the first message middleware and/or the second message middleware can be quickly obtained, and the first message forwarding information can be improved. The establishment efficiency of the transmission path between the middleware and the second message middleware, and then the transmission of the two message middlewares can be carried out quickly and stably.

进一步地,在上述任一实施例的基础上,消息转发信息包括第一消息中间件的发送队列信息和第二消息中间件的接收队列信息;Further, on the basis of any of the above embodiments, the message forwarding information includes sending queue information of the first messaging middleware and receiving queue information of the second messaging middleware;

根据与第一消息中间件的长连接,接收第一消息中间件发送的第一报文,包括:According to the long connection with the first message middleware, receive the first message sent by the first message middleware, including:

根据与第一消息中间件的长连接对应的接收线程,从第一消息中间件的发送队列信息对应的发送队列拉取第一报文;Pulling the first message from the sending queue corresponding to the sending queue information of the first messaging middleware according to the receiving thread corresponding to the long connection of the first messaging middleware;

根据与第二消息中间件的长连接,将第二报文发送至第二消息中间件,包括:According to the long connection with the second message middleware, the second message is sent to the second message middleware, including:

根据与第二消息中间件的长连接对应的发送线程,将第二报文发送至第二消息中间件在接收队列信息对应的接收队列。According to the sending thread corresponding to the persistent connection of the second messaging middleware, the second message is sent to the receiving queue corresponding to the receiving queue information of the second messaging middleware.

接收线程可以用于接收第一消息中间件的第一报文。发送线程可以用于执行第二报文的发送。通过设置接收线程和发送线程,可以实现报文接收和报文发送的独立执行,提高报文接收和发送效率。The receiving thread may be used to receive the first message of the first message middleware. The sending thread can be used to send the second message. By setting the receiving thread and sending thread, the independent execution of message receiving and message sending can be realized, and the efficiency of message receiving and sending can be improved.

本申请实施例中,可以根据长连接对应的接收线程和发送线程,可以通过发送队列拉取第一报文,可以通过接收队列发送第二报文。实现第一报文的接收和第二报文的队列转发,实现报文的稳定而高效的转发。In the embodiment of the present application, according to the receiving thread and sending thread corresponding to the persistent connection, the first message can be pulled through the sending queue, and the second message can be sent through the receiving queue. Realize the reception of the first message and the queue forwarding of the second message, and realize the stable and efficient forwarding of the message.

进一步地,在上述任一实施例的基础上,根据第二消息中间件的报文格式,将第一报文转换为第二报文,包括:Further, on the basis of any of the above embodiments, converting the first message into the second message according to the message format of the second message middleware includes:

对第一报文进行解析,获得第一报文的消息内容。The first packet is parsed to obtain message content of the first packet.

根据第二消息中间件的报文格式,将消息内容封装至第二报文。Encapsulate the content of the message into the second message according to the message format of the second message middleware.

报文格式可以是指第二消息中间件支持的报文编码类型所对应的报文数据结构。The message format may refer to a message data structure corresponding to a message encoding type supported by the second message middleware.

消息内容可以是第一报文所承载的具体信息。The message content may be specific information carried in the first packet.

本申请实施例中,通过对第一报文的解析,获得第一报文的消息内容,以根据第二消息中间件的报文格式,将消息内容封装至第二报文中,实现从第一报文到第二报文的内容转换,使得第二报文能够适配于第二消息中间件,确保第二报文能够被正常传输至第二消息中间件,确保两种消息中间件的消息转发的稳定性和可靠性。In the embodiment of the present application, the message content of the first message is obtained by analyzing the first message, and the message content is encapsulated into the second message according to the message format of the second message middleware, so as to realize the The content conversion of a message to the second message enables the second message to be adapted to the second message middleware, ensures that the second message can be normally transmitted to the second message middleware, and ensures the compatibility of the two message middleware Stability and reliability of message forwarding.

进一步,可选地,对第一报文进行解析,获得第一报文的消息内容,包括:Further, optionally, the first message is parsed to obtain the message content of the first message, including:

对第一报文进行解析,获得第一报文的消息头和消息体构成的消息内容;Analyzing the first message to obtain message content composed of a message header and a message body of the first message;

根据第二消息中间件的报文格式,将消息内容封装至第二报文,包括:According to the message format of the second message middleware, the message content is encapsulated into the second message, including:

根据第二消息中间件的报文格式,确定第二报文的消息头格式和消息体格式;According to the message format of the second message middleware, determine the message header format and the message body format of the second message;

根据消息头格式,确定第二报文的消息头;Determine the message header of the second message according to the message header format;

根据消息体格式,将第一报文的消息体转换为第二报文的消息体;Converting the message body of the first message into the message body of the second message according to the message body format;

对第二报文的消息头和第二报文的消息体进行封装,获得第二报文。Encapsulate the message header of the second message and the message body of the second message to obtain the second message.

可选地,报文解析是指可以将报文从一种编码方式解析为另一种编码方式的过程。Optionally, message parsing refers to a process of parsing a message from one encoding method to another encoding method.

示例性地,报文可以是以二进制方式编码的,对第一报文进行解析是指将第一报文进行消息头和消息体分割,并将消息头的二进制字符串和消息体的二进制字符串分别转换为使用ASCII(American Standard Code for Information Interchange,美国信息交换标准代码)码方式表示的字符串,获得第一报文的消息头和消息体,该消息头和消息体即可以作为消息内容。Exemplarily, the message may be encoded in a binary manner, and parsing the first message refers to dividing the first message into a message header and a message body, and dividing the binary character string of the message header and the binary character of the message body The strings are respectively converted into strings expressed in ASCII (American Standard Code for Information Interchange, American Standard Code for Information Interchange) code mode, and the message header and message body of the first message are obtained, which can be used as the message content .

对第二报文的消息头和消息体进行封装具体可以是指将第二报文的消息头和消息体转换为适用于通信传输的字符串。例如,将使用ASCII方式构成的字符串转换为二进制编码,获得的二进制字符串即可以为第二报文。Encapsulating the message header and message body of the second message may specifically refer to converting the message header and message body of the second message into a character string suitable for communication transmission. For example, the character string formed in ASCII mode is converted into binary code, and the obtained binary character string can be used as the second message.

本申请实施例中,在将第一报文重新封装为第二报文时,可以基于第一报文的消息头和消息体对应封装至第二消息中间件所对应的报文格式中,实现第二报文格式的分段式封装,确保第二报文的封装更可靠,更有效。In the embodiment of the present application, when the first message is repackaged into the second message, the message header and the message body of the first message can be correspondingly encapsulated into the message format corresponding to the second message middleware to realize The segmented encapsulation of the second message format ensures that the encapsulation of the second message is more reliable and effective.

进一步,可选地,对第一报文进行解析,获得第一报文的消息头和消息体构成的消息内容之后,还包括:Further, optionally, after parsing the first message and obtaining the message content composed of the message header and the message body of the first message, the method further includes:

提取第一报文的消息头中的个性化信息以及其它信息;Extracting the personalized information and other information in the message header of the first message;

根据消息头格式,确定第二报文的消息头,包括:According to the message header format, determine the message header of the second message, including:

根据消息头格式,将第一报文的消息头中的其它信息转换为第二报文的消息头;Converting other information in the message header of the first message into the message header of the second message according to the message header format;

根据消息体格式,将第一报文的消息体转换为第二报文的消息体,包括:Convert the message body of the first message into the message body of the second message according to the message body format, including:

根据消息体格式,将个性化信息和第一报文的消息体转换为第二报文的消息体。Convert the personalized information and the message body of the first message into the message body of the second message according to the message body format.

个性化信息可以是设置于第一报文的消息头中的个性化内容,可以根据使用需求设置。将个性化信息增加到第一报文的消息头,可以实现报文的个性化传输,提高报文传输的灵活性。Personalized information may be personalized content set in the message header of the first packet, which may be set according to usage requirements. Adding personalized information to the message header of the first message can realize personalized transmission of the message and improve the flexibility of message transmission.

本申请实施例中,第一报文的消息头中可以包括个性化的表头信息和其它信息,针对个性化的表头信息,可以将其作为消息体的部分内容封装至第二报文的消息体中,避免因个性化信息与第二报文的消息头不适配出现的报文封装失败或者报文封装成功,但与第二报文的实际格式不适配的问题,实现第二报文的准确封装,提高第二报文的准确封装,避免封装失败或者误差。In this embodiment of the application, the message header of the first message may include personalized header information and other information, and for the personalized header information, it may be encapsulated as part of the message body into the second message In the message body, avoid the problem that the message encapsulation fails or the message encapsulation succeeds but does not match the actual format of the second message due to the incompatibility between the personalized information and the message header of the second message, and realizes the second The accurate encapsulation of the message improves the accurate encapsulation of the second message, and avoids encapsulation failure or error.

进一步地,在上述任一实施例的基础上,根据与第一消息中间件的长连接,接收第一消息中间件发送的第一报文之后,还包括:Further, on the basis of any of the above embodiments, according to the long connection with the first message middleware, after receiving the first message sent by the first message middleware, the method further includes:

从记录数据库中查询第一报文是否关联消息转发记录,记录数据库用于存储多条报文分别对应的消息转发记录,消息转发记录包括报文的转发状态,转发状态包括已转发、未转发或转发失败;Query whether the first message is associated with a message forwarding record from the record database. The record database is used to store message forwarding records corresponding to multiple messages. The message forwarding record includes the forwarding status of the message, and the forwarding status includes forwarded, not forwarded or forwarded. Forwarding failed;

若是,则查询第一报文关联的消息转发记录中的转发状态;If so, query the forwarding status in the message forwarding record associated with the first message;

若第一报文关联的消息转发记录中的转发状态为已转发,则删除第一报文;If the forwarding state in the message forwarding record associated with the first message is forwarded, then delete the first message;

若第一报文关联的消息转发记录中的转发状态为未转发,则执行根据第二消息中间件的报文格式,将第一报文转换为第二报文;If the forwarding state in the message forwarding record associated with the first message is not forwarded, then execute converting the first message into a second message according to the message format of the second message middleware;

若第一报文关联的消息转发记录中的转发状态为转发失败,则将第一报文退回第一消息中间件对应的第一节点。If the forwarding state in the message forwarding record associated with the first message is forwarding failure, return the first message to the first node corresponding to the first message middleware.

可选地,删除第一报文可以指销毁第一报文。在第一报文的转发状态为未转发时,可以执行后续的步骤204和205,实现报文的正常转发。Optionally, deleting the first packet may refer to destroying the first packet. When the forwarding state of the first message is not forwarded, subsequent steps 204 and 205 may be performed to realize normal forwarding of the message.

本申请实施例中,可以通过记录数据库中存储的多条报文分别对应的消息转发记录,消息转发记录用于记录报文的转发状态。通过查询记录数据库可以对第一报文是否存在消息转发记录进行确认。并在第一报文存在消息转发记录的情况下,对第一报文的转发状态进行确认。并在不同转发状态下执行不同的处理,以实现第一报文的准确而有效的转发,避免出现重复转发,并在转发失败时将第一报文退回至第一节点,以将转发结果及时反馈给第一节点,提高第一报文的转发效率和稳定性。In the embodiment of the present application, the message forwarding records corresponding to the multiple messages stored in the database may be recorded, and the message forwarding records are used to record the forwarding status of the messages. Whether there is a message forwarding record in the first message can be confirmed by querying the record database. And if there is a message forwarding record in the first message, confirm the forwarding state of the first message. And perform different processing in different forwarding states to achieve accurate and effective forwarding of the first message, avoid repeated forwarding, and return the first message to the first node when the forwarding fails, so as to timely forward the forwarding result Feedback to the first node to improve the forwarding efficiency and stability of the first message.

进一步,可选地,从记录数据库中查询第一报文是否关联消息转发记录之后,还包括:Further, optionally, after querying whether the first message is associated with a message forwarding record from the record database, it also includes:

若否,则在根据与第二消息中间件的长连接,将第二报文发送至第二消息中间件之后,根据第一报文的转发状态,生成消息转发记录,消息转发记录;If not, then according to the long connection with the second message middleware, after the second message is sent to the second message middleware, according to the forwarding state of the first message, generate a message forwarding record, a message forwarding record;

将消息转发记录存储于记录数据库中。Store message forwarding records in a records database.

本实施例中,在记录数据库中未查询到第一报文的消息转发记录时,可以利用第一报文的转发状态,生成第一报文的消息转发记录,并将第一报文的消息转发记录存储于记录数据库中。在第二报文转发之后,可以根据其转发状态,确定第一报文的消息转发记录,以实现消息转发记录的及时存储,并参与到后续的转发监控场景,提高报文转发的有效性和可靠性。In this embodiment, when the message forwarding record of the first message is not found in the record database, the forwarding state of the first message can be used to generate the message forwarding record of the first message, and the message forwarding record of the first message can be Forwarding records are stored in a records database. After the second message is forwarded, the message forwarding record of the first message can be determined according to its forwarding status, so as to realize the timely storage of the message forwarding record, participate in the subsequent forwarding monitoring scene, and improve the effectiveness and efficiency of message forwarding. reliability.

进一步地,在上述任一实施例的基础上,根据与第二消息中间件的长连接,将第二报文发送至第二消息中间件之后,还包括:Further, on the basis of any of the above embodiments, according to the long connection with the second message middleware, after sending the second message to the second message middleware, it also includes:

若第二报文发送失败,则将第一报文推送至死信队列;If the sending of the second message fails, push the first message to the dead letter queue;

基于定时补偿任务,从死信队列中拉取转发失败的第一报文;Based on the timing compensation task, pull the first message that fails to be forwarded from the dead letter queue;

根据第二消息中间件的报文格式,将转发失败的第一报文重新转换为第三报文;According to the message format of the second message middleware, the first message that fails to be forwarded is re-converted into a third message;

根据长连接,将第三报文补偿发送至第二节点。According to the long connection, the third packet is compensated and sent to the second node.

可选地,死信队列可以用于存储传输失败的至少一条报文。任意一条报文传输失败则可以将该报文推送至死信队列,并根据定时补偿任务,从死信队列中拉取转发失败的报文,实现报文的重传。Optionally, the dead letter queue may be used to store at least one message whose transmission fails. If any message fails to be transmitted, the message can be pushed to the dead letter queue, and according to the timing compensation task, the message that fails to be forwarded is pulled from the dead letter queue to realize the retransmission of the message.

其中,定时补偿任务是指基于设置的补偿频率,执行定频补偿。在当前时间达到按照补偿频率确定的补偿时间时,则可以开始从死信队列中逐一拉取转发失败的第一报文,以重新执行报文格式转换以及补偿发送。The timing compensation task refers to performing fixed frequency compensation based on the set compensation frequency. When the current time reaches the compensation time determined according to the compensation frequency, the first packets that fail to be forwarded can be pulled from the dead letter queue one by one, so as to re-execute the packet format conversion and compensation sending.

本申请实施例中,可以在第二报文发送失败时,将第一报文推送至死信队列。死信队列中可以存储传输失败的第一报文,以在定时补偿任务的执行下,从死信队列中拉取转发失败的第一报文,以将拉取失败的第一报文重新进行报文转换以及发送。可以对消息转发失败的第一报文进行补偿传输,提高传输成功率,进而使得两个不同消息中间件的消息转发的可靠性有效提升。In the embodiment of the present application, when the sending of the second message fails, the first message may be pushed to the dead letter queue. The first message that failed to be transmitted can be stored in the dead letter queue, so that under the execution of the timing compensation task, the first message that failed to be forwarded can be pulled from the dead letter queue, so that the first message that failed to be pulled can be reprocessed. Message conversion and sending. Compensation and transmission can be performed on the first message that fails to be forwarded to improve the transmission success rate, thereby effectively improving the reliability of message forwarding by two different message middleware.

如图4所示,为本申请实施例提供的一种消息转发装置的一个实施例的结构示意图,该消息转发装置可以执行上述任一种消息转发方法。消息转发装置可以位于电子设备中。其中,消息转发装置400,可以包括:As shown in FIG. 4 , it is a schematic structural diagram of an embodiment of a message forwarding device provided in an embodiment of the present application, and the message forwarding device can implement any one of the above message forwarding methods. The message forwarding means may be located in the electronic device. Wherein, the message forwarding device 400 may include:

确定单元401:用于确定第一消息中间件和第二消息中间件对应的消息转发信息,第一消息中间件和第二消息中间件类型不同,消息转发信息用于指示第一消息中间件和第二消息中间件各自的配置参数;Determining unit 401: used to determine message forwarding information corresponding to the first message middleware and the second message middleware, the first message middleware and the second message middleware are of different types, and the message forwarding information is used to indicate the first message middleware and the second message middleware Respective configuration parameters of the second message middleware;

建立单元402:用于基于消息转发信息,分别与第一消息中间件和第二消息中间件建立长连接;Establishing unit 402: for establishing a long connection with the first message middleware and the second message middleware respectively based on the message forwarding information;

接收单元403:用于根据与第一消息中间件的长连接,接收第一消息中间件发送的第一报文;The receiving unit 403: configured to receive the first message sent by the first message middleware according to the long connection with the first message middleware;

转换单元404:用于根据第二消息中间件的报文格式,将第一报文转换为第二报文;A conversion unit 404: configured to convert the first message into the second message according to the message format of the second message middleware;

发送单元405:用于根据与第二消息中间件的长连接,将第二报文发送至第二消息中间件。Sending unit 405: configured to send the second packet to the second messaging middleware according to the long connection with the second messaging middleware.

进一步地,在上述任一实施例的基础上,确定单元,包括:Further, on the basis of any of the above embodiments, the determining unit includes:

请求接收模块,用于接收消息转发服务的启动请求,启动请求包括第一消息中间件的标识信息和第二消息中间件的标识信息;The request receiving module is configured to receive an activation request of the message forwarding service, where the activation request includes identification information of the first messaging middleware and identification information of the second messaging middleware;

请求响应模块,用于响应于启动请求,确定第一消息中间件的标识信息和/或第二消息中间件的标识信息对应的消息转发信息。The request response module is configured to determine message forwarding information corresponding to the identification information of the first messaging middleware and/or the identification information of the second messaging middleware in response to the start request.

进一步地,在上述任一实施例的基础上,还包括:Further, on the basis of any of the above embodiments, it also includes:

采集单元,用于采集第一消息中间件对应的传输配置信息以及第二消息中间件对应的传输配置信息;A collection unit, configured to collect transmission configuration information corresponding to the first message middleware and transmission configuration information corresponding to the second message middleware;

生成单元,用于根据第一消息中间件对应的传输配置信息和第二消息中间件对应的传输配置信息,生成消息转发信息;A generating unit, configured to generate message forwarding information according to the transmission configuration information corresponding to the first message middleware and the transmission configuration information corresponding to the second message middleware;

存储单元,用于将消息转发信息存储至转发数据库中;a storage unit, configured to store message forwarding information in a forwarding database;

确定单元,包括:Identify units, including:

信息查询模块,用于从转发数据库中查询与第一消息中间件和/或第二消息中间件关联的消息转发信息。An information query module, configured to query message forwarding information associated with the first message middleware and/or the second message middleware from the forwarding database.

进一步地,在上述任一实施例的基础上,消息转发信息包括第一消息中间件的发送队列信息和第二消息中间件的接收队列信息;Further, on the basis of any of the above embodiments, the message forwarding information includes sending queue information of the first messaging middleware and receiving queue information of the second messaging middleware;

接收单元,包括:Receiver unit, including:

报文拉取模块,用于根据与第一消息中间件的长连接对应的接收线程,从第一消息中间件的发送队列信息对应的发送队列拉取第一报文;The message pulling module is used to pull the first message from the sending queue corresponding to the sending queue information of the first message middleware according to the receiving thread corresponding to the long connection of the first message middleware;

发送单元,包括:sending unit, consisting of:

报文发送模块,用于根据与第二消息中间件的长连接对应的发送线程,将第二报文发送至第二消息中间件在接收队列信息对应的接收队列。The message sending module is configured to send the second message to the receiving queue corresponding to the receiving queue information of the second messaging middleware according to the sending thread corresponding to the long connection of the second messaging middleware.

进一步地,在上述任一实施例的基础上,转换单元,包括:Further, on the basis of any of the above embodiments, the converting unit includes:

报文解析模块,用于对第一报文进行解析,获得第一报文的消息内容;A message parsing module, configured to parse the first message to obtain the message content of the first message;

报文封装模块,用于根据第二消息中间件的报文格式,将消息内容封装至第二报文。The packet encapsulation module is configured to encapsulate the message content into the second packet according to the packet format of the second message middleware.

进一步地,在上述任一实施例的基础上,报文解析模块,包括:Further, on the basis of any of the above-mentioned embodiments, the message parsing module includes:

报文解析子模块,用于对第一报文进行解析,获得第一报文的消息头和消息体构成的消息内容;The message parsing sub-module is used for parsing the first message to obtain the message content composed of the message header and the message body of the first message;

报文封装模块,包括:Packet encapsulation module, including:

格式确定子模块,用于根据第二消息中间件的报文格式,确定第二报文的消息头格式和消息体格式;A format determining submodule, configured to determine the message header format and message body format of the second message according to the message format of the second message middleware;

第一确定子模块,用于根据消息头格式,确定第二报文的消息头;The first determining submodule is used to determine the message header of the second message according to the format of the message header;

第二确定子模块,用于根据消息体格式,将第一报文的消息体转换为第二报文的消息体;The second determining submodule is used to convert the message body of the first message into the message body of the second message according to the message body format;

报文确定子模块,用于对第二报文的消息头和第二报文的消息体进行封装,获得第二报文。The message determining submodule is configured to encapsulate the message header of the second message and the message body of the second message to obtain the second message.

进一步地,在上述任一实施例的基础上,还包括:Further, on the basis of any of the above embodiments, it also includes:

个性提取单元,用于提取第一报文的消息头中的个性化信息以及其它信息;a personality extraction unit, configured to extract the personalized information and other information in the message header of the first message;

第一确定子模块,具体可以用于:The first sub-module is determined, which can be specifically used for:

根据消息头格式,将第一报文的消息头中的其它信息转换为第二报文的消息头;Converting other information in the message header of the first message into the message header of the second message according to the message header format;

第二确定子模块,具体可以用于:The second determination sub-module can be specifically used for:

根据消息体格式,将个性化信息和第一报文的消息体转换为第二报文的消息体。Convert the personalized information and the message body of the first message into the message body of the second message according to the message body format.

进一步地,在上述任一实施例的基础上,还包括:Further, on the basis of any of the above embodiments, it also includes:

记录查询单元,用于从记录数据库中查询第一报文是否关联消息转发记录,记录数据库用于存储多条报文分别对应的消息转发记录,消息转发记录包括报文的转发状态,转发状态包括已转发、未转发或转发失败;The record query unit is used to query whether the first message is associated with a message forwarding record from the record database, and the record database is used to store message forwarding records corresponding to a plurality of messages respectively, the message forwarding record includes the forwarding status of the message, and the forwarding status includes forwarded, not forwarded or failed to forward;

状态查询单元,用于若是,则获取第一报文关联的消息转发记录中的转发状态;The state query unit is used to obtain the forwarding state in the message forwarding record associated with the first message if it is true;

第一处理单元,用于若第一报文关联的消息转发记录中的转发状态为已转发,则删除第一报文;The first processing unit is configured to delete the first message if the forwarding state in the message forwarding record associated with the first message is forwarded;

第二处理单元,用于若第一报文关联的消息转发记录中的转发状态为未转发,则执行根据第二消息中间件的报文格式,将第一报文转换为第二报文;The second processing unit is configured to convert the first message into the second message according to the message format of the second message middleware if the forwarding state in the message forwarding record associated with the first message is not forwarded;

第三处理单元,用于若第一报文关联的消息转发记录中的转发状态为转发失败,则将第一报文退回第一消息中间件。The third processing unit is configured to return the first message to the first message middleware if the forwarding status in the message forwarding record associated with the first message is forwarding failure.

进一步地,在上述任一实施例的基础上,还包括:Further, on the basis of any of the above embodiments, it also includes:

记录生成单元,用于若否,则在根据与第二消息中间件的长连接,将第二报文发送至第二消息中间件之后,根据第一报文的转发状态,生成消息转发记录,消息转发记录;The record generating unit is configured to, if not, generate a message forwarding record according to the forwarding state of the first message after the second message is sent to the second message middleware according to the long connection with the second message middleware, message forwarding record;

记录存储单元,用于将消息转发记录存储于记录数据库中。The record storage unit is used for storing the message forwarding record in the record database.

进一步地,在上述任一实施例的基础上,还包括:Further, on the basis of any of the above embodiments, it also includes:

失败处理单元,用于若第二报文发送失败,则将第一报文推送至死信队列;a failure processing unit, configured to push the first message to the dead letter queue if the second message fails to be sent;

定时处理单元,用于基于定时补偿任务,从死信队列中拉取转发失败的第一报文;A timing processing unit, configured to pull the first message that fails to be forwarded from the dead letter queue based on the timing compensation task;

重新转换单元,用于根据第二消息中间件的报文格式,将转发失败的第一报文重新转换为第三报文;A reconversion unit, configured to reconvert the first message that failed to be forwarded into a third message according to the message format of the second message middleware;

补偿发送单元,用于根据长连接,将第三报文补偿发送至第二消息中间件。The compensation sending unit is configured to send the third message compensation to the second message middleware according to the long connection.

图5是根据一示例性实施例示出的一种节点的框图,该设备可以是移动电话,计算机,数字广播终端,消息收发设备,游戏控制台,平板设备,医疗设备,健身设备,个人数字助理等。Fig. 5 is a block diagram showing a node according to an exemplary embodiment, the device may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant wait.

装置500可以包括以下一个或多个组件:处理组件502,存储器504,电源组件506,多媒体组件508,音频组件510,输入/输出(I/O)接口512,传感器组件514,以及通信组件516。Apparatus 500 may include one or more of the following components: processing component 502, memory 504, power supply component 506, multimedia component 508, audio component 510, input/output (I/O) interface 512, sensor component 514, and communication component 516.

处理组件502通常控制装置500的整体操作,诸如与显示,电话呼叫,数据通信,相机操作和记录操作相关联的操作。处理组件502可以包括一个或多个处理器520来执行指令,以完成上述的方法的全部或部分步骤。此外,处理组件502可以包括一个或多个模块,便于处理组件502和其他组件之间的交互。例如,处理组件502可以包括多媒体模块,以方便多媒体组件508和处理组件502之间的交互。The processing component 502 generally controls the overall operations of the device 500, such as those associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 502 may include one or more processors 520 to execute instructions to complete all or part of the steps of the above method. Additionally, processing component 502 may include one or more modules that facilitate interaction between processing component 502 and other components. For example, processing component 502 may include a multimedia module to facilitate interaction between multimedia component 508 and processing component 502 .

存储器504被配置为存储各种类型的数据以支持在装置500的操作。这些数据的示例包括用于在装置500上操作的任何应用程序或方法的指令,联系人数据,电话簿数据,消息,图片,视频等。存储器504可以由任何类型的易失性或非易失性存储设备或者它们的组合实现,如静态随机存取存储器(SRAM),电可擦除可编程只读存储器(EEPROM),可擦除可编程只读存储器(EPROM),可编程只读存储器(PROM),只读存储器(ROM),磁存储器,快闪存储器,磁盘或光盘。The memory 504 is configured to store various types of data to support operations at the device 500 . Examples of such data include instructions for any application or method operating on device 500, contact data, phonebook data, messages, pictures, videos, and the like. The memory 504 can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable Programmable Read Only Memory (EPROM), Programmable Read Only Memory (PROM), Read Only Memory (ROM), Magnetic Memory, Flash Memory, Magnetic or Optical Disk.

电源组件506为装置500的各种组件提供电力。电源组件506可以包括电源管理系统,一个或多个电源,及其他与为装置500生成、管理和分配电力相关联的组件。The power supply component 506 provides power to various components of the device 500 . Power components 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for device 500 .

多媒体组件508包括在装置500和用户之间的提供一个输出接口的屏幕。在一些实施例中,屏幕可以包括液晶显示器(LCD)和触摸面板(TP)。如果屏幕包括触摸面板,屏幕可以被实现为触摸屏,以接收来自用户的输入信号。触摸面板包括一个或多个触摸传感器以感测触摸、滑动和触摸面板上的手势。触摸传感器可以不仅感测触摸或滑动动作的边界,而且还检测与触摸或滑动操作相关的持续时间和压力。在一些实施例中,多媒体组件508包括一个前置摄像头和/或后置摄像头。当装置500处于操作模式,如拍摄模式或视频模式时,前置摄像头和/或后置摄像头可以接收外部的多媒体数据。每个前置摄像头和后置摄像头可以是一个固定的光学透镜系统或具有焦距和光学变焦能力。The multimedia component 508 includes a screen that provides an output interface between the device 500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may not only sense a boundary of a touch or a swipe action, but also detect duration and pressure associated with the touch or swipe operation. In some embodiments, the multimedia component 508 includes a front camera and/or a rear camera. When the device 500 is in an operation mode, such as a shooting mode or a video mode, the front camera and/or the rear camera can receive external multimedia data. Each front camera and rear camera can be a fixed optical lens system or have focal length and optical zoom capability.

音频组件510被配置为输出和/或输入音频信号。例如,音频组件510包括一个麦克风(MIC),当装置500处于操作模式,如呼叫模式、记录模式和语音识别模式时,麦克风被配置为接收外部音频信号。所接收的音频信号可以被进一步存储在存储器504或经由通信组件516发送。在一些实施例中,音频组件510还包括一个扬声器,用于输出音频信号。The audio component 510 is configured to output and/or input audio signals. For example, the audio component 510 includes a microphone (MIC), which is configured to receive external audio signals when the device 500 is in operation modes, such as call mode, recording mode and voice recognition mode. Received audio signals may be further stored in memory 504 or sent via communication component 516 . In some embodiments, the audio component 510 also includes a speaker for outputting audio signals.

I/O接口512为处理组件502和外围接口模块之间提供接口,上述外围接口模块可以是键盘,点击轮,按钮等。这些按钮可包括但不限于:主页按钮、音量按钮、启动按钮和锁定按钮。The I/O interface 512 provides an interface between the processing component 502 and a peripheral interface module. The peripheral interface module may be a keyboard, a click wheel, a button, and the like. These buttons may include, but are not limited to: a home button, volume buttons, start button, and lock button.

传感器组件514包括一个或多个传感器,用于为装置500提供各个方面的状态检测。例如,传感器组件514可以检测到装置500的打开/关闭状态,组件的相对定位,例如组件为装置500的显示器和小键盘,传感器组件514还可以检测装置500或装置500一个组件的位置改变,用户与装置500接触的存在或不存在,装置500方位或加速/减速和装置500的温度变化。传感器组件514可以包括接近传感器,被配置用来在没有任何的物理接触时检测附近物体的存在。传感器组件514还可以包括光传感器,如CMOS或CCD图像传感器,用于在成像应用中使用。在一些实施例中,该传感器组件514还可以包括加速度传感器,陀螺仪传感器,磁传感器,压力传感器或温度传感器。Sensor assembly 514 includes one or more sensors for providing status detection of various aspects of device 500 . For example, the sensor component 514 can detect the open/closed state of the device 500, the relative positioning of components, such as the display and keypad of the device 500, the sensor component 514 can also detect a change in the position of the device 500 or a component of the device 500, the user Presence or absence of contact with device 500 , device 500 orientation or acceleration/deceleration and temperature change of device 500 . Sensor assembly 514 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. Sensor assembly 514 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 514 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor.

通信组件516被配置为便于装置500和其他设备之间有线或无线方式的通信。装置500可以接入基于通信标准的无线网络,如WiFi,2G或3G,或它们的组合。在一个示例性实施例中,通信组件516经由广播信道接收来自外部广播管理系统的广播信号或广播相关信息。在一个示例性实施例中,通信组件516还包括近场通信(NFC)模块,以促进短程通信。例如,在NFC模块可基于射频识别(RFID)技术,红外数据协会(IrDA)技术,超宽带(UWB)技术,蓝牙(BT)技术和其他技术来实现。The communication component 516 is configured to facilitate wired or wireless communication between the apparatus 500 and other devices. The device 500 can access wireless networks based on communication standards, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 516 receives broadcast signals or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, communication component 516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, Infrared Data Association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

在示例性实施例中,装置500可以被一个或多个应用专用集成电路(ASIC)、数字信号处理器(DSP)、数字信号处理设备(DSPD)、可编程逻辑器件(PLD)、现场可编程门阵列(FPGA)、控制器、微控制器、微处理器或其他电子元件实现,用于执行上述方法。In an exemplary embodiment, apparatus 500 may be programmed by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable A gate array (FPGA), controller, microcontroller, microprocessor or other electronic component implementation for performing the methods described above.

在示例性实施例中,还提供了一种包括指令的非临时性计算机可读存储介质,例如包括指令的存储器504,上述指令可由装置500的处理器520执行以完成上述方法。例如,非临时性计算机可读存储介质可以是ROM、随机存取存储器(RAM)、CD-ROM、磁带、软盘和光数据存储设备等。In an exemplary embodiment, there is also provided a non-transitory computer-readable storage medium including instructions, such as the memory 504 including instructions, which can be executed by the processor 520 of the device 500 to implement the above method. For example, the non-transitory computer readable storage medium may be ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, and the like.

本申请提供一种电子设备,包括:处理器,以及与处理器通信连接的存储器;The present application provides an electronic device, including: a processor, and a memory connected to the processor in communication;

存储器存储计算机执行指令;the memory stores computer-executable instructions;

处理器执行存储器存储的计算机执行指令,以实现如上述任一实施例可能的方法。The processor executes the computer-executable instructions stored in the memory, so as to implement the possible method in any one of the foregoing embodiments.

本申请提供一种计算机可读存储介质,计算机可读存储介质中存储有计算机执行指令,计算机执行指令被处理器执行时用于实现如任一实施例可能的方法。The present application provides a computer-readable storage medium. Computer-executable instructions are stored in the computer-readable storage medium. When executed by a processor, the computer-readable instructions are used to implement the method as possible in any embodiment.

本申请提供一种计算机程序产品,包括计算机程序,该计算机程序被处理器执行时实现如任一实施例可能的方法。The present application provides a computer program product, including a computer program. When the computer program is executed by a processor, the method as possible in any embodiment is implemented.

本领域技术人员在考虑说明书及实践这里公开的发明后,将容易想到本申请的其它实施方案。本申请旨在涵盖本申请的任何变型、用途或者适应性变化,这些变型、用途或者适应性变化遵循本申请的一般性原理并包括本申请未公开的本技术领域中的公知常识或惯用技术手段。说明书和实施例仅被视为示例性的,本申请的真正范围和精神由下面的权利要求书指出。Other embodiments of the present application will be readily apparent to those skilled in the art from consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the application, these modifications, uses or adaptations follow the general principles of the application and include common knowledge or conventional technical means in the technical field not disclosed in the application . The specification and examples are to be considered exemplary only, with a true scope and spirit of the application indicated by the following claims.

应当理解的是,本申请并不局限于上面已经描述并在附图中示出的精确结构,并且可以在不脱离其范围进行各种修改和改变。本申请的范围仅由所附的权利要求书来限制。It should be understood that the present application is not limited to the precise constructions which have been described above and shown in the accompanying drawings, and various modifications and changes may be made without departing from the scope thereof. The scope of the application is limited only by the appended claims.

Claims (13)

1.一种消息转发方法,其特征在于,包括:1. A message forwarding method, characterized in that, comprising: 确定第一消息中间件和第二消息中间件对应的消息转发信息,所述第一消息中间件和所述第二消息中间件类型不同,所述消息转发信息用于指示所述第一消息中间件和所述第二消息中间件各自的传输配置;Determine message forwarding information corresponding to the first message middleware and the second message middleware, the first message middleware and the second message middleware are of different types, and the message forwarding information is used to indicate that the first message middleware The respective transmission configurations of the middleware and the second message middleware; 基于所述消息转发信息,分别与所述第一消息中间件和所述第二消息中间件建立长连接;Establishing a long connection with the first message middleware and the second message middleware respectively based on the message forwarding information; 根据与所述第一消息中间件的长连接,接收所述第一消息中间件发送的第一报文;Receive the first message sent by the first message middleware according to the long connection with the first message middleware; 根据所述第二消息中间件的报文格式,将所述第一报文转换为第二报文;converting the first message into a second message according to the message format of the second message middleware; 根据与所述第二消息中间件的长连接,将所述第二报文发送至所述第二消息中间件。Send the second message to the second message middleware according to the long connection with the second message middleware. 2.根据权利要求1所述的方法,其特征在于,所述确定第一消息中间件和第二消息中间件对应的消息转发信息,包括:2. The method according to claim 1, wherein the determining the message forwarding information corresponding to the first message middleware and the second message middleware comprises: 接收消息转发服务的启动请求,所述启动请求包括所述第一消息中间件的标识信息和所述第二消息中间件的标识信息;Receive an activation request of the message forwarding service, where the activation request includes identification information of the first messaging middleware and identification information of the second messaging middleware; 响应于所述启动请求,确定所述第一消息中间件的标识信息和/或所述第二消息中间件的标识信息对应的消息转发信息。In response to the start request, determine message forwarding information corresponding to the identification information of the first messaging middleware and/or the identification information of the second messaging middleware. 3.根据权利要求1或2所述的方法,其特征在于,还包括:3. The method according to claim 1 or 2, further comprising: 采集所述第一消息中间件对应的传输配置信息以及所述第二消息中间件对应的传输配置信息;Collecting transmission configuration information corresponding to the first messaging middleware and transmission configuration information corresponding to the second messaging middleware; 根据所述第一消息中间件对应的传输配置信息和所述第二消息中间件对应的传输配置信息,生成所述消息转发信息;generating the message forwarding information according to the transmission configuration information corresponding to the first messaging middleware and the transmission configuration information corresponding to the second messaging middleware; 将所述消息转发信息存储至转发数据库中;storing the message forwarding information in a forwarding database; 所述确定第一消息中间件和第二消息中间件对应的消息转发信息,包括:The determining the message forwarding information corresponding to the first message middleware and the second message middleware includes: 从所述转发数据库中查询与所述第一消息中间件和/或所述第二消息中间件关联的消息转发信息。Querying message forwarding information associated with the first message middleware and/or the second message middleware from the forwarding database. 4.根据权利要求1所述的方法,其特征在于,所述消息转发信息包括所述第一消息中间件的发送队列信息和所述第二消息中间件的接收队列信息;4. The method according to claim 1, wherein the message forwarding information includes sending queue information of the first messaging middleware and receiving queue information of the second messaging middleware; 所述根据与所述第一消息中间件的长连接,接收所述第一消息中间件发送的第一报文,包括:The receiving the first message sent by the first message middleware according to the long connection with the first message middleware includes: 根据与所述第一消息中间件的长连接对应的接收线程,从所述第一消息中间件的所述发送队列信息对应的发送队列拉取所述第一报文;Pulling the first message from the sending queue corresponding to the sending queue information of the first messaging middleware according to the receiving thread corresponding to the long connection of the first messaging middleware; 所述根据与所述第二消息中间件的长连接,将所述第二报文发送至所述第二消息中间件,包括:The sending the second message to the second message middleware according to the long connection with the second message middleware includes: 根据与所述第二消息中间件的长连接对应的发送线程,将所述第二报文发送至所述第二消息中间件在所述接收队列信息对应的接收队列。Send the second message to the receiving queue corresponding to the receiving queue information of the second messaging middleware according to the sending thread corresponding to the persistent connection of the second messaging middleware. 5.根据权利要求1所述的方法,其特征在于,所述根据所述第二消息中间件的报文格式,将所述第一报文转换为第二报文,包括:5. The method according to claim 1, wherein converting the first message into a second message according to the message format of the second message middleware comprises: 对所述第一报文进行解析,获得所述第一报文的消息内容;Analyzing the first packet to obtain message content of the first packet; 根据所述第二消息中间件的报文格式,将所述消息内容封装至所述第二报文。Encapsulating the message content into the second message according to the message format of the second message middleware. 6.根据权利要求5所述的方法,其特征在于,所述对所述第一报文进行解析,获得所述第一报文的消息内容,包括:6. The method according to claim 5, wherein said parsing said first message to obtain the message content of said first message comprises: 对所述第一报文进行解析,获得所述第一报文的消息头和消息体构成的消息内容;Analyzing the first message to obtain message content composed of a message header and a message body of the first message; 所述根据所述第二消息中间件的报文格式,将所述消息内容封装至所述第二报文,包括:According to the message format of the second message middleware, encapsulating the message content into the second message includes: 根据所述第二消息中间件的报文格式,确定所述第二报文的消息头格式和消息体格式;Determine the message header format and message body format of the second message according to the message format of the second message middleware; 根据所述消息头格式,确定所述第二报文的消息头;Determine the message header of the second message according to the message header format; 根据所述消息体格式,将所述第一报文的消息体转换为所述第二报文的消息体;converting the message body of the first message into the message body of the second message according to the message body format; 对所述第二报文的消息头和所述第二报文的消息体进行封装,获得所述第二报文。Encapsulate the message header of the second message and the message body of the second message to obtain the second message. 7.根据权利要求6所述的方法,其特征在于,所述对所述第一报文进行解析,获得所述第一报文的消息头和消息体构成的消息内容之后,还包括:7. The method according to claim 6, wherein after analyzing the first message and obtaining the message content formed by the message header and the message body of the first message, further comprising: 提取所述第一报文的消息头中的个性化信息以及其它信息;Extracting the personalized information and other information in the message header of the first message; 所述根据所述消息头格式,确定所述第二报文的消息头,包括:The determining the message header of the second message according to the message header format includes: 根据所述消息头格式,将所述第一报文的消息头中的其它信息转换为所述第二报文的消息头;converting other information in the message header of the first message into the message header of the second message according to the message header format; 所述根据所述消息体格式,将所述第一报文的消息体转换为所述第二报文的消息体,包括:The converting the message body of the first message into the message body of the second message according to the message body format includes: 根据所述消息体格式,将所述个性化信息和所述第一报文的消息体转换为所述第二报文的消息体。Converting the personalized information and the message body of the first message into the message body of the second message according to the message body format. 8.根据权利要求1所述的方法,其特征在于,所述根据与所述第一消息中间件的长连接,接收所述第一消息中间件发送的第一报文之后,还包括:8. The method according to claim 1, characterized in that, after receiving the first message sent by the first message middleware according to the long connection with the first message middleware, further comprising: 从记录数据库中查询所述第一报文是否关联消息转发记录,所述记录数据库用于存储多条报文分别对应的消息转发记录,所述消息转发记录包括报文的转发状态,所述转发状态包括已转发、未转发或转发失败;Query whether the first message is associated with a message forwarding record from the record database, the record database is used to store message forwarding records corresponding to a plurality of messages, the message forwarding record includes the forwarding status of the message, and the forwarding Status includes Forwarded, Not Forwarded, or Forwarded Failed; 若是,则获取所述第一报文关联的消息转发记录中的转发状态;If so, obtain the forwarding status in the message forwarding record associated with the first message; 若所述第一报文关联的消息转发记录中的转发状态为已转发,则删除所述第一报文;If the forwarding state in the message forwarding record associated with the first message is forwarded, then delete the first message; 若所述第一报文关联的消息转发记录中的转发状态为未转发,则执行根据所述第二消息中间件的报文格式,将所述第一报文转换为第二报文;If the forwarding state in the message forwarding record associated with the first message is not forwarded, perform converting the first message into a second message according to the message format of the second message middleware; 若所述第一报文关联的消息转发记录中的转发状态为转发失败,则将所述第一报文退回所述第一消息中间件。If the forwarding state in the message forwarding record associated with the first message is forwarding failure, return the first message to the first message middleware. 9.根据权利要求8所述的方法,其特征在于,所述从记录数据库中查询所述第一报文是否关联消息转发记录之后,还包括:9. The method according to claim 8, wherein after querying whether the first message is associated with a message forwarding record from the record database, further comprising: 若否,则在所述根据与所述第二消息中间件的长连接,将所述第二报文发送至所述第二消息中间件之后,根据所述第一报文,生成所述第一报文的消息转发记录;If not, after the second message is sent to the second message middleware according to the long connection with the second message middleware, the first message is generated according to the first message A message forwarding record of a message; 将所述第一报文的消息转发记录存储于所述记录数据库中。storing the message forwarding record of the first message in the record database. 10.根据权利要求1所述的方法,其特征在于,所述根据与所述第二消息中间件的长连接,将所述第二报文发送至所述第二消息中间件之后,还包括:10. The method according to claim 1, characterized in that, after sending the second message to the second message middleware according to the long connection with the second message middleware, further comprising: : 若所述第二报文发送失败,则将所述第一报文推送至死信队列;If the sending of the second message fails, pushing the first message to a dead letter queue; 基于定时补偿任务,从所述死信队列中拉取转发失败的第一报文;Based on the timing compensation task, pull the first message that fails to be forwarded from the dead letter queue; 根据所述第二消息中间件的报文格式,将所述转发失败的第一报文重新转换为第三报文;Reconverting the first message that failed to be forwarded into a third message according to the message format of the second message middleware; 根据所述长连接,将所述第三报文补偿发送至所述第二消息中间件。Send the third message compensation to the second message middleware according to the long connection. 11.一种消息转发装置,其特征在于,包括:11. A message forwarding device, characterized in that it comprises: 确定单元,用于确定第一消息中间件和第二消息中间件对应的消息转发信息,所述第一消息中间件和所述第二消息中间件类型不同,所述消息转发信息用于指示所述第一消息中间件和所述第二消息中间件各自的配置参数;A determining unit, configured to determine message forwarding information corresponding to the first message middleware and the second message middleware, where the types of the first message middleware and the second message middleware are different, and the message forwarding information is used to indicate the Respective configuration parameters of the first message middleware and the second message middleware; 建立单元,用于基于所述消息转发信息,分别与所述第一消息中间件和所述第二消息中间件建立长连接;An establishing unit, configured to respectively establish a long connection with the first message middleware and the second message middleware based on the message forwarding information; 接收单元,用于根据与所述第一消息中间件的长连接,接收所述第一消息中间件发送的第一报文;a receiving unit, configured to receive the first message sent by the first message middleware according to the long connection with the first message middleware; 转换单元,用于根据所述第二消息中间件的报文格式,将所述第一报文转换为第二报文;A conversion unit, configured to convert the first message into a second message according to the message format of the second message middleware; 发送单元,用于根据与所述第二消息中间件的长连接,将所述第二报文发送至所述第二消息中间件。A sending unit, configured to send the second message to the second message middleware according to the long connection with the second message middleware. 12.一种电子设备,其特征在于,包括:处理器,以及与所述处理器通信连接的存储器;12. An electronic device, comprising: a processor, and a memory communicatively connected to the processor; 所述存储器存储计算机执行指令;the memory stores computer-executable instructions; 所述处理器执行所述存储器存储的计算机执行指令,以实现如权利要求1至10任一项所述的方法。The processor executes the computer-implemented instructions stored in the memory to implement the method according to any one of claims 1-10. 13.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机执行指令,所述计算机执行指令被处理器执行时用于实现如权利要求1至10任一项所述的方法。13. A computer-readable storage medium, characterized in that computer-executable instructions are stored in the computer-readable storage medium, and the computer-executable instructions are used to implement any one of claims 1 to 10 when executed by a processor the method described.
CN202310436226.5A 2023-04-21 2023-04-21 Message forwarding method, device, electronic device and storage medium Pending CN116506501A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310436226.5A CN116506501A (en) 2023-04-21 2023-04-21 Message forwarding method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310436226.5A CN116506501A (en) 2023-04-21 2023-04-21 Message forwarding method, device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN116506501A true CN116506501A (en) 2023-07-28

Family

ID=87325881

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310436226.5A Pending CN116506501A (en) 2023-04-21 2023-04-21 Message forwarding method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN116506501A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100161821A1 (en) * 2008-12-18 2010-06-24 Slamkovic Richard D Midleware broker
CN110365802A (en) * 2019-08-26 2019-10-22 北京奇艺世纪科技有限公司 A kind of method for message transmission, message forwarding device and storage medium
CN112153158A (en) * 2020-09-29 2020-12-29 中国银行股份有限公司 Information processing method and device
CN112291254A (en) * 2020-11-05 2021-01-29 中国人民银行清算总中心 Message processing method and device for reliable transaction
CN112788074A (en) * 2019-11-07 2021-05-11 中兴通讯股份有限公司 Data transmitting method, processing method, receiving method and equipment and storage medium
CN115134361A (en) * 2022-06-20 2022-09-30 中汽创智科技有限公司 Cross-platform communication method and device for automatic driving software platform

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100161821A1 (en) * 2008-12-18 2010-06-24 Slamkovic Richard D Midleware broker
CN110365802A (en) * 2019-08-26 2019-10-22 北京奇艺世纪科技有限公司 A kind of method for message transmission, message forwarding device and storage medium
CN112788074A (en) * 2019-11-07 2021-05-11 中兴通讯股份有限公司 Data transmitting method, processing method, receiving method and equipment and storage medium
CN112153158A (en) * 2020-09-29 2020-12-29 中国银行股份有限公司 Information processing method and device
CN112291254A (en) * 2020-11-05 2021-01-29 中国人民银行清算总中心 Message processing method and device for reliable transaction
CN115134361A (en) * 2022-06-20 2022-09-30 中汽创智科技有限公司 Cross-platform communication method and device for automatic driving software platform

Similar Documents

Publication Publication Date Title
CN109981607B (en) Media stream processing method and device, electronic equipment and storage medium
US20210303521A1 (en) Device searching system and method for data transmission
JP6338782B2 (en) Communication message processing method and apparatus
JP2016522477A (en) Group creation method, group withdrawal method, apparatus, program, and recording medium
CN109005096B (en) Application interaction method and device
CN105100829A (en) Video content interception method and device
EP3051772B1 (en) Method and apparatus for accessing network
AU2018432003B2 (en) Video processing method and device, and terminal and storage medium
CN114422472A (en) Network address conversion method and device and electronic equipment
CN108848497A (en) Acquisition methods, device, terminal and the computer readable storage medium of list of application
US10924529B2 (en) System and method of transmitting data by using widget window
CN104219299B (en) Data transmission method and device
CN104572230A (en) Script file loading method, script file generating method and script file generating device
CN116506501A (en) Message forwarding method, device, electronic device and storage medium
CN109218275B (en) Application interaction method and device
CN110224991A (en) Depending on the networked terminals means of communication and device
CN108848116A (en) call recording method, device and storage medium
CN116033264A (en) Image processing parameter adjustment method, device and equipment
CN115086295A (en) File transmission method, file transmission device, server and storage medium
CN114417133A (en) Business data processing method and device, electronic equipment and computer storage medium
US20160373504A1 (en) Method for sharing a digital content during communication
CN109032583A (en) Data interactive method and device
CN114007101B (en) Processing method, device and storage medium of fusion display device
CN108958943A (en) Memory release method and device
CN114928597B (en) Data transmission method, device and 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