{{Quickfixn}} Is it possible to retreive the message associated with a reject programatically?

Phillip Wei pwei at bluemountaincapital.com
Mon Jan 6 07:26:05 PST 2014


A rejection usually comes with a RefSeqNum that refers to the sequence number of the message being rejected.  If you have access to your MessageStore, you can invoke MessageStore.Get() to retrieve it (passing in the seqNum as both start/end, and additionally, a string-list for the function to populate).  This gives you the raw string, which you then need to use the msgFactory to create an explicit Message for.

I added the following to Session.cs to do this:

public Message GetMessage(int seqNum)
{
  List<string> refMessageList = new List<string>();
  MessageStore.Get(seqNum, seqNum, refMessageList);
  if (refMessageList.Count != 1)
  {
    throw new Exception(string.Format("Could not find seqnum={0}", seqNum));
  }
  string msgStr = refMessageList[0];
  MsgType msgType = Message.IdentifyType(msgStr);
  string beginString = Message.ExtractBeginString(msgStr);

  Message message = msgFactory_.Create(beginString, msgType.Obj);
  message.FromString(
    msgStr,
    this.ValidateLengthAndChecksum,
    this.SessionDataDictionary,
    this.ApplicationDataDictionary,
    this.msgFactory_);

  return message;
}

Note, I think you might be able to do this outside of Sesssion.cs (I think the specific MessageStore is exposed on Session, and the MessageFactory you should have passed in), but this is how I did it at the time.  Let me know if this works for you (or if others have a better way of doing it).

Phil

From: quickfixn-bounces at lists.quickfixn.com [mailto:quickfixn-bounces at lists.quickfixn.com] On Behalf Of Tim Bailey [ATEO]
Sent: Monday, January 06, 2014 8:57 AM
To: quickfixn at lists.quickfixn.com
Subject: {{Quickfixn}} Is it possible to retreive the message associated with a reject programatically?

Hi

I have a requirement in which I need to get the message sent whenever we receive a reject message.  I can see that we should be able to do this using the SessionState.Get method, but how do I access this as SessionState appears to be a private member of Session.

To clarify what we are wishing to achieve:


1.       Message sent to client.

2.       Client sends a reject message.

3.       We need to programmatically get the message which the reject was set in response to.

This will be for both  Reject and BusinessMessageReject messages.

Thanks for any assistance.

Tim Bailey

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.quickfixn.com/pipermail/quickfixn-quickfixn.com/attachments/20140106/51ae18f0/attachment-0002.htm>


More information about the Quickfixn mailing list