# Event Routing

Event processing Agents receive messages sent by other Agents or by Native-Object Triggers and Actions.

Often, HTTP agents are responsible for the ingres of data into your Contextual tenant and either store the incoming data into an object-type record, or send it directly to an Event Agent.

Since there can be multiple instances of a single Agent, the Contextual messaging service automatically partitions the the messages for a specific agent based on the number of agent instances that are running. Events (messages) can then be automatically allocated to a specific partition based on a "key" which is a specific property of the event. This partitioning allows you to ensure that all "related events" can be processed in the same order in which they were received, based on the partition key.

However if no partition key is specified, then messages will be randomly distributed across the available agent instances.

For example, if an event is triggered by an object-type trigger for each record update, you could use the record 'id' (primary key) as the partition key, thus ensuring that all of the events for a specific record are processed in the order in which they were triggered, even if there are many agent instances running. By using the 'id' as the partition key, all of the events for a specific record would be processed by the same agent instance, and since Event agents only process one message at a time, order of processing is ensured.

Similarly, if one agent sends a message to another agent using the "Send To Agent" node, the partition key can also be specified as a property of the node, allowing the flow developer to ensure proper processing order.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.contextual.io/documentation-and-resources/components-and-data/agents/how-agents-work/event-routing.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
