Haipeng Lin Backend Development Notes
website·Indexed 31 days ago
https://blog.haipeng-lin.cnA comprehensive collection of backend development notes covering Java (JDK 8 to 17), Go, and SpringMVC. It includes detailed guides on databases (MySQL, Redis, MongoDB, Elasticsearch), message queues (RabbitMQ, RocketMQ), ORM frameworks (MyBatis, MyBatis-Plus), and infrastructure tools like Kubernetes (K8s), Canal, and Loki+Grafana.
What's inside Haipeng Lin Backend Blog
- MyBatis is a semi-automatic Object-Relational Mapping (ORM) framework that maps Java entity classes to database records. Unlike fully automatic frameworks (like Hibernate), MyBatis allows for customized SQL and stored procedures, providing a clear separation between Java business logic and SQL data access. It encapsulates most JDBC boilerplate code, including parameter setting and result set retrieval.
Overview of Java Collections Framework
Java collections (containers) are primarily derived from two root interfaces:Collection(for single elements) andMap(for key-value pairs). TheCollectioninterface is further subdivided intoListandSetinterfaces.Overview of Alibaba Canal
Canal is a component based on MySQL database incremental log parsing. It provides incremental data subscription and consumption, allowing data changes to be delivered to downstream consumers (such as Kafka, RocketMQ) or storage systems (such as Elasticsearch, HBase). Essentially, Canal detects MySQL data changes, parses them, and sends them to a message queue or another database for further business processing.Overview of AgentScope Java Tooling Concepts
AgentScope Java utilizes three core concepts to manage capabilities exposed to an AI model:
- Tool: An object that implements the
AgentToolinterface (typically by extendingToolBase) or a method in a standard class marked with the@Toolannotation (referred to as a reflective function tool). - Toolkit: A container responsible for registering tools, MCP (Model Context Protocol) clients, and skills. It exposes their JSON schemas to the model and dispatches tool calls to the appropriate tool object.
- Tool Group: A named collection of tools, MCPs, or skills that can be activated or deactivated as a unit. Agents can switch groups at runtime using a built-in meta tool to maintain context focus.
- Tool: An object that implements the
Overview of Redis Persistence Methods
Redis provides two primary methods for persisting data to disk:
- RDB (Redis DataBase): A point-in-time full backup of the dataset stored as a compact binary serialization file (
dump.rdb). - AOF (Append Only File): A continuous incremental backup that records every write operation executed by the server as text logs (
appendonly.aof).
If both are enabled, Redis will prioritize loading the AOF file upon restart because it typically contains a more complete dataset.
- RDB (Redis DataBase): A point-in-time full backup of the dataset stored as a compact binary serialization file (
Overview of Claude Code
Claude Code is a command-line interface (CLI) coding assistant developed by Anthropic. Unlike a standard chatbot, it acts as an AI pair programmer with operational permissions, allowing it to read local codebases, write files, run terminal commands, execute tests, and manage Git commits and pull requests.Overview of Java ArrayList implementation
ArrayList is a dynamic array implementation of theListinterface. Unlike standard Java arrays, its capacity can grow dynamically. To minimize the number of incremental reallocations when adding a large number of elements, theensureCapacitymethod can be used to increase the instance capacity manually. It extendsAbstractListand implements several key interfaces:List(standard list operations),RandomAccess(indicates support for fast random access via index),Cloneable(supports copying), andSerializable(allows conversion to byte streams for storage or transmission).public class ArrayList<E> extends AbstractList<E> implements List<E>, RandomAccess, Cloneable, java.io.Serializable { }Overview of Chat Memory in Spring AI Alibaba
Chat Memory allows Large Language Models (LLMs) to 'remember' previous interactions by storing and retrieving historical conversation messages. This enables context-aware multi-turn dialogues. Its core functions include:
- Storing History: Automatically saving user messages and model responses after each interaction.
- Retrieving History: Automatically retrieving historical messages and injecting them into the current prompt before a request is sent.
- Session Isolation: Using a
conversationIdto distinguish between different users, ensuring memories remain independent.
Overview of MyBatis-Plus features
MyBatis-Plus (MP) is an enhancement tool for MyBatis that provides a non-invasive way to simplify development and increase efficiency without changing the core MyBatis functionality. Key features include:
- Automatic CRUD: Built-in generic Mapper and Service for single-table operations.
- Lambda Support: Use Lambda expressions for query conditions to avoid hardcoded field names.
- Primary Key Generation: Supports 4 primary key strategies, including a distributed unique ID generator (Sequence).
- ActiveRecord Pattern: Entities can inherit from the
Modelclass to perform CRUD operations directly. - Pagination Plugin: Physical pagination support for multiple databases (MySQL, Oracle, PostgreSQL, SQLServer, etc.).
- Code Generator: Quickly generate Mapper, Model, Service, and Controller layers via Maven plugins or code.
Overview of AbstractQueuedSynchronizer (AQS)
AbstractQueuedSynchronizer (AQS) is a base framework used to implement locks and synchronizers in Java (introduced in JDK 5). It provides the foundation for high-level concurrency utilities such asReentrantLock,ReentrantReadWriteLock,Semaphore, andCountDownLatch. AQS manages synchronization between threads using avolatile int statevariable and a FIFO wait queue. It supports two primary modes of resource acquisition: SHARED and EXCLUSIVE.Overview of Java 8 Key Features
Java 8 introduced several foundational changes to the language:
- Lambda Expressions: Allows passing functions as method arguments.
- Stream API (
java.util.stream): Enables functional-style operations on sequences of elements. - Method References: Compact syntax to refer to existing methods or constructors.
- Date Time API: Improved handling of dates and times.
- Optional Class: A container object used to reduce
NullPointerExceptionrisks.
Overview of Go Concurrency primitives
Go implements concurrency through three primary components:
- Goroutines: Lightweight execution units (similar to threads) that are non-blocking and allow thousands of concurrent tasks without manual thread allocation.
- Channels: Mechanisms for data transfer between Goroutines, supporting synchronization and data sharing without explicit locks.
- Scheduler: Manages the distribution of Goroutines to system threads using the GMP model (Goroutine, Machine, Processor).