Summary [summary] front-end project

Learning this, and despite having no one to teach you, the most important thing is that you have no consciousness and perseverance.

I wish everyone to grab votes home!

What is the front-end

FEP divided into two parts to explain: Pre-and dryers.
  • Machine: you can run a server application, may be windows server, linux can also be a server.
  • Front: Since the server provided by merchants and not the public network IP and port, and then we write the program, in order to connect to the merchant's database, the application can only be deployed to the server to provide the merchant's. That program in front to the merchant server. Front-end program of business is simply to get http / https interface to the business of commodity prices, inventory, promotions, and other members of the data provided by the station, the transmission station to the cloud system.

Why should summarize the FEP project

FEP business is indeed very simple, is to query data - data transmission, not particularly complex business. But is this simple business, but it contains a number of technical thinking and business thinking. With the proverb, it is "small but perfectly formed." Because only ensure a reliable and stable data transmission front-end in order to ensure timely and accurate business data online, it will not result in loss of business. So how to write a reliable, stable and fast front-end data transmission system, but also we need to continue thinking and practice.

Currently After several iterations, the basic design of their own from 0-1, the development of cloud front-end, it would like to share the overall iterative process under the front-end, it can be considered a summary of the self. Special thanks at Universal Brother, give me a lot of technical options and design ideas on architecture. Just to show everyone a reliable cloud front-end data transmission. Now I will operationally and technically, I will design the development process recorded, to share with you, probably not the best, but it is the most suitable front-end. This article does not relate to specific technical Reading in just a brief introduction Why use this, rather than the other?

Front-end technology options

SSM and springboot choice

SSM disadvantages:
  • 1 large amounts of XML configuration
  • 2 Spring coupled with API Servlet, it is difficult from the container (e.g. tomcat) operate independently, so that each had an FEP vessel deployment tomcat

springboot2 advantages:

  • 1 Spring Boot can be run as a separate jar package, embedded Servlet container, no separate deployment tomcat container, so that the project can run fast. Simple deployment
  • 2 Spring Boot offers a range of starter pom to simplify our dependence Maven
  • 3 comes with application monitoring
  • 4 Spring Boot based on the classpath jar package, class, automatically configured to jar Bean bag type, this will greatly reduce our arranged to use
  • 5 No xml configuration and code generation. Spring Boot does not require any configuration to achieve all xml configuration of Spring.

Finally select springboot, development, packaging, compiling, deploying, running is very fragrant than before.

Select swagger2 and front pages

Self-checkout times, if you want to casually synchronous transmission tasks need to write a separate page, front-end level due to poor I can only write a very simple page, this is the need to develop time.

Under later learned, swagger2 an online API documentation, visit http curl and internal support, combined with my need to query data, the actual situation manually synchronize data, cloud FEP has chosen swagger2. Need only a simple configuration, no need to write any page, you can generate online API documentation, and support for offline export.

If some businesses provide public IP and port, and that our product developers or operators, testing the students can also access this page at any time, query the underlying business erp data corresponding. Greatly improve development efficiency and operational efficiency.

Finally, select swagger2.

Database persistence and spring retry retry

Because the data transmission time, the reason may be due to the network, and other network connection timeout different reasons, cause data transmission failure, this time need to retry.

spring retry

springboot integrated spring mechanism retry retry

Retryable method takes effect only directly through a proxy object calls, calls by other indirect methods does not take effect (all the same annotation-based AOP) Tips: In Spring, only need to use Aop proxy class will be generated proxy object, Aop do not need to return directly native objects

First, when JDK dynamic proxies based only method interface proxy, it is necessary to note the following

  • @Retryable or @Recover modified method must be declared in an interface
  • @Retryable can be modified on the interface method declarations can be implemented on a modified method
  • @Recover comment only modification in the method declaration in the interface (the specific reasons have not been analyzed)
  • [Modified to achieve Recover will prompt on the method: Can not locate recovery method]

Second, based CGLIB dynamic proxy, the proxy target class can inherit all methods

  • @Retryable or @Recover modified method must be inherited (can not be final, private modification)
  • @Retryable and @Recover direct modification on the method implementation

Relying on the retry database

Database added a number of retries (tryCount) (synStatus) field and synchronization status, then fail, retry +1 number of retries to a specified number also fails, it is not retried, DB record reason for the failure, issue e-mail alerts to notify project leader process.

Finally, select DB Retry

log4j2 remote log

In the business front-end query log disadvantages:

  • Slow, because the first card or by sunflower tm and other remote connectivity tools, connecting the front-end business before you can open the log file to view, but because of a network problem, connect the front-end is very slow. Open the log file is also very slow,
  • The longest time from the connection to the open log file with the FEP about 8 minutes.
  • Then even if we managed to open the log file to see the time is very slow. So with trying to log front-end synchronization server to our own ideas, because we query log system is based on elk, you can quickly query log.

So they access the http transfer log log4j2, the log file is divided according to the business account

 <Http name="Http" url="xx">
            <JsonLayout properties="true"/>
            <Property name="orgCode" value="123456" />
</Http>
复制代码

spring quartz与spring boot的@Scheduled

Prior to integration is spring quartz, each service module will need to manually write code to handle.

spring quartz

Finally, select @Scheduled spring boot, requiring only a simple annotation configuration and configuration tasks are executed in parallel, it can be used.

spring admin monitor

springboot ring admin is monitoring the project, it is easy to let me know how well the front-end configuration. In addition it can borrow to dynamically modify the log level of function, when the problem, you can switch the logging level to view the log

Local caching options

Local cache: this is because there is a whole brush backdoor all store data, taking into account other people delayed, it would result in data full brush again, he added a mailbox, and generates in advance a verification code into the cache, if used map cache to do so, but also consider issues such as cache miss, so they use the Guava's cache.

Do use google guava memory cache

Limiting

Since the beginning of each business system performance problems, a large number of front-end data transmission, will exceed the capacity of their business processing system, based on this consideration front-end interface to transfer data at http call time, also to be limiting, guaranteed to be called services running. Chose RateLimiter Guava's

Guava achieved using flow restrictors

Reducing the burden on the operation and maintenance maintenance

springboo2 external configuration file

Prior to the time that the business address of each database connections are configured in the code, so that each time a new on-line store, you need a repeated configuration - compilation - Packaging - Remote transfer files - start deployment, this one step, time now in the form of an external configuration file, when the project started references to external configuration files, do not use the configuration in the project, it is a new store, you only need to modify the file, you can restart the application. And whether research and development, or project manager can be a simple operation. Also reducing the burden on developers.

 
 -jar D:\jddj-2\jddj-start.jar --spring.profiles.active=product --spring.config.location=D:\jddj-2\application-product-2.yaml

复制代码
  • before
  • Rear

Remote data query erp

Sometimes, we need to query the raw data underlying business erp database, before then, the project manager is to provide a commodity code to the research, development and query connected to the front-end system going, then return to the project manager.

This needs to be a return takes about five minutes, with access to more and more business, personal development time is getting longer and longer to maintain, so the development of remote inquiry is necessary. After the decision by way of polling, the development of remote query.

  • before
  • Present

Development idea plugins recommended

1 MyBatisCodeHelper-Pro

I think this is a best mybatis extension, although the charges, but that is a pack of cigarettes money. Currently our group I have already recommended three people.

2 Jrebel hot deployment plug-in

This is particularly useful really, really, when I springboot development, I do not need to restart each time the frequent closures of the project, I finished modifying something, recompile directly under the line, greatly improving efficiency.

3 Maven Helper analysis since the conflict maven

Plug-maven to resolve the conflict, it has been in use.

4 GenerateAllSetter plug

This is a key attribute of the set of all objects of a method of generating, using the Alt + enter, can.

Jun Chen | text [original]

Each other to discuss common progress

If the article errors, please point out.

Big weekend or wish you could grab a ticket to go home in it!

Guess you like

Origin juejin.im/post/5dfd82cf518825124c50e565