OnixS C++ FIX Engine 4.14.0
Users' manual and API documentation
Loading...
Searching...
No Matches
Exchanging Messages

Sending Messages to a Counterparty

Use OnixS::FIX::Session::send to submit a message. This call does not wait for counterparty acknowledgment. Messages submitted while disconnected are stored according to the session's storage configuration, but later delivery is not guaranteed. The counterparty must request the messages, and they must still be available in session storage and meet the resend conditions. OnixS::FIX::ISessionListener::onResendRequest must return true to allow a message to be resent. The callback returns false by default, so the Engine sends a gap fill instead of resending the message. See Resending Messages.

Receiving Messages from Counterparty

To receive incoming application-level messages, it is necessary to override the OnixS::FIX::ISessionListener::onInboundApplicationMsg method of OnixS::FIX::ISessionListener Class and pass instance of the descendant class to the OnixS::FIX::Session's constructor.

Example

using namespace OnixS::FIX;
using namespace OnixS::FIX::FIX42;
class SessionListener : public ISessionListener
{
public:
void onInboundApplicationMsg(Message & message, Session *) override
{
// Processing incoming application-level message..
std::clog
<< "Incoming application-level message: "
<< message.toString()
<< std::endl;
}
};
const std::string SenderCompId = "AcceptorAndInitiator_SND";
const std::string TargetCompId = "AcceptorAndInitiator_TRG";
const std::string AcceptoHost = "localhost";
const int AcceptorPort = Engine::instance()->listenPort();
SessionListener listener;
Session acceptor(SenderCompId, TargetCompId, version, &listener);
Session initiator(TargetCompId, SenderCompId, version, &listener);
acceptor.logonAsAcceptor();
initiator.logonAsInitiator(AcceptoHost, AcceptorPort);
Message order(Values::MsgType::Order_Single, version);
order.set(Tags::ClOrdID, "20080808-0955789")
.set(Tags::HandlInst, Values::HandlInst::Automated_execution_order_private_no_Broker_intervention)
.set(Tags::Symbol, "MSFT")
.set(Tags::OrderQty, 100000)
.set(Tags::Side, Values::Side::Buy)
.set(Tags::OrdType, Values::OrdType::Market)
.set(Tags::TransactTime, "20051012-22:10:11");
order.validate();
initiator.send(&order);
// Continues the message exchange..
// Done with messaging.
initiator.logout();
acceptor.logout();
initiator.shutdown();
acceptor.shutdown();