Blockchain-based SDK rapid integration method, device, equipment and storage medium
By using preset format configuration files and web3j instances, the problem of low SDK integration in the prior art is solved, rapid integration and simplified access costs are achieved, and communications of multiple alliance chains are supported.
Patent Information
- Application Number
- CN201910475206.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-05-31
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2039-12-18
Smart Images

Figure CN110209381B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain technology, and in particular to a blockchain-based SDK rapid integration method, apparatus, device, and storage medium for the financial industry. Background Art
[0002] With the development of computer technology, more and more technologies (such as distributed systems, blockchain, big data, and artificial intelligence) are being applied in the financial sector. Traditional finance is gradually shifting towards Fintech, and more and more technologies are being applied to the financial industry. Existing technologies include the Java-based web3j SDK toolkit for connecting to blockchains. It integrates relevant contract events (maintaining contracts for topics and events), internally encapsulates operations such as message upload and pull, and provides external publish and subscribe interfaces for application systems to display and call, send topic messages, and monitor messages.
[0003] However, in the existing technology, the application project must introduce the applicationContext.xml file and load the file through the Spring component to initialize the web3j environment. The software development kit SDK has low integration, resulting in high access costs for publishing and subscribing to events. Summary of the Invention
[0004] The main purpose of the present invention is to propose a blockchain-based SDK rapid integration method, device, equipment and storage medium, aiming to solve the problem of low integration in the existing technology, which leads to high access costs for publishing and subscribing to events.
[0005] To achieve the above objectives, the present invention provides a blockchain-based SDK rapid integration method, which includes the following steps:
[0006] When the business system receives the startup instruction, it obtains the configuration file in the preset format;
[0007] Based on the configuration file, create an Ethereum web3j instance, wherein the web3j instance provides a blockchain API interface;
[0008] Determine the theme configuration item corresponding to the configuration file;
[0009] If the topic configuration item is a consumer topic configuration item, initialize the consumer instance through the software development kit SDK and subscribe to the consumer topic event on the alliance chain node;
[0010] If the topic configuration item is a producer topic configuration item, the producer instance is initialized through the SDK so that the business system calls the API interface to publish the producer topic event.
[0011] Preferably, when the business system receives the startup instruction of the software development kit SDK, before the step of obtaining the configuration file in a preset format, the blockchain-based SDK rapid integration method further includes:
[0012] The configuration file is obtained through business application based on the business scenario and the SDK configuration information.
[0013] Preferably, the step of creating an Ethereum web3j instance based on the configuration file includes:
[0014] Parsing the configuration file through the SDK to obtain the ID of the alliance chain node;
[0015] Based on the ID of the alliance chain node, a communication link is established between the SDK and the corresponding alliance chain to build the web3j instance.
[0016] Preferably, the step of subscribing to consumer topic events on the alliance chain node further includes:
[0017] The consortium chain node monitors the consumer topic event to obtain message data;
[0018] Parsing the message data to obtain a message notification;
[0019] The message notification is distributed to the business function corresponding to the consumer topic configuration item through a message distributor, so that the business function can process the message notification.
[0020] Preferably, the consumer subject event includes a first consumer event and a second consumer event; and the step of obtaining message data by monitoring the consumer subject event based on the alliance chain node includes:
[0021] The first consumer event is monitored by the alliance chain node to obtain first data, and the second consumer event is cached.
[0022] Preferably, the API interface is a message publishing interface; if the topic configuration item is a producer topic configuration item, the step of initializing a producer instance through the SDK so that the business system calls the API interface to publish a producer topic event includes:
[0023] If the topic configuration item is a producer topic configuration item, the configuration file is parsed by the SDK to obtain a topic contract;
[0024] Call the publishing message interface corresponding to the subject contract to send the producer subject event to the alliance chain node.
[0025] In addition, to achieve the above-mentioned purpose, the present invention also provides a blockchain-based SDK rapid integration device, which includes:
[0026] An acquisition module is used to acquire a configuration file in a preset format when the business system receives a startup instruction;
[0027] A construction module is used to create an Ethereum web3j instance based on the configuration file, wherein the web3j instance provides a blockchain API interface;
[0028] A determination module, configured to determine a theme configuration item corresponding to the configuration file;
[0029] A subscription module, which is used to initialize a consumer instance through the software development kit SDK and subscribe to consumer topic events on the alliance chain node if the topic configuration item is a consumer topic configuration item;
[0030] The publishing module is used to initialize the producer instance through the SDK if the topic configuration item is a producer topic configuration item, so that the business system calls the API interface to publish the producer topic event.
[0031] Preferably, the blockchain-based SDK rapid integration device further includes:
[0032] The configuration module is used to obtain a configuration file based on the business scenario and the SDK configuration information through business applications.
[0033] Preferably, the building block is further used for:
[0034] Parsing the configuration file through the SDK to obtain the ID of the alliance chain node;
[0035] Based on the ID of the alliance chain node, a communication link is established between the SDK and the corresponding alliance chain to build the web3j instance.
[0036] Preferably, the subscription module is further configured to:
[0037] The consortium chain node monitors the consumer topic event to obtain message data;
[0038] Parsing the message data to obtain a message notification;
[0039] The message notification is distributed to the business function corresponding to the consumer topic configuration item through a message distributor, so that the business function can process the message notification.
[0040] Preferably, there are multiple consumer theme events, namely, a first consumer event and a second consumer event; and the subscription module is further configured to:
[0041] The first consumer event is monitored by the alliance chain node to obtain first data, and the second consumer event is cached.
[0042] In addition, to achieve the above-mentioned purpose, the present invention also provides a blockchain-based SDK rapid integration device, which includes: a memory, a processor, and a blockchain-based SDK rapid integration program stored on the memory and runnable on the processor. When the blockchain-based SDK rapid integration program is executed by the processor, the steps of the blockchain-based SDK rapid integration method as described above are implemented.
[0043] In addition, to achieve the above-mentioned purpose, the present invention also provides a readable storage medium, on which a blockchain-based SDK quick integration program is stored. When the blockchain-based SDK quick integration program is executed by a processor, the steps of the blockchain-based SDK quick integration method as described above are implemented.
[0044] The blockchain-based SDK rapid integration method proposed in this paper effectively removes the existing application.xml file dependency through a pre-formatted configuration file, making the SDK more versatile and scalable. Furthermore, the web3j instance built based on the configuration file supports multiple consortium chains. Furthermore, after determining the topic configuration items, message publishing and / or subscription can be achieved by configuring producer and consumer roles for the same topic. Compared to the existing method that requires the business system to initialize consumer and producer instances, this method initializes consumers and producers within the SDK, effectively achieving rapid SDK integration and simplifying access costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 Schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention;
[0046] Figure 2 This is a flowchart of the first embodiment of the blockchain-based SDK rapid integration method of the present invention;
[0047] Figure 3This is a schematic diagram of blockchain node publishing and subscription events according to the first embodiment of the blockchain-based SDK rapid integration method of the present invention;
[0048] Figure 4 This is a flowchart of building a web3j instance in the first embodiment of the blockchain-based SDK rapid integration method of the present invention.
[0049] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings and in conjunction with the embodiments. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0051] like Figure 1 As shown, Figure 1 It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.
[0052] The blockchain-based SDK rapid integration device in the embodiment of the present invention can be a PC or a server device.
[0053] like Figure 1 As shown, the blockchain-based SDK rapid integration device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. The communication bus 1002 is used to enable communication between these components. The user interface 1003 may include a display and an input unit such as a keyboard. Optionally, the user interface 1003 may also include a standard wired interface or a wireless interface. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as a disk storage device. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0054] Those skilled in the art will understand that Figure 1 The device structure shown in the figure does not constitute a limitation of the device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0055] like Figure 1 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a blockchain-based SDK rapid integration program.
[0056] exist Figure 1In the device shown, the network interface 1004 is mainly used to connect to the backend server and communicate data with the backend server; the user interface 1003 is mainly used to connect to the client (user end) and communicate data with the client; and the processor 1001 can be used to call the blockchain-based SDK rapid integration program stored in the memory 1005 and perform the operations in each embodiment of the following blockchain-based SDK rapid integration method.
[0057] Based on the above hardware structure, an embodiment of the blockchain-based SDK rapid integration method of the present invention is proposed.
[0058] Reference Figure 2 , Figure 2 This is a flow chart of the first embodiment of the blockchain-based SDK rapid integration method of the present invention, which includes:
[0059] Step S10, when the business system receives the startup instruction, obtains a configuration file in a preset format;
[0060] In this embodiment, an SDK (Software Development Kit) is generally a collection of development tools used by software engineers to build application software for a specific software package, software framework, hardware platform, operating system, etc. When the business system receives a startup instruction from the SDK, it obtains a configuration file in a preset format. The startup instruction may be triggered when the business system is started. During the business system startup process, the obtained configuration file is read.
[0061] The configuration file in the preset format may include: SDK function switch, blockchain node ip:port, subject topic contract address, blockchain certificate file path, organization id, consumption topic, production topic and other one or more information. Multiple business organizations can add the orgid prefix to the key for independent configuration. For example:
[0062] aaaa.weevent.consumer.topic=*****
[0063] bbbb.weevent.consumer.topic=*****
[0064] aaa and bbb are the names of business institutions (such as banking institutions, insurance institutions and other financial institutions), which can flexibly distinguish business institutions. Figure 3 As shown, Figure 3This is a diagram of how blockchain nodes publish and subscribe to events. WeEvent provides a blockchain-based Publish / Subscribe feature set. An event is a business message and can be in character format, such as JSON or XML, or binary format, such as protocol buffers. The maximum length of events supported by WeEvent in this case is 10KB. Events with the same topic structure are logically defined as belonging to the same topic. Topics are isolated from each other during event processing and maintenance. The Event Broker is blockchain node middleware. To publish an event, a producer publishes an event to a topic through the publish interface. Successfully published events are permanently stored on the financial blockchain FISCO-BCOS. Events are never lost, cannot be tampered with, and support post-event auditing. When subscribing to an event, a consumer subscribes to listen for events on a topic and receives notifications when an event occurs. The special flag OFFSET_FIRST can be used to retrieve all events for that topic since its creation. Unsubscribe to an event cancels a subscription, preventing future event notifications.
[0065] In the existing technology, the application project must introduce the applicationContext.xml file, and load the file through the spring component to initialize the web3j environment. Currently, most Java applications are basically built based on the spring-boot framework, using property files with the suffix "properties". The configuration of application.xml will fix the specific content instance, and the application.xml method cannot implement multiple consortium chains.
[0066] Business applications in this solution configure relevant information based on their specific business scenarios, including: blockchain node information, access certificates, topic names, and the declaration of the business interface functions corresponding to the topics. When expanding business systems, simply adding configuration items allows for flexible content instance configuration, making the SDK highly versatile and scalable.
[0067] Step S20: creating an Ethereum web3j instance based on the configuration file, wherein the web3j instance provides a blockchain API interface;
[0068] In this step, based on the configuration file, an Ethereum web3j instance is built using the SDK to communicate with the consortium chain node. Each business organization corresponds to a web3j instance, and the SDK initializes the web3j instance based on the consortium chain node. The web3j instance provides a blockchain API interface. Furthermore, communication between the SDK and the consortium chain node is maintained by establishing a persistent link between the business application and the blockchain node, which initiates a heartbeat thread and automatically reconnects if the link fails.
[0069] like Figure 4 As shown, Figure 4 It is a flowchart of building a web3j instance. During the system startup process, the configuration file is obtained and the web3j environment for each business organization to connect to the blockchain node is dynamically generated. Specifically, based on the configuration file, an Ethereum web3j instance is created to obtain the web3j environment; the consumer instance consumer is initialized according to the topic configuration, and the producer instance producer is initialized; and, through the web3j environment, the alliance chain of each organization is established to obtain a web3j instance. For example, communication with the alliance chain of organization A, communication with the alliance chain of organization B, and communication with the alliance chain of organization C are established respectively to obtain a web3j instance.
[0070] The web3j instance provides the blockchain API calling interface. The producer instance and consumer instance both rely on the web3j instance API calling interface. Through the producer instance and consumer instance, a series of logical operations are integrated to realize a subscription and publishing mode.
[0071] Based on the configuration file, an Ethereum web3j instance that communicates with the consortium chain node is built through the SDK. This can realize multiple consortium chains, such as the consortium chain with institution A, the consortium chain with institution B, and the consortium chain with institution C, effectively circumventing the problem that the existing technology application.xml method cannot support multiple consortium chains.
[0072] Step S30, determining the theme configuration item corresponding to the configuration file;
[0073] In this step, the theme configuration items of the configuration file are determined, specifically by: parsing the configuration file through the SDK, and determining the theme configuration items according to the configuration items predetermined in the configuration file.
[0074] It should be noted that when the SDK parses the configuration file, it obtains not only the theme name of the theme configuration item, but also the ID, IP port and communication certificate of the alliance chain.
[0075] For example: the configuration file has configuration items:
[0076] {orgid}.weevent.consumer.topic={topicname}
[0077] {orgid}.weevent.producer.topic={topicname}.
[0078] Then, from the above configuration items, we know that the topic configuration item {orgid}.weevent.consumer.topic is a consumer configuration item, which means that the configuration file is configured with a consumer topic configuration item, and the corresponding consumer instance can subscribe to events; the topic configuration item {orgid}.weevent.producer.topic is a producer configuration item, which means that the configuration file is configured with a producer topic configuration item, and the corresponding producer instance can publish events.
[0079] By parsing the configuration file, the value corresponding to the specific business configuration item is obtained, thereby determining whether it is a consumer topic configuration item or a producer topic configuration item.
[0080] Step S40: If the topic configuration item is a consumer topic configuration item, initialize the consumer instance through the software development kit SDK and subscribe to the consumer topic event on the alliance chain node.
[0081] In this step, initializing the consumer instance through the software development kit SDK is equivalent to initializing the consumer instance through the software development kit SDK alliance chain node. Subscribing to the consumer topic event on the alliance chain node is specifically as follows: based on the alliance chain node, the consumer topic event is monitored to obtain message data; the message data is parsed to obtain a message notification; and the message notification is distributed to the business function corresponding to the consumer topic configuration item through the message distributor, so that the business function can process the message notification. After defining a topic event topic, there is a process in which a scheduled task pulls block high data for parsing and distributes it to the business function declared by the topic for processing.
[0082] Specifically: The SDK periodically obtains the current blockchain block height as blockHeight, the block height of the data pulled by the SDK is lastBlock, and the block height currently to be pulled is currentBlockNum = lastBlocNum + 1. When currentBlockNum <= blockHeight, the SDK obtains the data of the currentBlockNum block on the chain, parses the data content, and distributes notifications based on the topic to which the data content belongs.
[0083] Since the consumer instance is initialized through the SDK, compared with the existing technology that requires the business system to initialize the consumer instance, it effectively realizes the rapid integration of the SDK.
[0084] Step S50: If the topic configuration item is a producer topic configuration item, the producer instance is initialized through the SDK so that the business system calls the API interface to publish the producer topic event.
[0085] In this step, initializing the producer instance through the SDK is equivalent to initializing the producer instance through the SDK alliance chain node. Publishing the producer topic event is specifically: the SDK calls the publish message interface publish WeEvent defined by the topic contract, and sends the message to the chain. It is the business system that actively calls the release.
[0086] Since the producer instance is also initialized through the SDK, compared with the existing technology that requires the business system to initialize the producer instance, it effectively realizes the rapid integration of the SDK.
[0087] The blockchain-based SDK rapid integration method proposed in this paper effectively removes the existing application.xml file dependency through a pre-formatted configuration file, making the SDK more versatile and scalable. Furthermore, the web3j instance built based on the configuration file supports multiple consortium chains. Furthermore, after determining the topic configuration items, message publishing and / or subscription can be achieved by configuring producer and consumer roles for the same topic. Compared to the existing method that requires the business system to initialize consumer and producer instances, this method initializes consumers and producers within the SDK, effectively enabling rapid SDK integration and simplifying access costs.
[0088] Furthermore, before step S10, the blockchain-based SDK rapid integration method may further include:
[0089] The configuration file is obtained through business application based on the business scenario and the SDK configuration information.
[0090] In this embodiment, the business system fills in the corresponding configuration values according to the configuration items defined by the SDK, and the SDK directly reads the local file to obtain them.
[0091] In existing technologies, the applicationContext.xml file is the base configuration file loaded by the Spring component, declaring and configuring various context instances. This model forces the business system to rely on the Spring suite and creates a fixed instance structure, making it difficult to upgrade and expand.
[0092] In this case, the business system configures scenario information based on the business scenario and SDK. For business scenarios such as consumers and producers, the corresponding configuration values are filled in according to the configuration items defined by the SDK to obtain a configuration file in a preset format. The preset configuration file may include: SDK function switch, blockchain node ip:port, subject topic contract address, blockchain certificate file path, organization id, consumption topic, production topic and other information. Multiple business organizations are independently configured by adding the orgid prefix to the key. In particular, the configuration file stored in the Key=value format allows the SDK to dynamically generate various context instances. For the application system, it only needs to configure according to the provided configuration items. The SDK will control the initialization of the context instance internally. In addition, the Key=value configuration file is a more common configuration mode for various program applications.
[0093] By storing configuration files in the format of Key=value, when expanding the business system, you only need to add configuration items to flexibly configure content instances, making the SDK versatile and scalable.
[0094] Furthermore, step S20 may include:
[0095] Parsing the configuration file through the SDK to obtain the ID of the alliance chain node;
[0096] Based on the ID of the alliance chain node, a communication link is established between the SDK and the corresponding alliance chain to build the web3j instance.
[0097] In this embodiment, the SDK parses the configuration file to obtain the ID of the consortium chain node and establishes a communication link between the SDK and the corresponding consortium chain, thereby building a web3j instance. Communication is maintained by creating a persistent link between the business application and the blockchain node, which initiates a heartbeat thread and automatically reconnects if the link fails.
[0098] For example: the configuration file has configuration items:
[0099] {orgid}.weevent.consumer.topic={topicname}
[0100] {orgid}.weevent.producer.topic={topicname}.
[0101] Then, after parsing, the topic configuration item {orgid}.weevent.consumer.topic is the consumer configuration item, which determines that the consumer topic configuration item is configured in the configuration file, and corresponds to the consumer instance, and can subscribe to events; the topic configuration item {orgid}.weevent.producer.topic is the producer configuration item, which determines that the producer topic configuration item is configured in the configuration file, and corresponds to the producer instance, and can publish events.
[0102] When there are multiple IDs of the alliance chain node, multiple alliance chains can communicate with the SDK to obtain multiple web3j instances. In addition, one web3j instance corresponds to one business organization, effectively supporting multi-chain scenarios.
[0103] By parsing the configuration file and judging the subject configuration items therein, specific business configuration items are obtained, and message communication is carried out for the specific business configuration items.
[0104] Furthermore, based on the first embodiment of the blockchain-based SDK rapid integration method of the present invention, a second embodiment of the blockchain-based SDK rapid integration method of the present invention is proposed; step S50 may include: monitoring the consumer subject event based on the alliance chain node to obtain message data;
[0105] Parsing the message data to obtain a message notification;
[0106] The message notification is distributed to the business function corresponding to the consumer topic configuration item through a message distributor, so that the business function can process the message notification.
[0107] In this embodiment, subscribing to a consumer topic event on a consortium chain node involves: monitoring the consortium chain node for the consumer topic event to obtain message data; parsing the message data to obtain a message notification; and distributing the message notification to the business function corresponding to the consumer topic configuration item via a message distributor, for processing by the business function. After defining a topic event topic, a scheduled task pulls block data, parses it, and distributes it to the business function declared by the topic for processing.
[0108] Specifically: The SDK periodically obtains the current blockchain block height as blockHeight, the block height of the data pulled by the SDK is lastBlock, and the block height currently to be pulled is currentBlockNum = lastBlocNum + 1. When currentBlockNum <= blockHeight, the SDK obtains the data of the currentBlockNum block on the chain, parses the data content, and distributes notifications based on the topic to which the data content belongs.
[0109] In the existing technology, a subsystem subscribes to the same topic message under multiple application instances. When there is topic information, each instance will pull the message, causing the business system to process the message repeatedly, and the business system needs to solve the deduplication processing on its own.
[0110] In the present invention, business applications only need to focus on and implement the business interface declared by the corresponding topic. Other common processes such as message deduplication and message flag storage are handled uniformly by the message distributor.
[0111] Messages subscribed to a topic are uniformly sent to the message distributor, which deduplicates the messages through the redis middleware, which is implemented by the default redis method. The accessor only needs to inject his own redis component into the distributor. Custom implementation methods are also supported and can be declared in the provided interface base class (interface IEventHelp) to ensure that only one organization instance can execute the topic message. The distributor assigns the message to the business function declared for the corresponding topic based on the business organization ID and topic name to which the message belongs. Finally, the distributor asynchronously records the consumed messages.
[0112] Furthermore, there are multiple consumer theme events, namely, a first consumer event and a second consumer event; step S40 may further include:
[0113] The first consumer event is monitored by the alliance chain node to obtain first data, and the second consumer event is cached.
[0114] In this embodiment, when there are multiple consumer topic events, such as the first consumer event, the second consumer event, etc., when monitoring the consumer topic events, the first consumer event will be monitored first, and the second consumer event and events other than the first consumer event will be cached. When there is a message in the memory, the second consumer event will be processed synchronously.
[0115] For example, in three scenarios, topicA, topicB, and topicC, the execution order is: topicA first requests to pull the block data from the chain and caches the messages of other topicsB and C. TopicB and topicC wait for topicA to be processed and then directly retrieve the messages from memory and return them.
[0116] The existing technology handles this as follows: when a business application is configured with multiple consumer topics, each block and each topic will request the chain to pull the block data once, parse the data, and then return its own topic message, resulting in low efficiency.
[0117] This case caches the second consumer events to avoid the problem of requesting all the data of a block on the chain for each topic pulling messages, thereby achieving efficiency optimization and realizing message pulling processing in multiple topic scenarios.
[0118] Furthermore, the API interface is a message publishing interface; step S50 includes:
[0119] Parse the configuration file through the SDK to obtain the subject contract;
[0120] Call the message publishing interface corresponding to the subject contract to send the producer subject event to the alliance chain node.
[0121] In this embodiment, publishing producer topic events is specifically as follows: the SDK calls the publishWeEvent message publishing interface defined by the topic contract and sends the message to the chain. The business system actively calls the publication. When the topic event is successfully published, the topic event is permanently stored on the FISCO-BCOS blockchain. The topic event will never be lost, cannot be tampered with, and supports post-audit.
[0122] Since the producer instance is also initialized through the SDK, compared with the existing technology that requires the business system to initialize the producer instance, the rapid integration of the SDK is effectively achieved. In addition, when publishing events, the rapid integration of the SDK simplifies the interface calling method.
[0123] The present invention also provides a blockchain-based SDK rapid integration device. The blockchain-based SDK rapid integration device of the present invention includes:
[0124] An acquisition module, used to acquire a configuration file in a preset format when the business system receives a startup instruction;
[0125] A construction module is used to create an Ethereum web3j instance based on the configuration file, wherein the web3j instance provides a blockchain API interface;
[0126] A determination module, configured to determine a theme configuration item corresponding to the configuration file;
[0127] A subscription module, which is used to initialize a consumer instance through the software development kit SDK and subscribe to consumer topic events on the alliance chain node if the topic configuration item is a consumer topic configuration item;
[0128] The publishing module is used to initialize the producer instance through the SDK if the topic configuration item is a producer topic configuration item, so that the business system calls the API interface to publish the producer topic event.
[0129] Furthermore, the blockchain-based SDK rapid integration device also includes:
[0130] The configuration module is used to obtain a configuration file based on the business scenario and the SDK configuration information through business applications.
[0131] Furthermore, the building block is also used to:
[0132] Parsing the configuration file through the SDK to obtain the ID of the alliance chain node;
[0133] Based on the ID of the alliance chain node, a communication link is established between the SDK and the corresponding alliance chain to build the web3j instance.
[0134] Furthermore, the subscription module is also used to:
[0135] The consortium chain node monitors the consumer topic event to obtain message data;
[0136] Parsing the message data to obtain a message notification;
[0137] The message notification is distributed to the business function corresponding to the consumer topic configuration item through a message distributor, so that the business function can process the message notification.
[0138] Furthermore, there are multiple consumer theme events, namely, a first consumer event and a second consumer event; and the subscription module is further configured to:
[0139] The first consumer event is monitored by the alliance chain node to obtain first data, and the second consumer event is cached.
[0140] The present invention also provides a computer-readable storage medium.
[0141] The computer-readable storage medium of the present invention stores a blockchain-based SDK rapid integration program, which, when executed by a processor, implements the steps of the blockchain-based SDK rapid integration method described above.
[0142] Among them, the method implemented when the blockchain-based SDK rapid integration program running on the processor is executed can refer to the various embodiments of the blockchain-based SDK rapid integration method of the present invention, and will not be repeated here.
[0143] It should be noted that, in this document, the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, article, or system comprising a series of elements includes not only those elements but also other elements not explicitly listed, or elements inherent to such process, method, article, or system. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or system comprising the element.
[0144] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0145] Through the description of the above embodiments, those skilled in the art can clearly understand that the above embodiment methods can be implemented by means of software plus the necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product. The computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions for enabling a blockchain-based SDK rapid integration device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0146] The above are only preferred embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention description and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A blockchain-based SDK rapid integration method, characterized in that: The blockchain-based SDK rapid integration method includes the following steps: When the business system receives the startup command, it obtains a configuration file in a preset format. The configuration file in the preset format includes the organization ID. Multiple business organizations are independently configured by adding the organization ID prefix to the key. The configuration file in the preset format is obtained by the business system by filling in the corresponding configuration values according to the configuration items defined by the SDK; Based on the configuration file, an Ethereum web3j instance corresponding to each institution is created through the SDK, wherein the web3j instance provides a blockchain API interface; the SDK is used to dynamically generate various context instances based on the configuration file; Determine the theme configuration item corresponding to the configuration file; If the topic configuration item is a consumer topic configuration item, initialize the consumer instance through the software development kit SDK and subscribe to the consumer topic event on the alliance chain node; If the topic configuration item is a producer topic configuration item, the producer instance is initialized through the SDK so that the business system calls the API interface to publish the producer topic event.
2. The blockchain-based SDK rapid integration method according to claim 1, characterized in that: When the business system receives the startup instruction of the software development kit SDK, before the step of obtaining the configuration file in a preset format, the blockchain-based SDK rapid integration method further includes: The configuration file is obtained through business application based on the business scenario and the SDK configuration information.
3. The blockchain-based SDK rapid integration method according to claim 1, characterized in that: The steps of creating Ethereum web3j instances corresponding to various organizations through the SDK based on the configuration file include: Parsing the configuration file through the SDK to obtain the ID of the alliance chain node; Based on the ID of the alliance chain node, a communication link is established between the SDK and the corresponding alliance chain to build the web3j instance.
4. The blockchain-based SDK rapid integration method according to claim 1, wherein: The step of subscribing to the consumer topic event on the alliance chain node also includes: The consortium chain node monitors the consumer topic event to obtain message data; Parsing the message data to obtain a message notification; The message notification is distributed to the business function corresponding to the consumer topic configuration item through a message distributor, so that the business function can process the message notification.
5. The blockchain-based SDK rapid integration method according to claim 4, characterized in that: The consumer subject event includes a first consumer event and a second consumer event; The step of obtaining message data by monitoring the consumer topic event based on the alliance chain node includes: The first consumer event is monitored by the alliance chain node to obtain first data, and the second consumer event is cached.
6. The blockchain-based SDK rapid integration method according to any one of claims 1 to 5, characterized in that: The API interface is a message publishing interface; if the topic configuration item is a producer topic configuration item, the steps of initializing a producer instance through the SDK so that the business system calls the API interface to publish a producer topic event include: If the topic configuration item is a producer topic configuration item, the configuration file is parsed by the SDK to obtain a topic contract; Call the message publishing interface corresponding to the subject contract to send the producer subject event to the alliance chain node.
7. A blockchain-based SDK rapid integration device, characterized in that: The blockchain-based SDK rapid integration device includes: An acquisition module, configured to acquire a configuration file in a preset format when the business system receives a startup instruction. The configuration file in the preset format includes an organization ID. Multiple business organizations are independently configured by adding an organization ID prefix to the key. The configuration file in the preset format is obtained by the business system by filling in the corresponding configuration values according to the configuration items defined in the SDK; A construction module is used to create an Ethereum web3j instance corresponding to each institution through the SDK based on the configuration file, wherein the web3j instance provides a blockchain API interface; the SDK is used to dynamically generate various context instances based on the configuration file; A determination module, configured to determine a theme configuration item corresponding to the configuration file; A subscription module, which is used to initialize a consumer instance through the software development kit SDK and subscribe to consumer topic events on the alliance chain node if the topic configuration item is a consumer topic configuration item; The publishing module is used to initialize the producer instance through the SDK if the topic configuration item is a producer topic configuration item, so that the business system calls the API interface to publish the producer topic event.
8. The blockchain-based SDK rapid integration device according to claim 7, characterized in that: The blockchain-based SDK rapid integration device also includes: The configuration module is used to obtain a configuration file based on the business scenario and the SDK configuration information through business applications.
9. The blockchain-based SDK rapid integration device according to claim 7, characterized in that: The building blocks are also used to: Parsing the configuration file through the SDK to obtain the ID of the alliance chain node; Based on the ID of the alliance chain node, a communication link is established between the SDK and the corresponding alliance chain to build the web3j instance.
10. The blockchain-based SDK rapid integration device according to any one of claims 7 to 9, characterized in that: The subscription module is also used to: The consortium chain node monitors the consumer topic event to obtain message data; Parsing the message data to obtain a message notification; The message notification is distributed to the business function corresponding to the consumer topic configuration item through a message distributor, so that the business function can process the message notification.
11. The blockchain-based SDK rapid integration device according to claim 10, characterized in that: There are multiple consumer subject events, namely, first consumer events and second consumer events; the subscription module is further used to: The first consumer event is monitored by the alliance chain node to obtain first data, and the second consumer event is cached.
12. A blockchain-based SDK rapid integration device, characterized in that: The blockchain-based SDK rapid integration device includes: a memory, a processor, and a blockchain-based SDK rapid integration program stored in the memory and executable on the processor. When the blockchain-based SDK rapid integration program is executed by the processor, the steps of the blockchain-based SDK rapid integration method according to any one of claims 1 to 6 are implemented.
13. A storage medium, characterized in that: The storage medium stores a blockchain-based SDK rapid integration program, which, when executed by a processor, implements the steps of the blockchain-based SDK rapid integration method according to any one of claims 1 to 6.
Citation Information
Patent Citations
A distributed message protection method and a protection device based on a block chain
CN109067810A