> 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/replay.md).

# Replay

The replay server can be used to replay pre-recorded matches or recently offered matches. You can replay all messages sent for a particular sport event (older than 48hrs) using the replay server. In general, the matches are replayable forever. However, Betradar reserves the right to remove events that are older than 2 years.

#### Scenarios <a href="#uofsdkreplay-scenarios" id="uofsdkreplay-scenarios"></a>

Using the replay server functionally is especially useful during the integration period. You can replay one or more sport events or one of the predefined scenarios (currently 3 are available). Scenarios are sets of sport-events/matches that are prepared by Betradar.&#x20;

Instead of adding individual matches, you can add a complete scenario. The sport-events in scenarios will be emitted faster since they are cached, and it is recommended that you use the scenarios for i.e. stress testing.

***Please note that***

* When using the replay server, invoking recovery requests is disabled
* No producer down/up in a replay session (no heartbeat checking is performed)
* The setting "DisabledProducers" is ignored.

#### **Configuration for Replay** <a href="#uofsdkreplay-configurationforreplay" id="uofsdkreplay-configurationforreplay"></a>

When integrating with UOF SDK user can use the "*UofSdkForReplay*" root object (instead of *UofSdk*) which provides the ReplayManager property through which the user can easily define what should be replayed.

{% tabs %}
{% tab title="Configuring UofSdkForReplay (java)" %}

```java
OddsFeedConfiguration configReplay = OddsFeed
            .getOddsFeedConfigurationBuilder()
            .setAccessToken(token)
            .selectReplay()
            .setSdkNodeId(123)
            .setDefaultLocale(Locale.ENGLISH)
            .setExceptionHandlingStrategy(ExceptionHandlingStrategy.Throw)
            .build();
 
ReplayOddsFeed replayFeed = new ReplayOddsFeed(new GlobalEventsListener(), config);
 
OddsFeedSessionBuilder sessionBuilder = replayFeed.getSessionBuilder();
sessionBuilder
            .setListener(new CustomMessageListener("LiveMessagesOnly", oddsFeed, config.getDesiredLocales()))
            .setMessageInterest(MessageInterest.LiveMessagesOnly)
            .build();
sessionBuilder
            .setListener(new CustomMessageListener("PrematchMessagesOnly", oddsFeed, config.getDesiredLocales()))
            .setMessageInterest(MessageInterest.PrematchMessagesOnly)
            .build();
 
logger.info("Feed open");
// Open the feed with all the built sessions
replayFeed.getReplayManager().stop();
replayFeed.getReplayManager().clear();
replayFeed.open();
         
boolean addResponse = replayFeed.getReplayManager().playScenario(1);
ReplayStatus replayStatus = replayFeed.getReplayManager().getPlayStatus();
writeReplayStatus(replayStatus, logger);
 
List<SportEvent> queueEvents = replayFeed.getReplayManager().getReplayList();
logger.info("Currently {} items in queue.", queueEvents.size());
 
// wait till all feed messages are processed. Let's sleep awhile (30 minutes) and see what gets printed.
Thread.sleep(1000 * 60 * 30L);
 
replayFeed.close();
logger.info("Feed close");
```

{% endtab %}

{% tab title="Configuring UofSdkForReplay (.Net)" %}

```java
var _config = UofSdk.GetConfigurationBuilder().SetAccessToken(token).SelectReplay().LoadFromConfigFile().SetSupportedLanguages(supportedCultures10).SetExceptionHandlingStrategy(ExceptionHandlingStrategy.Throw).Build();
 
_log.LogInformation("Creating UofSdk instance");
_replayFeed = new UofSdkForReplay(_config, _loggerFactory, _metricsRoot);
 
_log.LogInformation("Creating UofSession");
var session = _replayFeed.CreateBuilder().SetMessageInterest(messageInterest).Build();
_log.LogInformation("Attaching to uof sdk events");
AttachToFeedEvents(_replayFeed);
AttachToSessionEvents(session);
 
_log.LogInformation("Opening the UofSdk instance");
_replayFeed.Open();
 
_log.LogInformation("Stop and clear replay.");
WriteReplayResponse(replayFeed.ReplayManager.StopAndClearReplay());
var replayStatus = replayFeed.ReplayManager.GetStatusOfReplay();
WriteReplayStatus(replayStatus);
var queueEvents = replayFeed.ReplayManager.GetEventsInQueue();
_log.LogInformation($"Currently {queueEvents.Count()} items in replay queue.");
 
// add events for replaying
WriteReplayResponse(replayFeed.ReplayManager.AddMessagesToReplayQueue(Urn.Parse("sr:match:123456")));
WriteReplayResponse(replayFeed.ReplayManager.AddMessagesToReplayQueue(Urn.Parse("sr:stage:333333")));
 
// start replaying (after feed messages are created on server, the messages will come via same event handlers as it would on normal integration or production server)
WriteReplayResponse(replayFeed.ReplayManager.StartReplay(100, 100));
 
// wait till all feed messages are processed
Console.Readline();
 
// close UofSdk instance
_log.LogInformation("Stopping replay");
_replayFeed.ReplayManager.StopReplay();
 
_log.LogInformation("Closing / disposing the feed");
_replayFeed.Close();
 
DetachFromFeedEvents(_replayFeed);
DetachFromSessionEvents(session);
```

{% endtab %}
{% endtabs %}


---

# 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/replay.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.
