Serialize Message

Hi,
I want to serialize MessageEventArgs.Messsage and store it in flat file, but while serializing i am getting exception that type is non serializable. Any way by which i can serialize "Message" and store in flat file?

Tagged:

Answers

  • amackenzie
    amackenzie Member, Employee Posts: 260 Solace Employee

    there is no way to serialize the IMessage as you have discovered. Can I ask what parts of the message you are interested in and what you are trying to store in a flat file? Parts of the message are available as getters and may suffice for what you are trying to store, but I don't know what your use case for the flat file is.

  • prasoonSolace
    prasoonSolace Member Posts: 9

    Hi,
    Our requirement is when solace is down or because of some reason we are not able to connect with it, then also we want to push data in our application. So what we are trying is when solace is up at that time we want to store data in flat files. In case we are not able to connect to solace we will push the data from the flat files. We are not concered that data should be latest or not. We are more interested in having the data in the application.

    For that purpose we are trying to store IMessage in flat files and push that to client using TCP.

    Client is using many properties of IMessage, so we want to save the entire object.

    Please suggest if there is a way to achieve this. Any suggestion will be helpful :smile:

  • amackenzie
    amackenzie Member, Employee Posts: 260 Solace Employee

    https://docs.solace.com/API-Developer-Online-Ref-Documentation/net/html/75f2bae5-bd7e-322c-0cc5-4d16112790fe.htm has the setters/getters for iMessage. Are the properties you need to store available there? If so is it viable that you create a class to prepare an "exportable" message object of your own definition that can can be serialized?