Some Experience with Balance Deduction Under High Concurrency
Recently, I participated in optimizing an older billing system and learned some common techniques for balance deduction under high concurrency. I also tried some approaches, so I’m summarizing my findings here. Problem DescriptionFor a billing system, concurrency issues are actually divided into two categories. The first is high application concurrency—essentially a large number of users and high access volume. This type of problem is no different from general high concurrency problems and ...
Java Details: Ternary Operator and Autoboxing
Problem IntroductionI encountered an interesting problem today while scanning code with FindBugs — it’s about the ternary operator. Let me record it here. It’s about code like this: 12boolean b = true; Long a = b ? 0l : Long.valueOf(2); FindBugs gave the warning: “Boxed value is unboxed and then immediately reboxed” — meaning a boxed object is unboxed and then immediately reboxed. This problem is actually quite common. I didn’t pay much attention to it at first, and just habitually change...
Designing an Open-Source Beijing Subway Route Planner (Java Version)
OverviewI’ve been looking for an apartment recently, and I wanted to find a location that’s relatively convenient to get to several places. Checking the map manually was quite troublesome, so I decided to build a small tool for planning Beijing subway routes. This article briefly introduces the implementation process. The current functionality is relatively simple — the main method takes an input starting station and lists the routes with the minimum number of stops from all other stations to...
Redis Cluster Data Migration
In a previous article Understanding Redis Cluster Principles Through Hands-on Practice, we briefly introduced the design principles of Redis Cluster. Data in Redis Cluster is distributed across 16384 slots according to certain rules, and these slots are mapped to different nodes based on the configuration. We know that after the cluster is running stably, data can still be transferred at the slot level. However, I’ve never been entirely sure about the specific transfer process, including clus...
JStorm Source Code Analysis: The Loop Task AsyncLoopThread
OverviewAsyncLoopThread is a custom loop task execution utility in JStorm. The implementation is not complex, and on its own may not warrant a dedicated article. However, it is so widely used in JStorm — for features such as supervisor/nimbus heartbeat, fetching new topologies, updating worker status, and many more — that it’s worth introducing here, as it will also help with reading other parts of the codebase. UsageAsyncLoopThread can actually be extracted and used in your own projec...
ActiveMQ Feature - Persistence
IntroductionData persistence is a concern that many systems deal with, especially for systems like Redis and ActiveMQ where data is primarily stored in memory. Since data is stored in memory, there is a risk of data loss when the system crashes. The solution to this problem is to write data to disk through some mechanism — that is, persistence. ActiveMQ provides three persistence methods, based on JDBC, KahaDB, and LevelDB respectively. Currently, the officially recommended method is KahaDB-b...
ActiveMQ Series - Overview
ActiveMQ is an open-source messaging middleware (Message-Oriented Middleware, MOM) under the Apache Software Foundation and a complete implementation of the JMS (Java Message Service) 1.1 specification. This article is the opening piece of the ActiveMQ series. We’ll first clarify what messaging middleware is and what problems it solves, then introduce the core concepts of JMS, laying a solid foundation for further exploration of ActiveMQ’s specific features. What Problems Does Messaging Mid...
Exporting JStorm Monitoring Metrics to Third-Party Storage
JStorm Metrics SystemJStorm’s UI provides a large number of very detailed monitoring parameters, which are extremely helpful for troubleshooting. For information about the UI, you can refer to my previous article: https://lichuanyang.top/posts/31996/. However, using the UI can sometimes be inconvenient, for example when you need to query historical data. Therefore, we want to export monitoring data to other storage media for easier subsequent querying and analysis. Since JStorm’s monitoring h...
Camel Series: Using Camel Debugger
Apache Camel is a powerful enterprise integration framework built on EIP (Enterprise Integration Patterns), with over 200 components that can easily connect various data sources and middleware. However, this power comes with a downside: the high level of encapsulation makes the underlying details opaque, and troubleshooting route problems can be very difficult. Fortunately, the Camel team provides a Debugger tool that allows you to set breakpoints at route nodes and inspect message content, j...
JStorm Source Code Analysis: Bolt Exception Handling
ProblemAnyone who has used Storm or JStorm knows that if an uncaught exception occurs in bolt code, the worker process will exit. This article analyzes the specific design from a source code perspective. It’s actually not as simple as “an exception occurs and then the process crashes.” The TruthLet’s first look at the source code of BasicBoltExecutor: 123456789101112public void execute(Tuple input) { _collector.setContext(input); try { _bolt.execute(input, _collector); ...













