[{"content":"This article records the main steps and failure modes encountered while building OpenNMS from source and deploying a Core and Minion topology.\nPrerequisites\rPrepare a machine with at least 8 GB of memory. Install Java 17. Ensure that Maven Central and the required dependency repositories are reachable. Use a PostgreSQL version supported by the target OpenNMS release. For the environment described here, that means a version earlier than PostgreSQL 17. Build OpenNMS from source\rClone the OpenNMS repository, then run the project scripts:\n1 2 3 4 5 6 7 8 ulimit -n 65535 sudo apt install bzip2 ./clean.pl ./compile.pl -DskipTests ./assemble.pl -p dir ./target/opennms-33.1.4/bin/runjava -s ./target/opennms-33.1.4/bin/install -dis ./target/opennms-33.1.4/bin/opennms -vt start When tests fail during assembly, use:\n1 ./assemble.pl -p dir -DskipTests Keep a custom Maven repository outside the OpenNMS source tree. The assembly process packages source directories, so a repository placed inside the checkout can make the generated archive unexpectedly large.\nUser and permission failures\rIf startup scripts report that the configured user does not exist or lacks permissions, review the RUNAS value in the runjava, install, and opennms scripts. For a controlled test environment, it can be set explicitly:\n1 export RUNAS=root Use a dedicated service account and minimal permissions for a production deployment.\nPostgreSQL authentication\rA common installation failure is:\n1 2 The server requested SCRAM-based authentication, but the password is an empty string. This means the installer reached PostgreSQL but did not receive a valid password. Verify the OpenNMS datasource configuration, the database role password, and the matching pg_hba.conf rule. Test the same credentials with psql before rerunning the OpenNMS installer.\nRemote debugging\rEnable the JVM debug agent on port 8001, then create a Remote JVM Debug configuration in IntelliJ IDEA. Bind the debug listener to a trusted interface only, and restrict the port with a firewall or SSH tunnel because the Java debug protocol must not be exposed publicly.\nThe OpenNMS web interface is available on port 8980 by default.\nCore and Minion deployment\rThe distributed topology consists of:\nOpenNMS Core for event processing, persistence, alarms, and the web console. Minion close to monitored networks for collection and remote execution. gRPC for communication between Core and Minion. The critical checks are:\nCore exposes the configured gRPC endpoint. Minion can resolve and reach the Core address. Certificates, credentials, and location identifiers match. The Minion appears online in the OpenNMS console. A test collection or scan can be executed from the expected location. Treat network reachability, authentication, and location configuration as separate concerns. Verifying them independently makes distributed deployment failures much easier to diagnose.\n","date":"2026-11-24T00:10:00+08:00","permalink":"/en/posts/opennms-distributed-deployment/","title":"OpenNMS Distributed Deployment: Source Build, Remote Debugging, and Minion Configuration"},{"content":"Enterprise Integration Patterns provide a shared vocabulary for connecting systems without turning every integration into a one-off design. The value of the patterns is not the diagram itself, but the explicit ownership, delivery semantics, and failure behavior behind it.\nMessages and channels\rApplications in a distributed system cannot share process memory. They exchange messages that normally contain:\nA header with metadata such as an identifier, timestamp, correlation ID, and routing information. A body containing the business payload. Channels isolate business flows. Commands, domain events, queries, and bulk data transfers should not be mixed into one undifferentiated stream because they have different consumers, priorities, and retry expectations.\nPipes and filters\rThe Pipes and Filters pattern decomposes a complex flow into independent processing stages.\nA filter validates, enriches, decrypts, or transforms a message. A pipe transfers a message between filters. Filters should be stateless whenever practical. Stateless stages are easier to scale horizontally, retry, and test. If a stage requires state, the consistency boundary and replay behavior must be explicit.\nMessage routers\rA router decides where a message goes without changing its business content. Common routing strategies include:\nStatic routing for stable, predefined destinations. Content-based routing using fields in the header or payload. Context-based routing using service health, tenant, region, or runtime policy. Dynamic routing where rules are maintained by a control plane. Routing rules are business rules. They need versioning, tests, monitoring, and a fallback path for messages that match no destination.\nMessage translation\rSystems often disagree at several levels:\nLevel Example Transport HTTP to JMS Representation XML to JSON Data type String to integer Business structure External order model to internal payment model Keep translation at integration boundaries. Allowing an external model to spread through the domain layer couples core business logic to another system\u0026rsquo;s schema.\nSplitter and aggregator\rA splitter turns one composite message into multiple smaller messages. An aggregator combines related messages into one result.\nBoth patterns require a correlation identifier. Aggregation also needs a completion rule:\nExpected message count reached. A final marker received. A time window expired. A business-specific condition became true. Timeout behavior matters as much as the successful path. The system must decide whether to return a partial result, retry missing parts, send the message to manual handling, or fail the entire operation.\nReliability and idempotency\rMost message systems provide at-least-once delivery in real deployments. Consumers must therefore tolerate duplicates.\nUseful controls include:\nA business idempotency key. A consumed-message table or deduplication cache. Transactional outbox for atomically persisting business state and an event. Retry policies with backoff and a maximum attempt count. Dead-letter handling with enough context for replay. Exactly-once business outcomes usually come from idempotent application design, not from assuming the broker will deliver every message exactly once.\nObservability\rAn integration flow should expose:\nMessage and correlation IDs. Current stage and destination. Processing duration per stage. Retry count and final failure reason. Queue depth, consumer lag, and dead-letter volume. Structured logs and distributed tracing must avoid recording passwords, tokens, personal data, or full payment payloads.\nThe practical goal is a flow where routing, transformation, retries, and ownership are visible. A pattern is useful only when operators can understand what happened to a message after production traffic becomes imperfect.\n","date":"2026-11-24T00:00:00+08:00","permalink":"/en/posts/enterprise-integration-patterns/","title":"Enterprise Integration Patterns: Channels, Routing, and Transformation"},{"content":"When an API suddenly becomes slow, restarting the service should not be the first response. A restart may temporarily restore service, but it also destroys the most valuable runtime evidence. Arthas can inspect a running JVM without changing application code.\nConfirm the scope\rBefore running commands, record:\nThe affected APIs or jobs. When the problem started and whether traffic changed. CPU, memory, GC, thread pool, and database connection pool metrics. Recent releases, configuration changes, and downstream failures. Every command should test a hypothesis. Avoid enabling expensive observation on high-frequency production methods without limits.\nInspect the JVM and threads\rUse dashboard for a high-level view of threads, heap usage, and GC. Then inspect high-CPU or blocked threads:\n1 2 3 dashboard thread -n 10 thread --state BLOCKED If many threads wait for the same lock, inspect their stacks. If they are waiting on remote calls, move the investigation toward downstream latency, timeouts, and connection pools.\nLocate slow methods\rtrace shows the time spent at each node in a call chain:\n1 trace com.example.OrderService queryOrder \u0026#39;#cost \u0026gt; 100\u0026#39; Filtering by execution time reduces noise and runtime overhead. After identifying a suspicious method, use watch to inspect only the necessary arguments, return values, or exceptions.\nAlways limit the number of observations and output depth. Avoid printing large objects or observing extremely hot methods.\nVerify the loaded code\rWhen a release appears not to have taken effect, use sc, sm, and jad to inspect loaded classes, methods, and decompiled bytecode. The classloader command helps identify which class loader loaded a class.\nBuild an evidence chain\rA useful incident conclusion connects monitoring symptoms, thread or trace evidence, the root cause, immediate mitigation, and the permanent fix. For example, an apparently slow Java method may ultimately be waiting for an exhausted database connection pool.\nArthas shortens the distance between a symptom and runtime evidence. Use the smallest observation scope possible and record the commands, timestamps, and conclusions for the incident review.\n","date":"2026-10-12T20:09:00+08:00","permalink":"/en/posts/arthas-online-troubleshooting/","title":"A Practical Arthas Workflow for Troubleshooting Java in Production"},{"content":"Customer requests are often phrased as solutions: \u0026ldquo;add a button,\u0026rdquo; \u0026ldquo;provide another route type,\u0026rdquo; or \u0026ldquo;make the task faster.\u0026rdquo; Implementing the sentence literally can deliver a feature without solving the underlying problem.\nStart with the user\u0026rsquo;s goal\rRewrite the request in this form:\n1 2 3 4 When a specific user is in a specific situation, what task are they trying to complete, what currently prevents them from completing it, and what observable result defines success? For example, a request for manual waypoint insertion may actually come from inaccurate route altitude over uneven terrain. The more direct solution could be denser DEM sampling and a better simplification algorithm rather than asking users to edit every point.\nSeparate the requirement, solution, and constraints\rRequirement: the business problem that must be solved. Solution: one proposed implementation. Constraints: protocol, device, time, cost, security, and compatibility limits. When these are mixed together, a temporary implementation idea can be mistaken for an immutable requirement.\nTest the understanding with failure cases\rHappy-path discussion creates false agreement. Ask:\nWhat happens when input is empty, duplicated, or outside the allowed range? How does a partially completed task recover? Can concurrent users create a conflict? May an external timeout be retried? Which actions require an audit record? Failure scenarios expose business rules more effectively than a screen mockup alone.\nWrite verifiable acceptance criteria\rThe result of requirement analysis should be testable:\n1 2 3 4 Given a valid work area with concave boundaries, when the user generates an orthophoto route, the system must produce only valid segments inside the permitted area, and the waypoint count must remain within the device limit. Acceptance criteria give product, engineering, and testing a shared definition of completion.\nKeep the change focused\rFinding the real problem does not mean replacing the existing design. Prefer the smallest verifiable change that preserves stable interfaces and critical workflows. State what is intentionally outside the current scope.\nGood requirement analysis reduces rework and hidden assumptions. Its purpose is not to produce a longer document, but to make the proposed solution falsifiable and the expected outcome clear.\n","date":"2026-07-13T19:44:00+08:00","permalink":"/en/posts/find-real-problem-from-requirements/","title":"How to Identify the Real Business Problem Behind a Requirement"},{"content":"While using the notification stream in hub4j/github-api, I encountered a GitHub API 422 response:\n1 2 Unable to parse If-Modified-Since request header. Please make sure value is in an acceptable format. The fix was merged in PR #1984 and linked to Issue #1985.\nTrace the error to the request header\rThe response explicitly named If-Modified-Since, so the investigation focused on request construction rather than response parsing. In GHNotificationStream.fetch(), the request reused the Last-Modified value from the previous response:\n1 req.setHeader(\u0026#34;If-Modified-Since\u0026#34;, lastModified); The problem was that lastModified is optional. When it was null, the request layer could send the string \u0026quot;null\u0026quot;. That is not a valid HTTP date, so the GitHub API returned 422.\nApply the smallest correct fix\rThe notification stream did not need a broad refactor. The header should only be set when a value exists:\n1 2 3 if (lastModified != null) { req.setHeader(\u0026#34;If-Modified-Since\u0026#34;, lastModified); } This preserves the valid path. When GitHub returns Last-Modified, later polls still use a conditional request. When it is absent, the client sends a normal request.\nAdd a regression test\rA one-line code change is not enough evidence that the bug will stay fixed. I added WireMock data for the notification endpoint and extended the existing test with another iteration after a response without Last-Modified.\nThe test verifies observable behavior rather than a private field: consecutive notification reads must not send an If-Modified-Since header containing \u0026quot;null\u0026quot; and must not receive a 422 response.\nTakeaway\rAn effective open-source fix combines a reproducible failure, a focused code change, and a regression test that matches the project\u0026rsquo;s existing style.\nThe same boundary condition applies to many integrations: optional response headers, cursors, continuation tokens, and pagination links must be checked before they are copied into a later request.\n","date":"2026-06-19T21:12:00+08:00","permalink":"/en/posts/hub4j-notification-bug-fix/","title":"How I Diagnosed and Fixed a Bug in hub4j/github-api"},{"content":"Prerequisites\rUse a machine with at least 8 GB of memory. Install Java 17. Ensure that external dependency repositories are reachable. Use a PostgreSQL version supported by the OpenNMS release. Build and start\rClone OpenNMS, then run:\n1 2 3 4 5 6 7 8 ulimit -n 65535 sudo apt install bzip2 ./clean.pl ./compile.pl -DskipTests ./assemble.pl -p dir ./target/opennms-33.1.4/bin/runjava -s ./target/opennms-33.1.4/bin/install -dis ./target/opennms-33.1.4/bin/opennms -vt start If assembly tests fail, retry with:\n1 ./assemble.pl -p dir -DskipTests Do not place a custom Maven repository inside the source checkout, because the assembly process may include it in the generated source archive.\nRemote debugging\rConfigure the OpenNMS JVM to listen for a debugger on port 8001, then attach with IntelliJ IDEA. Keep the debug port private and use an SSH tunnel when debugging a remote host.\nThe web console uses port 8980 by default.\nScript permissions\rIf the startup scripts report a missing user or insufficient permissions, review the RUNAS setting in runjava, install, and opennms. In a temporary test environment, the value can be supplied explicitly:\n1 export RUNAS=root Production environments should use a dedicated service user with only the required permissions.\n","date":"2025-03-28T08:44:08+08:00","permalink":"/en/posts/legacy-189/","title":"Building and Remotely Debugging OpenNMS"}]