> 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/configuring-the-runtime/message-flow.md).

# Message Flow

## Overview

Message flow configuration controls how messages move through your Rumi microservice, from receipt through processing to sending. Proper configuration of message flow features ensures reliable, ordered, and duplicate-free message processing.

This section covers runtime configuration options that affect message flow behavior. For conceptual information about message processing, see [Message Processing](/rumi-core/guides/developing-applications/authoring-user-code/message-processing.md).

## What You Can Configure

Message flow encompasses several aspects of how messages are handled:

### Duplicate Detection

Configure sequence number-based duplicate detection to ensure exactly-once processing semantics:

* Enable/disable duplicate checking per channel
* Configure sequence number windows
* Set persistence options for sequence tracking
* Handle sequence resets and rollovers

See [Duplicate Detection](/rumi-core/guides/developing-applications/configuring-the-runtime/message-flow/duplicate-detection.md) for complete configuration reference.

### Message Ordering (Future)

Configuration for message ordering guarantees:

* Ordered delivery within channels
* Key-based ordering
* Sequence number validation

*Note: Additional message flow topics will be added as the documentation expands.*

## Configuration Hierarchy

Message flow settings are configured in your DDL under the engine's messaging section:

```xml
<service name="my-service" mainClass="com.example.MyApp">
  <messaging>
    <buses>
      <bus name="orders-bus">
        <channels>
          <channel name="orders" join="true">
            <!-- Duplicate detection configuration -->
            <duplicateDetection enabled="true"/>
          </channel>
        </channels>
      </bus>
    </buses>
  </messaging>
</service>
```

## How Message Flow Works

Understanding the message processing flow helps configure these features effectively:

1. **Message Receipt**: Message arrives from messaging backbone
2. **Duplicate Check**: If enabled, sequence number checked against tracking window
3. **Handler Dispatch**: Message routed to appropriate handler based on type
4. **Business Logic**: Handler executes, updating state and sending messages
5. **Sequence Update**: If duplicate detection enabled, sequence number recorded
6. **Transaction Commit**: Changes committed atomically with consensus

See [Message Processing](/rumi-core/concepts/microservice-operation/message-processing.md) for detailed flow diagrams.

## Common Configuration Patterns

### Exactly-Once Processing

Enable duplicate detection for channels where exactly-once semantics are critical:

```xml
<channel name="orders" join="true">
  <duplicateDetection enabled="true"/>
</channel>
```

### High-Throughput Channels

For channels where duplicates are acceptable or handled at application level, disable duplicate checking for maximum performance:

```xml
<channel name="market-data" join="true">
  <duplicateDetection enabled="false"/>
</channel>
```

## Related Topics

### Message Processing Concepts

* [Message Processing](/rumi-core/concepts/microservice-operation/message-processing.md) - How messages flow through the engine
* [Transactions](/rumi-core/concepts/transactions.md) - Transaction boundaries and guarantees

### Developer Guidance

* [Detecting Duplicates](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/detecting-duplicates.md) - Understanding duplicate detection from developer perspective
* [Handling Messages](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/processing-messages/handling-messages.md) - Writing message handlers
* [Sending Messages](/rumi-core/guides/developing-applications/authoring-user-code/message-processing/processing-messages/sending-messages.md) - Sending messages with sequence numbers

### Configuration Reference

* [Configuration](/rumi-core/reference/configuration.md) - Complete DDL reference for all message flow settings

## Best Practices

1. **Enable duplicate detection for business-critical channels**: Ensure exactly-once semantics for orders, trades, and other critical messages
2. **Disable for high-volume market data**: When duplicate checking overhead is unacceptable and duplicates can be handled at application level
3. **Configure sequence persistence**: Enable sequence number persistence for channels that need recovery after cold start
4. **Monitor sequence gaps**: Use per-transaction statistics to detect and investigate sequence number gaps
5. **Test failover behavior**: Verify message retransmission and duplicate filtering work correctly during failover scenarios

## See Also

* [Transactions](/rumi-core/guides/developing-applications/configuring-the-runtime/transactions.md) - Configure transaction batching and commit behavior
* [Threading](/rumi-core/guides/developing-applications/configuring-the-runtime/threading.md) - Configure threads that process messages
* [Monitoring](/rumi-core/guides/developing-applications/configuring-the-runtime/monitoring.md) - Monitor message processing statistics
