# Define messages · Event-driven multi-chain dapps with ICMF · Learn Chromia

> Here is the sequence of events when someone orders a product through the system:

Source: https://chromia.com/learn/icmf-course/defining-messages/

Event-driven multi-chain dapps with ICMFLesson 3 of 7

1. [01Event-driven multi-chain dapps with ICMF](https://chromia.com/learn/icmf-course/introduction/)
2. [02Set up your project](https://chromia.com/learn/icmf-course/setup/)
3. [03Define messages](https://chromia.com/learn/icmf-course/defining-messages/)
4. [04Order chain (send message)](https://chromia.com/learn/icmf-course/order-chain/)
5. [05Delivery chain (receive message)](https://chromia.com/learn/icmf-course/delivery-chain/)
6. [06The factory chain: sending and receiving](https://chromia.com/learn/icmf-course/factory-chain/)
7. [07Test the dapp](https://chromia.com/learn/icmf-course/manual-testing/)

[Learn](https://chromia.com/learn/)[Event-driven multi-chain dapps with ICMF](https://chromia.com/learn/icmf-course/)

03 / 07Advanced

# Define messages

Here is the sequence of events when someone orders a product through the system:

1. The user places an order, and its details go to the Order Chain (OC).
2. The OC passes the production requirements on to the Factory Chain (FC).
3. The OC also sends the delivery details to the Delivery Chain (DC).
4. The factory produces the ordered items.
5. Delivery gets ready to ship the items as soon as they are finished.
6. The FC tells the DC that the order is ready to ship.
7. Delivery brings the order to the user. This step happens off-chain.
8. The user confirms that the delivery arrived.

To represent this flow in Rell, you define three topics, one per message passed between the chains, along with the payload each message carries. In the `src` directory, create a file named `messages.rell` and add this code:

src/messages.rell

```
module;

namespace topic {
    val PRODUCTION_ORDER = "L_production";
    val NEW_DELIVERY = "L_delivery";
    val SHIPMENT_READY = "L_shipment_ready";
}

namespace msg {
    struct order_details {
        customer_id: integer;
        address: text;
        products: list<product>;
    }

    struct product {
        id: integer;
        quantity: integer;
    }

    // Order -> Factory
    struct production_details {
        order_id: integer;
        products: list<product>;
    }

    // Order -> Delivery
    struct delivery_details {
        order_id: integer;
        shipping_address: text;
        customer_id: integer;
    }

    // Factory -> Delivery
    struct shipment_ready {
        order_id: integer;
    }
}
```

ICMF requires the L\_ prefix. It limits who can receive a message to chains in the sender's cluster.

Only system blockchains are allowed to send global messages, which use the `G_` prefix.

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**Set up your project**](https://chromia.com/learn/icmf-course/setup/)[Next →**Order chain (send message)**](https://chromia.com/learn/icmf-course/order-chain/)
