> For the complete documentation index, see [llms.txt](https://docs.rumi.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rumi.systems/rumi-core/guides/developing-applications/authoring-user-code.md).

# Authoring User Code

This section covers how to write the business logic for your Rumi microservice. Topics are organized by functional area to help you find the right information quickly.

## Overview

Rumi microservices are event-driven applications that process messages within automatic transactions. Your user code defines:

* **What consensus model to use** - Event Sourcing or State Replication
* **How to initialize** - Lifecycle hooks and startup behavior
* **How to process messages** - Business logic in message handlers
* **How to inject messages** - Programmatic and scheduled injection
* **How to expose commands** - Administrative control points
* **How to expose metrics** - Custom telemetry and monitoring

## Getting Started

**New to Rumi?** Start here:

1. [Consensus Model](#consensus-model) - Choose and configure your HA policy
2. [Lifecycle](#lifecycle) - Understand initialization and shutdown
3. [Message Processing](#message-processing) - Write your first message handlers
4. Read [Programming Fundamentals](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/processing-messages/handling-messages/programming-fundamentals.md) before writing handlers

## Categories

### Consensus Model

Configure your microservice's high availability and consensus behavior.

* [**Specifying The HA Policy**](/rumi-core/guides/developing-applications/authoring-user-code/consensus-model/specifying-the-ha-policy.md) - Choose Event Sourcing or State Replication

### Lifecycle

Implement lifecycle methods that the Rumi runtime invokes during your microservice's lifecycle.

Lifecycle methods include **accessor methods** (provide data to runtime), **injection methods** (receive runtime objects), and **notification methods** (handle lifecycle events).

* [**Implementing Lifecycle Methods**](/rumi-core/guides/developing-applications/authoring-user-code/lifecycle/implementing-lifecycle-methods.md) - Implement accessor, injection, and notification methods
* [**Initializing the Microservice**](/rumi-core/guides/developing-applications/authoring-user-code/lifecycle/initializing-the-microservice.md) - Handle first and initial messages

### Message Processing

Process inbound messages and execute business logic.

* [**Filtering Messages**](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/filtering-messages.md) - Selectively process messages
* [**Processing Messages**](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/processing-messages.md) - Core message handling
  * [Handling Messages](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/processing-messages/handling-messages.md) - Write message handlers
  * [Sending Messages](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/processing-messages/sending-messages.md) - Send outbound messages
* [**Unhandled Messages**](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/unhandled-messages.md) - Handle messages with no registered handler

### Message Injection

Programmatically create and inject messages for processing.

* [**Injecting Messages**](/rumi-core/guides/developing-applications/authoring-user-code/message-injection/injecting-messages.md) - Inject messages programmatically
* [**Scheduling Messages**](/rumi-core/guides/developing-applications/authoring-user-code/message-injection/scheduling-messages.md) - Schedule future or periodic messages

### Command and Control

Implement administrative commands for runtime control.

* [**Implementing Command Handlers**](/rumi-core/guides/developing-applications/authoring-user-code/command-and-control/implementing-command-handlers.md) - Create custom administrative commands

### Monitoring

Expose custom statistics and telemetry from your microservice.

* [**Exposing Application Stats**](/rumi-core/guides/developing-applications/authoring-user-code/monitoring/exposing-application-statistics.md) - Define custom metrics using `@AppStat`

## Related Topics

* [Microservice Template](/rumi-core/guides/developing-applications/microservice-template.md) - Template-specific guidance for Event Sourcing and State Replication
* [Configuring Messaging](/rumi-core/guides/developing-applications/configuring-messaging.md) - Set up message bus connections and subscriptions
* [Configuring the Microservice Runtime](/rumi-core/guides/developing-applications/configuring-the-runtime.md) - Runtime configuration and tuning
* [Concepts & Architecture](/rumi-core/concepts/introduction.md) - Understand how Rumi works
