This sample demonstrates how to use a pluggable session storage.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20
21#include <iostream>
22
25
27
34
36
37int main(
int argc,
char* argv[])
38{
39
41
42 try
43 {
45
48
49
51
54
55
57
58 bgwSession.connect(bgwCredentials);
60
62
64
66
68 }
69 catch (const std::exception& ex)
70 {
71 std::cerr << "EXCEPTION: " << ex.what() << std::endl;
72 return 1;
73 }
74
75 return 0;
76}
#define ONIXS_ICEBOE_NAMESPACE
#define ONIXS_ICEBOE_MESSAGING_NAMESPACE
int main(int argc, char *argv[])
static MessageHolder< NewOrderRequest > createOrder(const std::string &traderId)
static MessageHolder< TraderLogoutRequest > createTraderLogoutRequest(const std::string &traderId)
static MessageHolder< TraderLogonRequest > createTraderLogonRequest(const std::string &traderId, const std::string &traderPwd)
std::promise< void > traderLoggedOn
std::pair< std::unique_ptr< GatewayEmulatorThread< BusSessionGatewayListener > >, std::unique_ptr< GatewayEmulatorThread< GatewayListener > > > createEmulator(const SessionSettings &settings, const ConnectivityConfiguration &cfg, bool tcpDirect=false)
BgwCredentials receiveBgwCredentials(SessionSettings settings, std::string host, Port port)
SessionSettings fillSettings(const LogonConfiguration &logonCfg, const ConnectivityConfiguration &connCfg, const SettingsConfiguration &settingsCfg)
std::future< T > wait(Stack &stack, std::promise< T > &promise, std::chrono::seconds timeout=std::chrono::seconds{30})
@ Pluggable
Pluggable Session Storage.
static void waitUntilKey(const std::string &message)
static void manageSignals() noexcept
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
20
23
25namespace {
26
28 {
29 return static_cast<const char*>(message.data());
30 }
31
33 {
34 return static_cast<const char*
>(
advanceByBytes(message.data(), message.size()));
35 }
36
38 {
40
42 throw std::runtime_error("Unknown message type");
43 }
44}
45
47 inSeqNum_(1),
48 outSeqNum_(1),
50 terminated_(false),
51 sessionCreationTime_()
52{}
53
55{
56 std::clog << "\nClose the session storage (doBackup=" << doBackup << ").\n";
57
58 inSeqNum_ = 1;
59 outSeqNum_ = 1;
60 terminated_ = false;
61 inboundMessages_.clear();
62 outboundMessages_.clear();
63}
64
66{
67 return id_;
68}
69
71{
72 return inSeqNum_;
73}
74
76{
77 std::clog << "\nSet inSeqNum to " << msgSeqNum << ".\n";
78 inSeqNum_ = msgSeqNum;
79}
80
82{
83 return outSeqNum_;
84}
85
87{
88 std::clog << "\nSet outSeqNum to " << msgSeqNum << ".\n";
89 outSeqNum_ = msgSeqNum;
90}
91
93{
94 return sessionCreationTime_;
95}
96
98{
99 std::clog << "\nSet sessionCreationTime to " << time << "\n";
100 sessionCreationTime_ = time;
101}
102
104{
105 std::clog << "\nStore inbound message:\n";
106 storeMessage(inboundMessages_, message);
107
108 inSeqNum_ = msgSeqNum;
109}
110
112{
113 std::clog << "\nStore outbound message:\n";
114 storeMessage(outboundMessages_, message);
115
116 outSeqNum_ = msgSeqNum;
117}
118
120{
121}
122
124{
125}
126
127}
SbeMessage message() const noexcept
Retrieves the underlying SBE message.
The time point without the time-zone information.
void flush() override
Flushes all internal buffers.
void storeOutboundMessage(const NetworkMessage message, SeqNumber msgSeqNum, Timestamp messageSendingUtcTimestamp=Timestamp()) override
Logs the given outgoing message.
Timestamp sessionCreationTime() const override
std::vector< char > Message
void close(bool doBackup=false) override
Closes the storage.
void warmup(size_t, Timestamp) override
Warmup the storage.
SeqNumber outSeqNum() const override
SeqNumber inSeqNum() const override
std::list< Message > Messages
void storeInboundMessage(const NetworkMessage message, SeqNumber msgSeqNum, Timestamp messageReceivingUtcTimestamp=Timestamp()) override
Logs the given inbound message.
const std::string & id() const override
bool processTypified(SbeMessage binary, Processor &&processor)
Casts a given binary message according to template/type information and processes the cast messages b...
ONIXS_ICEBOE_FORCEINLINE Type * advanceByBytes(Type *pointer, ptrdiff_t distance) noexcept
Advances the pointer to a given offset (distance) in bytes.
decltype(std::declval< const Messaging::SbeMessage & >().sequenceId()) SeqNumber