• 周日. 11月 27th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

Matrix architecture practice of Boshi fund’s Internet open platform based on rocketmq

[db:作者]

1月 6, 2022

brief introduction : Matrix After more than a year of construction , At present, it has multi-channel unified access 、 Third party ecological Interconnection 、 Fund characteristic trading scene encapsulation and other functional features .Matrix By building quality 、 Accompanied by temperature , In terms of technology and experience , Let users understand the risks , Understanding investment , And continue to create value for customers .

image.png

author | Wu Zhenhe Architect of Internet Finance Department of Boshi fund 、 Zeng Zhi Development director of Internet Finance Department of Boshi fund

With the remarkable performance in the past two years , The public offering fund has ushered in the development of riding the wind and waves , By 2021 year 1 End of month , The scale of asset management has been broken 20 One trillion , A record high .

In the context of the high quality of China’s new economy and the development of scientific and technological innovation , Many financial Internet platforms cooperate with fund companies . The integration of Internet financial technology and traditional financial business , Promote the information technology system of traditional financial companies to be more open .

Accordingly ,2020 year , The Internet Finance Department of Boshi fund launched the Internet open platform Matrix The construction work of .

Boshi fund Internet open platform Matrix The background and goal of construction

1、 The problems and challenges of traditional financial architecture

The traditional financial system architecture is challenged by the Internet , Mainly in the following aspects :

1) Lack of control over Internet access

There are multiple teams offering different forms of Internet services , Interface protocol and authority control mode are inconsistent . When there are more and more services and interfaces ,API The problem of insufficient control capacity will be highlighted .

2) The system is relatively closed , Lack of openness

The ecosystem of traditional fund industry is relatively closed , The ability to open up ecology with partners needs to be improved .

3) The ability of financial scenario encapsulation is insufficient

The traditional fund industry system generally relies on the information provided by the underlying database ACID Feature to achieve transaction consistency . After micro service , This set of mechanism is very limited to the product packaging capacity of financial scenario .

2、 System construction goal

1) Multi channel unified security access

Provide standardized and unified access for self owned systems and operators , Achieve internal and external API Unified control .

Matrix Open to the third-party platform after the qualification certification of Boshi Internet platform , Different identities need to be identified according to the third-party platform , Interface level authority control .

2) Provide openness

Building an open platform , Build an open ecosystem with partners . Get in Matrix After the authorization of the platform , Developers of the third-party platform can call the interface capability of Boshi fund’s Internet open platform , Provide fund product information query for the third party platform 、 Registered account opening 、 Redeem points 、 Fund redemption 、 Asset inquiry 、 Joint login and other comprehensive services ; Third party platforms can choose or combine freely according to their own actual situation APP 、 WeChat official account 、 Wechat applet 、H5 And so on .

3) Encapsulating the characteristic functions of the fund industry

The application layer implements the distributed transaction framework to ensure the consistency of the whole transaction . Based on this , Package discount 、 Investment accompaniment and other complex financial scene functions , Let developers focus on business development , Enhance the customer’s investment experience .

Matrix Construction ideas

1、 Overall framework

1) Internet Architecture

be based on Spring Cloud Microservice suite and RocketMQ Message middleware , Build enterprise cloud native architecture .

image.png

2、 Key components

1)API gateway

API Gateway is one of the important components of microservice architecture , It’s the only entrance to the service .API The gateway encapsulates the internal system architecture , Lateral pull off universal function , Such as : Permission to check 、 Fusing and current limiting 、 Load balancing, etc. . adopt API Gateway can put the internal API Unified control .

image.png
At present, the Internet service access of Boshi fund is mainly divided into 3 class :

  • Boshi fund mobile terminal for proprietary business APP and H5 .
  • For direct sales front-end and other partners OpenAPI . As the entrance to the open platform , Service OpenAPI Conditional access restrictions will be provided ( Time 、 Traffic 、 frequency ), Need to consider flow control 、 Safety certification 、 Management of interface authorization .
  • Enterprise internal management system oriented API , Provide enterprise internal system access .

Matrix Of API The gateway is based on Spring Cloud Gateway structure ,SCG Built in Route、Predicate and Filter The module can be easily extended to route forwarding 、 Unified authentication and other cross-sectional functions . Based on the requirement of internal and external network isolation , We independently deployed two gateways , among Kylin Gateway provides Internet access .Phoenix Gateway is used for system access in domain , Provides access control for domain accounts .

2) authentication center

To protect OpenAPI The safety of the , Avoid malicious access 、 Unauthorized access 、 Security risks caused by hacker attacks, etc , Open platform needs to add authorization and authentication module . meanwhile , Between Boshi’s internal application systems , There are also single sign on requirements . A unified certification authority is an essential component of the microservice architecture .

Matrix be based on OAuth2 The protocol builds a unified certification authority , Implement users 、 application 、 Unified authentication and authentication of interface .OAuth2 The core idea is to authenticate the user’s identity through various authentication means , And give Token , So that third-party applications can use the token in a limited time 、 Restricted access to specified resources .Matrix Support OAuth2 Of Authorization Code 、Resource Owner Credentials and Client Credentials Three types of Authorization , According to different application scenarios , Different authorization types are adopted for issuing Token , For the security of open platform .

3)RocketMQ Message middleware

Technology selection

In the process of technology selection , We mainly consider the following points :

First of all, it must be domestic products , The second is the more popular open source products with high community activity .

in addition , Focus on MQ characteristic :

  • Reliable messaging , That is, make sure you don’t lose messages .
  • Distributed transactions , Need to support distributed transactions , Reduce the complexity of the business .
  • performance , Our scenario is mainly online financial business , need MQ Low latency to support financial grade .

Last , From the perspective of architecture evolution , We need to seamlessly connect our hybrid Cloud Architecture , In the end, we chose RocketMQ.

RocketMQ It’s Alibaba’s own R & D and dual 11 Trading core link message products , Provide financial grade high reliable information service . In terms of open source , Open source RocketMQ The integration of cloud native technology stack has been completed , Include Knative Event sources in ,Prometheus Of Exporter,K8s Of Operator etc. ; It also supports the microservice framework SpringCloud And the function computing framework OpenWhisk ; At the same time, a lot of Connector As Sink perhaps Source To connect ELK、Flume、Flink、Hadoop Excellent open source products in the field of big data and data analysis .

stay Matrix Open platform ,RocketMQ There are three main application scenarios .

1) Scenario packaging for financial products

Business scenario :

Typical business scenarios, such as preferential purchase , Jimin applies for the fund through the preferential purchase function , The transaction rate can be reduced to 0. To put it simply, buy Boshi money fund first , And then buy the target fund through the way of quick re purchase , Exemption from relevant conversion rates .

Realization principle :

Matrix be based on RocketMQ The transaction message of the system builds a highly reliable 、 Highly available transaction message platform — Business Center , The business processes involved are as follows :

The first stage is Prepare , That is, the business system will RocketMQ The semi transaction message is sent to the transaction center , The transaction center does not publish , Waiting for the second confirmation .Prepare When it’s done , The business system performs the main transaction , That is, to buy money funds , After success commit To the affairs center , The message is delivered from the transaction center to the slave transaction . If the main transaction fails , Just deliver it rollback To the affairs center .

image.png

Anti investigation mechanism :

Due to network jitter 、 Business system restart and other reasons , It may result in the loss of the secondary acknowledgement of the transaction message . At this time, we need to rely on the anti query mechanism to recover the context of the whole distributed transaction .RocketMQ Provided Message Status Check The mechanism is designed to solve the timeout problem in distributed transactions . The anti query mechanism process of the transaction center is mainly , Check the internal state of the transaction center first , Then check the execution result of the local transaction through the anti query interface , After restoring the transaction context , Push forward the follow-up process normally .

image.png
Depend on RocketMQ Transaction message provided , Transaction center implements distributed transaction in application layer , Greatly improved the scene of financial products packaging capabilities .

2) For decoupling between systems

Business scenario :

department A Responsible for according to the market 、 Products and customers accompany the scene output quality accompany content , department B Responsible for reaching these accompanying contents to different channels and users .

Realization principle :

department A Company events trigger services and departments B Company touch service through RocketMQ Message service decoupling , That is, there is no dependency between the two parties , It doesn’t have to be online at the same time .

image.png

3) Asynchronous call

Business scenario :

There are many scenarios for asynchronous calls , Such as user registration 、 Key user behavior tracking, etc . The user behavior tracking scenario , Record the user’s key behaviors and related properties asynchronously on the server side , It can lay a foundation for users’ hierarchical operation and precision marketing .

Realization principle :

Asynchronization of non core business processes can reduce the response time of the system , Increase throughput , Is a common means of system optimization .RocketMQ Provides an efficient communication mechanism , The business system is very convenient to use .

Summary and future prospects

With the continuous penetration of Internet technology in the financial field and the development of financial innovation formats , The Internet business of public funds needs continuous process transformation 、 Model innovation and service capacity upgrading , On the basis of optimizing the scene experience , Continue to build platform based 、 The Internet service platform of trinity of scene and product .

Matrix After more than a year of construction , At present, it has multi-channel unified access 、 Third party ecological Interconnection 、 Fund characteristic trading scene encapsulation and other functional features .Matrix By building quality 、 Accompanied by temperature , In terms of technology and experience , Let users understand the risks , Understanding investment , And continue to create value for customers .

some time , There will be more partners accessing Matrix , I hope we can swim together in the sea of stars of innovative technology , Win-win cooperation .

Link to the original text

This article is the original content of Alibaba cloud , No reprint without permission .

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注