I spent 30 minutes or so on it and was able to do it. IFindSagas lets you look into message headers.
Issues I found:
I couldn’t get the ReadOnlyContextBag to return header properties, so I had to cast it to an IMessageHandlerContext. Then I was able to get access to the message headers.
Since JSON_VALUE does not exist in SQL 2014, I had to use SUBSTRING and CHARINDEX to find the value in the Data column. This has poor performance, but, in my case, at most 1 or 2 of these saga’s will be running at a time, so it’s acceptable.
IF I tried to do custom mapping for an IAmStartedBy message, then lots of the properties do not get filled in. These include the property I was mapping on as well as the CorrelationId property for the SagaData table.
I have made the Substring search into a SQL Function.
As described here you can’t declare a correlation property if none of the messages is mapped to it. Correlation property only makes sense if it is used and mapped to messages. If all your messages use finders you should declare it as null. In that case the insert statement will not contain the @CorrelationId parameter that causes the problem.