> For the complete documentation index, see [llms.txt](https://docs.sportradar.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sportradar.com/uof/sdk/features/session.md).

# Session

### What is a Session? <a href="#uofsdksessions-whatisasession" id="uofsdksessions-whatisasession"></a>

A session represents a channel of communication with the AMQP broker.

Each **session** runs in its own thread - meaning that messages received by different sessions are processed in different threads. Each thread is owned by the component used to communicate with the **feed (rabbit channel).** The long-running operations should not be invoked on those threads because this would block receiving new messages on that **session**. More than one **session** can be created on each **feed** instance. The session itself cannot be opened or closed (started or stopped). It opens/closes when the associated **feed** object is opened/closed.

When building a **session**, a **message interest** specifying the **session** scope must be provided. **Message interest** specifies which messages will be received by the associated **session**.

Only certain combinations of **message interest / session** combinations are permitted. The permitted combinations are as follows:

* If only single session is configured - it can be associated with any message interest.
* If multiple sessions are desired to be configured than the following combinations are allowed:
  * High priority and Low priority message interests at a time, or
  * Live messages, Prematch messages and Virtual sports interests altogether, or any subset of these.

### **How to create a session?** <a href="#id-republish-uofsdksessions-howtocreateasession" id="id-republish-uofsdksessions-howtocreateasession"></a>

The code snippets (in Java and .NET) to create a session are as follows.

{% tabs %}
{% tab title="Creating session (Java)" %}

```
OddsFeedSession session = oddsFeed.getSessionBuilder()
                .setListener(new MyMessageListener())
                .setMessageInterest(MessageInterest.AllMessages)
                .build();
```

{% endtab %}

{% tab title="Creating session (.Net) " %}

```
var session = oddsFeed.CreateBuilder().SetMessageInterest(MessageInterest.AllMessages).Build();
```

{% endtab %}
{% endtabs %}

SDK always creates just one connection to rabbit server (uses that connection for one unique channel for system messages - alive and snapshot\_complete) and 1-3 channels for user messages depending on user configuration of sessions. Each **session** has one unique underlying channel.

**Session** ensures that feed messages are dispatched to the user code in the same order as they are put on the rabbit queue.

Once the messages are dispatched to the user code, you need to ensure that feed messages for the same sport event ID are processed in the same order as they were received and the feed messages for different event IDs should be processed in parallel.

### Best Practices <a href="#id-republish-uofsdksessions-bestpractices" id="id-republish-uofsdksessions-bestpractices"></a>

The customer should extract only time critical data like odds from the message in this thread, and hand over the message to a different thread to do further API calls for translations. This is the action which usually helps the most with the message processing speeds and reduction of down times.&#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.sportradar.com/uof/sdk/features/session.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
