CN117424809A - Information sending method and device based on multiple instances and storage medium - Google Patents

Information sending method and device based on multiple instances and storage medium Download PDF

Info

Publication number
CN117424809A
CN117424809A CN202311498053.6A CN202311498053A CN117424809A CN 117424809 A CN117424809 A CN 117424809A CN 202311498053 A CN202311498053 A CN 202311498053A CN 117424809 A CN117424809 A CN 117424809A
Authority
CN
China
Prior art keywords
instance
kafka
interface
production
information
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
CN202311498053.6A
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.)
China United Network Communications Group Co Ltd
Original Assignee
China United Network Communications Group Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China United Network Communications Group Co Ltd filed Critical China United Network Communications Group Co Ltd
Priority to CN202311498053.6A priority Critical patent/CN117424809A/en
Publication of CN117424809A publication Critical patent/CN117424809A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/08Configuration management of networks or network elements
    • H04L41/0803Configuration setting
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L41/00Arrangements for maintenance, administration or management of data switching networks, e.g. of packet switching networks
    • H04L41/06Management of faults, events, alarms or notifications
    • H04L41/0654Management of faults, events, alarms or notifications using network fault recovery
    • H04L41/0663Performing the actions predefined by failover planning, e.g. switching to standby network elements
    • 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
    • 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/60Scheduling or organising the servicing of application requests, e.g. requests for application data transmissions using the analysis and optimisation of the required network resources

Landscapes

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

Abstract

The application provides an information sending method, device and storage medium based on multiple instances, relates to the technical field of message processing, and can solve the problem that a current production server only comprises one kafkaTemplate instance and is low in reliability. The method comprises the following steps: determining a target kafka interface instance in the plurality of interface instances according to attribute information of the plurality of kafka interface instances, wherein the attribute information of the kafka interface instance comprises identification of the interface instance and a corresponding storage server; establishing a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance; the production information is sent to a target storage server corresponding to the target kafka interface instance based on the communication link. The method and the device can improve the reliability of information sending of the production server.

Description

Information sending method and device based on multiple instances and storage medium
Technical Field
The present disclosure relates to the field of message processing technologies, and in particular, to a method and an apparatus for sending information based on multiple instances, and a storage medium.
Background
The kafkaTemplate instance is an API provided by spring for apache kafka that sends messages to the kafka cluster. The kafkaTemplate instance may configure the specified keys and values. The production server asynchronously sends a single message or a batch of messages to the servers in the kafka cluster using the keys and values specified in the kafkaTemplate instance, without regard to the complex setup of the production server.
Under the default configuration, the production server contains only one kafkaTemplate instance. The production server may send information to servers in the kafka cluster through the kafkaTemplate instance.
If one kafkaTemplate instance in the production server fails, the production server cannot send information to the servers in the kafka cluster, and there is a problem of low reliability.
Disclosure of Invention
The application provides a multi-instance-based information sending method, device and storage medium, which solve the problem that the current production server only comprises one kafkaTemplate instance and has low reliability, and can improve the reliability of information sending of the production server.
In order to achieve the above purpose, the present application adopts the following technical scheme:
in a first aspect, the present application provides a multi-instance based information transmission method applied to a production server, the production server configured with a plurality of kafka interface instances, the plurality of kafka interface instances being independent of each other, the method comprising: determining a target kafka interface instance in the plurality of kafka interface instances according to attribute information of the plurality of kafka interface instances, wherein the attribute information of the kafka interface instance comprises identification of the interface instance and a corresponding storage server; establishing a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance; the production information is sent to a target storage server corresponding to the target kafka interface instance based on the communication link.
With reference to the first aspect, in one possible implementation manner, the method further includes: acquiring address information of a target storage server and an authentication mode of the target storage server through a target kafka interface instance, a kafka template instance, a production factory instance and a production configuration instance; transmitting authentication information to a target storage server based on address information of the target storage server and an authentication mode of the target storage server; after passing the authentication of the target storage server, a communication link between the target kafka interface instance and the target storage server is established.
With reference to the first aspect, in one possible implementation manner, the method further includes: performing a first operation for each of the plurality of kafka interface instances to cause each of the kafka interface instances to complete the configuration; the first operation includes: creating a kafka interface instance; a kafka interface instance for configuring the kafka template instance, the production factory instance, and the production configuration instance; adding configuration information of a storage server in the kafka interface instance; the configuration information comprises address information, a message serialization mode and an authentication mode; configuring a production configuration instance, a production factory instance, and a kafka template instance based on the configuration information; in the case where the kafka template instance completes the configuration, the kafka interface instance configuration is completed.
With reference to the first aspect, in one possible implementation manner, the method further includes: creating a production configuration instance based on the configuration information; based on the configuration information in the production configuration instance, completing the creation of the production factory instance; based on the production plant instance, a kafka template instance is created.
In a second aspect, the present application provides a multi-instance based information transmission apparatus, the apparatus comprising: a communication unit and a processing unit; a processing unit, configured to determine a target kafka interface instance in the multiple kafka interface instances according to attribute information of the multiple kafka interface instances, where the attribute information of the kafka interface instance includes an identifier of the interface instance and a corresponding storage server; a processing unit, configured to establish a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance; and a communication unit for transmitting the production information to the target storage server corresponding to the target kafka interface instance based on the communication link.
With reference to the second aspect, in one possible implementation manner, the processing unit is specifically configured to: acquiring address information of a target storage server and an authentication mode of the target storage server through a target kafka interface instance, a kafka template instance, a production factory instance and a production configuration instance; transmitting authentication information to a target storage server based on address information of the target storage server and an authentication mode of the target storage server; after passing the authentication of the target storage server, a communication link between the target kafka interface instance and the target storage server is established.
With reference to the second aspect, in a possible implementation manner, the processing unit is further configured to: performing a first operation for each of the plurality of kafka interface instances to cause each of the kafka interface instances to complete the configuration; the first operation includes: creating a kafka interface instance; the kafka interface instance is used for configuring a kafka template instance, a production factory instance and a production configuration instance; adding configuration information of a storage server in the kafka interface instance; the configuration information comprises address information, a message serialization mode and an authentication mode; configuring a production configuration instance, a production factory instance, and a kafka template instance based on the configuration information; in the case where the kafka template instance completes the configuration, the kafka interface instance configuration is completed.
With reference to the second aspect, in one possible implementation manner, the processing unit is specifically configured to: creating a production configuration instance based on the configuration information; based on the configuration information in the production configuration instance, completing the creation of the production factory instance; based on the production plant instance, a kafka template instance is created.
In a third aspect, the present application provides a multi-instance based information transmission apparatus, the apparatus including: a processor and a communication interface; the communication interface is coupled to a processor for running a computer program or instructions to implement the multi-instance based information transmission method as described in any one of the possible implementations of the first aspect and the first aspect.
In a fourth aspect, the present application provides a computer readable storage medium having instructions stored therein which, when run on a terminal, cause the terminal to perform a multi-instance based information transmission method as described in any one of the possible implementations of the first aspect and the first aspect.
In a fifth aspect, the present application provides a computer program product comprising instructions which, when run on a multi-instance based information sending apparatus, cause the multi-instance based information sending apparatus to perform a multi-instance based information sending method as described in any one of the possible implementations of the first aspect and the first aspect.
In a sixth aspect, the present application provides a chip comprising a processor and a communication interface, the communication interface and the processor being coupled, the processor being for running a computer program or instructions to implement the multi-instance based information transmission method as described in any one of the possible implementations of the first aspect and the first aspect.
In particular, the chip provided in the present application further includes a memory for storing a computer program or instructions.
It should be noted that the above-mentioned computer instructions may be stored in whole or in part on a computer-readable storage medium. The computer readable storage medium may be packaged together with the processor of the apparatus or may be packaged separately from the processor of the apparatus, which is not limited in this application.
In a seventh aspect, the present application provides a multi-instance based information transmission system, including: a production server and a storage server, wherein the production server is adapted to perform the multi-instance based information transmission method as described in any one of the possible implementations of the first aspect and the first aspect.
For descriptions of the second aspect through the seventh aspect in the present application, reference may be made to the detailed description of the first aspect; also, the advantageous effects described in the second aspect to the seventh aspect may refer to the advantageous effect analysis of the first aspect, and are not described herein.
In the present application, the names of the above-described multi-instance-based information transmitting apparatuses do not constitute limitations on the devices or function modules themselves, and in actual implementations, these devices or function modules may appear under other names. Insofar as the function of each device or function module is similar to the present application, it is within the scope of the claims of the present application and the equivalents thereof.
These and other aspects of the present application will be more readily apparent from the following description.
The scheme at least brings the following beneficial effects: based on the above technical solution, according to the multi-instance based information sending method provided by the present application, a production server determines a target interface instance of a plurality of interface instances according to attribute information of the plurality of kafka interface instances, establishes a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance, and then, the production server may send production information to the target storage server corresponding to the target kafka interface instance based on the communication link. Since the production server is configured with a plurality of independent Kafka interface instances, compared with the current production server which only contains one kafkaTemplate instance under the default configuration, if the kafkaTemplate instance fails, the production server cannot send information to the servers in the Kafka cluster, and the reliability is low. According to the technical scheme, when one kafka interface example in the plurality of kafka interface examples fails, production information can be sent to the corresponding production server through other kafka interface examples, and the reliability of the production server is greatly guaranteed.
Drawings
Fig. 1 is a schematic diagram of the working principle of kafka according to an embodiment of the present application;
fig. 2 is a schematic architecture diagram of a multi-instance-based information sending system according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a kafka interface example provided in an embodiment of the present application;
fig. 4 is a schematic hardware structure of an information sending device based on multiple instances according to an embodiment of the present application;
fig. 5 is a flowchart of a multi-instance based information sending method according to an embodiment of the present application;
FIG. 6 is a flowchart of another method for sending information based on multiple instances according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an information sending device based on multiple instances according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
The term "and/or" is herein merely an association relationship describing an associated object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone.
The terms "first" and "second" and the like in the description and in the drawings are used for distinguishing between different objects or for distinguishing between different processes of the same object and not for describing a particular sequential order of objects.
Furthermore, references to the terms "comprising" and "having" and any variations thereof in the description of the present application are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed but may optionally include other steps or elements not listed or inherent to such process, method, article, or apparatus.
It should be noted that, in the embodiments of the present application, words such as "exemplary" or "such as" are used to mean serving as an example, instance, or illustration. Any embodiment or design described herein as "exemplary" or "for example" should not be construed as preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "such as" is intended to present related concepts in a concrete fashion.
In the description of the present application, unless otherwise indicated, the meaning of "a plurality" means two or more.
The following explains the principle of message processing of kafka according to the embodiment of the present application, for convenience of the reader.
In one possible implementation, as shown in fig. 1, a kafka producer (producer) is used to send messages to agents (brookers) in the kafka cluster. The kafka consumer (consumer) is used to retrieve and process messages from the brooker. brooker is a message transfer station in the kafka cluster and is responsible for storing and forwarding messages, and a plurality of brookers can be configured to form a cluster. Specifically, producer sends messages to a broker in the kafka cluster, which stores messages in partitions (parts) of different topics (topics), from which a consumer can subscribe to and consume messages.
In each agent, the kafka producer's message is organized into individual topics, each of which contains one or more parts. A part is a physical concept, and a topic may have multiple parts, each part stores a part of a message, and the messages in each part do not interfere with each other. The number of parts may be configured according to the traffic demand, but the number of parts affects the performance and scalability of kafka.
The producer may send a message to a certain partition of a given topic, or may use a default partitioning policy to distribute the message evenly across all the partitions. The consumer may subscribe to one or more topics and retrieve messages from the part, and the consumption process is based on the part. Multiple consumer compositions may form a consumer group (consumer group). The consumer groups (consumer groups) can consume the messages of different parts of the same topic at the same time, so that the consumption speed is improved, and only one consumer consumes the messages of the same part in each consumer group through the setting of the consumer groups.
The kafkaTemplate instance is an API provided by spring for apache kafka that sends messages to the kafka cluster. The kafkaTemplate instance may configure the specified keys and values. The production server asynchronously sends a single message or a batch of messages to the servers in the kafka cluster using the keys and values specified in the kafkaTemplate instance, without regard to the complex setup of the production server. Also, the kafkaTemplate instance may also specify a callback function for each message, performing a specific operation after the message transmission is completed. In summary, the kafkaTemplate may send messages to the Kafka cluster in a convenient and efficient manner without having to write a large amount of code to handle the details of Kafka.
Under the default configuration, the production server contains only one kafkaTemplate instance, and the consumption server also contains only one kafkaTemplate instance. The production server may send information to servers in the kafka cluster through the kafkaTemplate instance.
If only one of the kafkaTemplate instances of the default configuration in the production server fails, the production server cannot send information to the servers in the kafka cluster, and there is a problem of low reliability.
Also, if the production server contains only one kafkaTemplate instance, a centralized write request may be caused, and this may limit the throughput of the transmitted message, especially in a high concurrency scenario, the throughput of one kafkaTemplate instance may become a bottleneck of the system.
In some usage scenarios, multiple kafkaTemplates need to be configured to send messages to different consumers. The default implementation of the usual bean using the kafkaAutoconfiguration class provided by java at this time has not met the needs, and requires the developer to achieve this by manually reconfiguring the implementation of the bean, which is complex and of low practicality.
In view of this, in the information sending method based on multiple instances, since the production server is configured with multiple Kafka interface instances independent of each other in advance, compared with the current production server in a default configuration, only one kafkaTemplate instance is included, and in the case that the kafkaTemplate instance fails, the production server cannot send information to the servers in the Kafka cluster, so that the reliability is low. According to the technical scheme, when one kafka interface example in the plurality of kafka interface examples fails, production information can be sent to the corresponding production server through other kafka interface examples, and the reliability of the production server is greatly guaranteed.
The following describes embodiments of the present application in detail with reference to the drawings.
Fig. 2 is a schematic diagram of an information sending system based on multiple instances according to an embodiment of the present application. As shown in fig. 2, the multi-instance based information transmission system includes: a production server 201 and a storage server 202.
The production server 201 and the storage server 202 are connected by a communication link. The communication link may be a wired communication link or a wireless communication link, which is not limited in this application.
In one example, the production server 201 is configured with a plurality of kafka interface instances 2011, and the plurality of kafka interface instances are independent of each other.
In a possible implementation, the production server 201 is configured to generate production information and send the production information to the target storage server 202 through the target kafka interface instance 2011. The target storage server 202 is configured to receive and store the production information.
The structure of one kafka interface instance 2011 in the production server 201 is specifically described below.
In one example, as shown in fig. 3, kafka interface instance 2011 includes a kafka template instance; the kafka template examples include production factory examples; the production factory instance includes a production configuration instance; the production configuration instance contains a plurality of pieces of configuration information.
In one possible implementation, configuration information is first added in a production configuration instance. The production factory instance completes configuration according to the configuration information in the production configuration instance. The production factory instance is used as configuration information in a kafka template instance, and after the production factory instance completes configuration, the kafka template instance completes creation of the kafka template instance based on the production factory instance and other configuration information of the completed configuration. Accordingly, when the kafka template instance completes creation, the kafka interface instance completes configuration.
When implemented in hardware, the various modules in the production server 201 may be integrated on a hardware structure of a multi-instance based information delivery device as shown in fig. 4. Specifically, as shown in fig. 4, a basic hardware structure of the information transmission apparatus based on multiple instances is introduced.
Fig. 4 is a schematic structural diagram of an information sending device based on multiple instances according to an embodiment of the present application. As shown in fig. 4, the multi-instance based information transmission apparatus includes at least one processor 401, a communication line 402, and at least one communication interface 404, and may further include a memory 403. The processor 401, the memory 403, and the communication interface 404 may be connected by a communication line 402.
The processor 401 may be a central processing unit (central processing unit, CPU), may be an integrated circuit (application specific integrated circuit, ASIC), or may be one or more integrated circuits configured to implement embodiments of the present application, such as: one or more digital signal processors (digital signal processor, DSP), or one or more field programmable gate arrays (field programmable gate array, FPGA).
Communication line 402 may include a path for communicating information between the components described above.
The communication interface 404, for communicating with other devices or communication networks, may use any transceiver-like device, such as ethernet, radio access network (radio access network, RAN), wireless local area network (wireless local area networks, WLAN), etc.
The memory 403 may be, but is not limited to, a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (random access memory, RAM) or other type of dynamic storage device that can store information and instructions, or an electrically erasable programmable read-only memory (electrically erasable programmable read-only memory, EEPROM), a compact disc (compact disc read-only memory) or other optical disc storage, optical disc storage (including compact disc, laser disc, optical disc, digital versatile disc, blu-ray disc, etc.), magnetic disk storage media or other magnetic storage devices, or any other medium that can be used to contain or store the desired program code in the form of instructions or data structures and that can be accessed by a computer.
In a possible design, the memory 403 may exist independent of the processor 401, i.e. the memory 403 may be a memory external to the processor 401, where the memory 403 may be connected to the processor 401 through a communication line 402, for storing execution instructions or application program codes, and the execution is controlled by the processor 401, to implement a multi-instance based information transmission method provided in the embodiments described below. In yet another possible design, the memory 403 may be integrated with the processor 401, i.e., the memory 403 may be an internal memory of the processor 401, e.g., the memory 403 may be a cache, and may be used to temporarily store some data and instruction information, etc.
As one possible implementation, processor 401 may include one or more CPUs, such as CPU0 and CPU1 in fig. 4. As another possible implementation, the multi-instance based information sending apparatus may include a plurality of processors, such as the processor 401 and the processor 407 in fig. 4. As yet another possible implementation, the multi-instance based information sending apparatus may further include an output device 405 and an input device 406.
It should be noted that, the embodiments of the present application may refer to or refer to each other, for example, the same or similar steps, and the method embodiment, the system embodiment and the device embodiment may refer to each other, which is not limited.
Fig. 5 is a flowchart of a multi-instance based information sending method according to an embodiment of the present application, where the method may be applied to the multi-instance based information sending system shown in fig. 2. As shown in fig. 5, the method includes the following S501-S503.
S501, the production server determines a target kafka interface instance in the plurality of kafka interface instances according to attribute information of the plurality of kafka interface instances.
Wherein, the attribute information of the kafka interface instance comprises the identification of the kafka interface instance and the corresponding storage server.
In one possible implementation, the production server annotates the kafka interface instance corresponding to the target storage server by calling a function based on the attribute information, specifying the kafka template instance corresponding to the target kafka interface.
In one example, take the example that the calling function is @ Qualifier function, the target interface instance is the kafkaConfig1 instance, and the kafka template instance corresponding to the target interface is the kafkaTemplate1 instance. The production server annotates the kafkaConfig1 instance by @ qualitier function, specifies that kafkaTemplate1 corresponding to the kafkaConfig1 instance sends production information to the corresponding target storage server, and assigns a value by constructor. For example, based on different attribute information passes
The code of kafkaTemplate1 for the kafkaConfig1 instance is shown below for the @ Qualifier function call:
@Component
public class kafkaSendUtil{
2usages
private static kafkaTemplate1<String,String>kafkaSzTemplate;
2usages
private static kafkaTemplate1<String,String>kafkaGdMecTemplate;
no usages yonghu
@Autowired
public kafkaSendUtil(@Qualifier("kafkaSzTemplate")
kafkaTemplate1<String,String>kafkaSzTemplate1,
@Qualifier("kafkaGdMecTemplate")kafkaTemplate1<String,String>
kafkaGdMecTemplate){kafkaSendUtil.kafkaSzTemplate=kafkaSzTemplate;
kafkaSendUtil.kafkaGdMecTempLate=kafkaGdMecTemplate;
}
it should be noted that, in the billing service scenario, the production server generates billing service data. In the case that the charging service data needs to be sent to the target storage server, the target interface instance in the plurality of interface instances can be determined according to the attribute information of the plurality of kafka interface instances, so that the purpose of sending the charging service data to the storage server is achieved. Further, the consumption server may extract billing service data from the target storage server.
S502, the production server establishes a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance.
In a possible implementation, the process of establishing a communication link may be implemented by the following steps 1-5.
Step 1, a production server obtains address information of a target storage server and an authentication mode of the target storage server through a target kafka interface instance, a kafka template instance, a production factory instance and a production configuration instance.
In one example, the target kafka interface instance is a kafkaConfig instance, the kafka template instance is a kafkaTemplate instance, the production factory instance is a produceFacto instance, and the production configuration instance is a produceConfig instance.
It should be noted that, the address information may be a bootstrap server field in the program code, and the authentication mode may be a sasl jaas config field in the program code.
In one possible implementation, the production server sends request information to the kafkaConfig instance requesting bootstrapping. The kafkaConfig instance, upon receiving the request information, transmits the request information to the kafkaTemplate instance in response to the request information. After receiving the request information, the kafkaTemplate sends the request information to the ProduceFactory instance in response to the request information. After receiving the request information, the producerfactor instance transmits the request information to the producrconfig instance in response to the request information. After receiving the request information, the ProducerConfig instance extracts the bootstrapping.server field and the sasl.jaas.config field configured by the ProducerConfig instance in response to the request information.
It should be noted that the kafkaTemplate instance is a core class in the Apache Kafka client library that provides a way to send messages to the Kafka topic. The kafkaTemplate instance is encapsulated in a Spring Kafka framework for simplifying interactions with Kafka. The kafkaTemplate instance allows a developer to send messages to specific topics in the kafka cluster in a simple and intuitive manner.
In one possible implementation, the ProducerConfig instance sends the extracted bootstrapping.server field and sasl.jaas.config field to the ProducerFactory instance.
The ProducerFactory instance sends a bootstrapping.server field and a sasl.jaas.config field to the kafkaTemplate instance. The kafkaTemplate instance sends a bootstrapping. Server field and a sasl. Jaas. Config field to the kafkaConfig instance. The kafkaConfig instance receives the bootstrap. Server field and the sasl. Jaas. Config field.
And 2, the production server sends authentication information to the target storage server based on the address information of the target storage server and the authentication mode of the target storage server. Accordingly, the target storage server receives the authentication information.
In one possible implementation manner, the production server determines an authentication mode of the target server based on the sasl.jaas.config field, and sends authentication information corresponding to the authentication mode to the target storage server corresponding to the bootstrapping.server field based on the bootstrapping.server field.
Optionally, the authentication mode may include any one of authentication and key agreement (authentication and key agreement, AKA) authentication, basic authentication (http basic authentication) authentication, session-cookie authentication, token (Token) verification authentication, open authorization (OAuth), and other authentication modes, which are not limited in this application.
And step 3, the target storage server performs authentication.
In one example, if the authentication information sent by the production server is the same as the authentication information preset in the target server, determining that the authentication result of the authentication is passed. If the authentication information sent by the production server is different from the authentication information preset in the target server, determining that the authentication result of the authentication is failed.
And step 4, the target storage server sends an authentication result to the production server.
And 5, after passing the authentication of the target storage server, the production server establishes a communication link between the target kafka interface instance and the target storage server.
It should be noted that, each kafkaConfig instance corresponds to a different Kafka cluster server, and when the production server is started, the initialization of the kafkaTemplate is performed, so that the network connection establishment and maintenance work with the target storage server is completed.
S503, the production server sends production information to the target storage server corresponding to the target kafka interface instance based on the communication link. Accordingly, the target storage server receives the production information.
In a possible implementation manner, the production server transmits the production information to the target storage server through an information transmission method preset in a kafkaTemplate instance of the KafkaConfig instance based on a communication link. Accordingly, the target storage server receives the production information.
The information sending method may be a send () method or sendDefault ().
Based on the above technical solution, according to the multi-instance based information sending method provided by the present application, a production server determines a target interface instance of a plurality of interface instances according to attribute information of the plurality of kafka interface instances, establishes a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance, and then, the production server may send production information to the target storage server corresponding to the target kafka interface instance based on the communication link. Since the production server is configured with a plurality of mutually independent kafka interface instances, compared with the current production server which only contains one kafkaTemplate instance under the default configuration, if the kafkaTemplate instance fails, the production server cannot send information to the servers in the kafka cluster, and the reliability is low. According to the technical scheme, when one kafka interface example in the plurality of kafka interface examples fails, production information can be sent to the corresponding production server through other kafka interface examples, and the reliability of the production server is greatly guaranteed.
As a possible embodiment of the present application, as shown in fig. 6 in conjunction with fig. 5, the process of the production server configuring each of the plurality of kafka interface instances may include the following S601-S603, before S501 described above.
S601, the production server creates a kafka interface instance.
Wherein the kafka interface instance is used for configuring the kafka template instance, the production factory instance and the production configuration instance.
In one example, the kafka interface instance may be program code. The production server completes the creation of the kafka interface instance based on the writing of the program code.
S602, the production server adds configuration information of the storage server in the kafka interface example.
The configuration information comprises address information, a message serialization mode and an authentication mode.
It should be noted that, the address information may be a bootstrap server field in the program code, the message serialization manner may be a key/value server field in the program code, and the authentication manner may be a sasl jaas config field in the program code.
S603, the production server configures a production configuration instance, a production factory instance and a kafka template instance based on the configuration information.
Wherein, in the case where the kafka template instance completes the configuration, the kafka interface instance completes the configuration.
In one example, in the configuration file of the Spring application, relevant parameters of the kafkaTemplate, such as connection information of the Kafka cluster, a serializer, etc., are set by configuration attributes.
In one possible implementation, the configuration process of the kafka interface instance may be implemented by the following steps 1-3.
And step 1, the production server creates a production configuration instance based on the configuration information.
In one example, the production configuration instance is created after adding configuration information such as address information, message serialization, and authentication.
And 2, the production server completes creating the production factory instance based on the configuration information in the production configuration instance.
In one example, a production configuration instance of a completion configuration is passed as a constructor of parameter information to a production plant instance, which thereby completes creation.
And 3, the production server creates a kafka template instance based on the production factory instance.
In one example, the production factory instance that completes the configuration is passed as parameter information to the kafka template instance, which completes the creation.
It should be noted that the production server assigns different kafka template instance names using @ bean annotations by different bean names.
Based on the above technical solution, the production server creates a kafka interface instance. The production server adds configuration information of the storage server in the kafka interface instance. The production server configures a production configuration instance, a production factory instance, and a kafka template instance based on the configuration information. In the case where the kafka template instance completes the configuration, the kafka interface instance configuration is completed. The kafka interface example can be configured and completed through the technical scheme, so that the subsequent production server can conveniently send production information to the target storage server through the kafka interface example.
The embodiment of the present application may divide the functional modules or functional units of the information sending apparatus based on multiple instances according to the above method example, for example, each functional module or functional unit may be divided corresponding to each function, or two or more functions may be integrated into one processing module. The integrated modules may be implemented in hardware, or in software functional modules or functional units. The division of the modules or units in the embodiments of the present application is merely a logic function division, and other division manners may be implemented in practice.
As shown in fig. 7, a schematic structural diagram of a multi-instance-based information sending device 70 according to an embodiment of the present application is provided, where the device includes: a communication unit 701 and a processing unit 702; a processing unit 702, configured to determine a target kafka interface instance in the multiple kafka interface instances according to attribute information of the multiple kafka interface instances, where the attribute information of the kafka interface instance includes an identifier of the interface instance and a corresponding storage server; a processing unit 702, configured to establish a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance; and a communication unit 701 for transmitting the production information to the target storage server corresponding to the target kafka interface instance based on the communication link.
The processing unit 702 is specifically configured to: acquiring address information of a target storage server and an authentication mode of the target storage server through a target kafka interface instance, a kafka template instance, a production factory instance and a production configuration instance; transmitting authentication information to a target storage server based on address information of the target storage server and an authentication mode of the target storage server; after passing the authentication of the target storage server, a communication link between the target kafka interface instance and the target storage server is established.
The processing unit 702 is further configured to: performing a first operation for each of the plurality of kafka interface instances to cause each of the kafka interface instances to complete the configuration; the first operation includes: creating a kafka interface instance; the kafka interface instance is used for configuring a kafka template instance, a production factory instance and a production configuration instance; adding configuration information of a storage server in the kafka interface instance; the configuration information comprises address information, a message serialization mode and an authentication mode; configuring a production configuration instance, a production factory instance, and a kafka template instance based on the configuration information; in the case where the kafka template instance completes the configuration, the kafka interface instance configuration is completed.
The processing unit 702 is specifically configured to: creating a production configuration instance based on the configuration information; based on the configuration information in the production configuration instance, completing the creation of the production factory instance; based on the production plant instance, a kafka template instance is created.
In a possible implementation manner, the multi-instance based information transmission apparatus 70 may further include a storage unit 703 (shown in a dashed box in fig. 7), where the storage unit 703 stores a program or an instruction, which when executed by the processing unit 702, enables the multi-instance based information transmission apparatus 70 to perform the multi-instance based information transmission method described in the above method embodiment.
From the foregoing description of the embodiments, it will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of functional modules is illustrated, and in practical application, the above-described functional allocation may be implemented by different functional modules according to needs, i.e. the internal structure of the apparatus is divided into different functional modules to implement all or part of the functions described above. The specific working processes of the above-described systems, devices and units may refer to the corresponding processes in the foregoing method embodiments, which are not described herein.
The present application provides a computer program product comprising instructions which, when run on a computer, cause the computer to perform the multi-instance based information delivery method of the method embodiments described above.
The embodiment of the application also provides a computer readable storage medium, in which instructions are stored, which when executed on a computer, cause the computer to execute the multi-instance based information sending method in the method flow shown in the method embodiment.
The computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access Memory (Random Access Memory, RAM), a Read-Only Memory (ROM), an erasable programmable Read-Only Memory (Erasable Programmable Read Only Memory, EPROM), a register, a hard disk, an optical fiber, a portable compact disc Read-Only Memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing, or any other form of computer readable storage medium known in the art. An exemplary storage medium is coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an application specific integrated circuit (Application Specific Integrated Circuit, ASIC). In the context of the present application, a computer-readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
Since the multi-instance based information transmitting apparatus, the computer readable storage medium, and the computer program product in the embodiments of the present application may be applied to the above-mentioned method, the technical effects that can be obtained by the method may also refer to the above-mentioned method embodiments, and the embodiments of the present application are not repeated herein.
In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some interface, indirect coupling or communication connection of devices or units, electrical, mechanical, or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The foregoing is merely a specific embodiment of the present application, but the protection scope of the present application is not limited thereto, and any changes or substitutions within the technical scope of the present disclosure should be covered in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.

Claims (10)

1. A multi-instance based information transmission method, characterized by being applied to a production server configured with a plurality of kafka interface instances, the plurality of kafka interface instances being independent of each other, the method comprising:
determining a target kafka interface instance in the plurality of kafka interface instances according to attribute information of the plurality of kafka interface instances, wherein the attribute information of the kafka interface instance comprises identification of the interface instance and a corresponding storage server;
establishing a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance;
And transmitting production information to a target storage server corresponding to the target kafka interface instance based on the communication link.
2. The method of claim 1, wherein the establishing a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance comprises:
acquiring address information of the target storage server and an authentication mode of the target storage server through the target kafka interface instance, the kafka template instance, the production factory instance and the production configuration instance;
transmitting authentication information to the target storage server based on the address information of the target storage server and the authentication mode of the target storage server;
after passing the authentication of the target storage server, a communication link between the target kafka interface instance and the target storage server is established.
3. The method according to claim 2, wherein the method further comprises:
performing a first operation for each of the plurality of kafka interface instances to cause the each kafka interface instance to complete configuration;
The first operation includes:
creating the kafka interface instance; the kafka interface instance is used for configuring the kafka template instance, the production factory instance and the production configuration instance;
adding configuration information of the storage server in the kafka interface instance; the configuration information comprises address information, a message serialization mode and an authentication mode;
configuring the production configuration instance, the production factory instance, and the kafka template instance based on the configuration information;
in the case where the kafka template instance completes the configuration, the kafka interface instance configuration is completed.
4. The method of claim 3, wherein configuring the production configuration instance, the production plant instance, and the kafka template instance based on the configuration information comprises:
creating the production configuration instance based on the configuration information;
completing creation of the production factory instance based on configuration information in the production configuration instance;
the kafka template instance is created based on the production plant instance.
5. An apparatus for transmitting information based on multiple instances, wherein the apparatus comprises a communication unit and a processing unit;
The processing unit is used for determining a target kafka interface instance in the plurality of kafka interface instances according to the attribute information of the plurality of kafka interface instances, wherein the attribute information of the kafka interface instance comprises an identifier of the interface instance and a corresponding storage server;
the processing unit is further configured to establish a communication link between the target kafka interface instance and a target storage server corresponding to the target kafka interface instance;
the communication unit is used for sending production information to a target storage server corresponding to the target kafka interface instance based on the communication link.
6. The apparatus according to claim 5, wherein the processing unit is specifically configured to:
acquiring address information of the target storage server and an authentication mode of the target storage server through the target kafka interface instance, the kafka template instance, the production factory instance and the production configuration instance;
transmitting authentication information to the target storage server based on the address information of the target storage server and the authentication mode of the target storage server;
after passing the authentication of the target storage server, a communication link between the target kafka interface instance and the target storage server is established.
7. The apparatus of claim 6, wherein the processing unit is further configured to:
performing a first operation for each of the plurality of kafka interface instances to cause the each kafka interface instance to complete configuration;
the first operation includes:
creating the kafka interface instance; the kafka interface instance is used for configuring the kafka template instance, the production factory instance and the production configuration instance;
adding configuration information of the storage server in the kafka interface instance; the configuration information comprises address information, a message serialization mode and an authentication mode;
configuring the production configuration instance, the production factory instance, and the kafka template instance based on the configuration information;
in the case where the kafka template instance completes the configuration, the kafka interface instance configuration is completed.
8. The apparatus according to claim 7, wherein the processing unit is specifically configured to:
creating the production configuration instance based on the configuration information;
completing creation of the production factory instance based on configuration information in the production configuration instance;
the kafka template instance is created based on the production plant instance.
9. A multi-instance based information transmission apparatus, comprising: a processor and a communication interface; the communication interface is coupled to the processor for executing a computer program or instructions to implement the multi-instance based information delivery method of any of claims 1-4.
10. A computer-readable storage medium having instructions stored therein, which when executed by a computer, perform the multi-instance based information transmission method of any one of claims 1-4.
CN202311498053.6A 2023-11-10 2023-11-10 Information sending method and device based on multiple instances and storage medium Pending CN117424809A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311498053.6A CN117424809A (en) 2023-11-10 2023-11-10 Information sending method and device based on multiple instances and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311498053.6A CN117424809A (en) 2023-11-10 2023-11-10 Information sending method and device based on multiple instances and storage medium

Publications (1)

Publication Number Publication Date
CN117424809A true CN117424809A (en) 2024-01-19

Family

ID=89522772

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311498053.6A Pending CN117424809A (en) 2023-11-10 2023-11-10 Information sending method and device based on multiple instances and storage medium

Country Status (1)

Country Link
CN (1) CN117424809A (en)

Similar Documents

Publication Publication Date Title
CN109845303B (en) Management method and management unit for network slices
US11895577B2 (en) Network slice selection method and apparatus
WO2021109735A1 (en) Cross-chain-network-based resource processing method, and device
WO2018006381A1 (en) Network resource management method, apparatus and system
CN110740057B (en) Service deployment method and block chain platform
CN108401037A (en) User terminal and the binding method of equipment, device and system
CN112804675B (en) Wireless communication core network and method for analyzing movement of user equipment therein
CN109067732A (en) Internet of things equipment and data insertion system, method and computer readable storage medium
CN107133231B (en) Data acquisition method and device
CN114710571B (en) Data packet processing system
CN110839007B (en) Cloud network security processing method and device and computer storage medium
CN110062396B (en) Method and device for configuring base station
CN116800616B (en) Management method and related device of virtualized network equipment
US11290575B2 (en) Connecting computer processing systems and transmitting data
US11595471B1 (en) Method and system for electing a master in a cloud based distributed system using a serverless framework
CN109561048B (en) Communication management method and device
CN113905094B (en) Industrial Internet integration method, device and system
CN117424809A (en) Information sending method and device based on multiple instances and storage medium
CN111756836A (en) Information sending method and device based on event management model
CN112751893A (en) Message track data processing method and device and electronic equipment
CN115987513B (en) Distributed database fragment encryption and decryption methods, devices, equipment and media
CN115297066B (en) Resource dynamic cooperation method, device, server and medium
US11947971B2 (en) Remote resource configuration mechanism
WO2024034057A1 (en) Network management device, network management method, and program
CN108694571A (en) A kind of method for processing business and device based on multi-process

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