Considering this code snippet:
For the destructor method, it got the following 'Segmentation fault (core dumped)' error:
So the question is
1) is that allow to call the destructor (to cleanup) of the consumer and then create a new one theoretically? And why we see those error?
2) For EMA C++, is that true the handler (onRefreshMsg, onStatusMsg,...,) logic runs in a separate thread other that the 'main' thread?
3) Is there any case that EMA cannot recover the connection and quit the application (even set the attemptLimit = -1)?
4) In the case of Login Stream CLOSED due to some issue, does the application need to destroy the old consumer and create a new one, how to do that in the onStatusMsg method implementation?
Firstly, I don't understand why the code above is calling the destructor explicitly - I am not a hardcore C++ developer - but I have always been advised that we should never call the destructor explicitly.
I tested an EMA Example on Linux (WSL) and If I call the destructor explicitly as in the code snippet above, I also see a Segmentation fault. If, however, I delete the OmmConsumer instance then I do not see the segmentation fault.
The event handlers do run in a separate thread to the main application thread.
If ReconnectAttemptLimit is set to -1, it should continue to try and connect indefinitely - unless of course, the main() function exits (e.g. in most of the EMA examples we have a 60s time limit).
If the Login Stream is closed then all streams are closed and the connection is closed, so they would need to create a new OmmConsumer. In terms of deleting and creating a new OmmConsmer - this should be down to standard C++ coding and the developer would need to implement the appropriate strategy in their code. For example, the EMA example 410 creates multiple OmmConsumer by creating a separate class called ConsumerManager - so even here the developer could have a separate class that handles creating and deleting an OmmConsumer on demand.