LiveBlocking::Resubscribe
Resubscribes only to active subscriptions, removing the original start time, if any.
Stored subscriptions and unsubscriptions are replayed in the order they were sent.
Usually performed after calling LiveBlocking.Reconnect.
API method
void Resubscribe(); Example usage
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include <databento/exceptions.hpp>
#include <databento/live.hpp>
#include <exception>
#include <iostream>
using namespace databento;
auto client = LiveBlocking::Builder()
.SetKey("$YOUR_API_KEY")
.SetDataset("GLBX.MDP3")
.BuildBlocking();
client.Subscribe({"BRN.FUT"}, Schema::Ohlcv1M, SType::Parent);
auto metadata = client.Start();
for (int32_t i = 0; i < 10; ++i) {
try {
[[maybe_unused]] auto record = client.NextRecord();
} catch (const databento::TcpError& error) {
std::cerr << "Caught TCP error: " << error.what()
<< "\nAttempting reconnect\n";
client.Reconnect();
client.Resubscribe();
metadata = client.Start();
} catch (const std::exception& exc) {
std::cerr << "Caught unknown exception: " << exc.what()
<< "\nShutting down\n";
client.Stop();
}
}