I am having issues with NSB reverting to the Xml Serializer for no apparent reason which obvisouly causes an error when trying to deserialize the message. Below is an excerpt from the log, as you can see some come through from the same source as Json and then all of a sudden XML!
2018-06-05 08:51:36.924 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body: 2018-06-05 08:51:37.026 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter {"Exchange":"Binance","Symbol":"SYSBTC","MinutesPerCandle":15} 2018-06-05 08:51:38.505 INFO Stockly.Services.QuoteService.QuoteHandler Received quote request for SYSBTC and retrived 1000 candles 2018-06-05 08:51:38.725 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body: 2018-06-05 08:51:38.728 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter {"Exchange":"Binance","Symbol":"DASHBTC","MinutesPerCandle":15} 2018-06-05 08:51:39.194 INFO Stockly.Services.QuoteService.QuoteHandler Received quote request for DASHBTC and retrived 1000 candles 2018-06-05 08:51:39.228 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body: 2018-06-05 08:51:39.230 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter {"Exchange":"Binance","Symbol":"ENJBTC","MinutesPerCandle":15} 2018-06-05 08:51:39.715 INFO Stockly.Services.QuoteService.QuoteHandler Received quote request for ENJBTC and retrived 1000 candles 2018-06-05 08:51:39.774 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body: 2018-06-05 08:51:39.777 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter BinanceRPXBTC15 2018-06-05 08:51:39.824 ERROR NServiceBus.RecoverabilityExecutor Moving message 'f095da8a-e830-4873-8fa0-a8f200719739' to the error queue 'error' because processing failed due to an exception: NServiceBus.MessageDeserializationException: An error occurred while attempting to extract logical messages from incoming physical message f095da8a-e830-4873-8fa0-a8f200719739 ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0. at Newtonsoft.Json.JsonTextReader.ParseValue()
Here is the configuration.
public static EndpointConfiguration ConfigureSerialization(this EndpointConfiguration endpointConfiguration)
{
var serialization = endpointConfiguration.UseSerialization<NewtonsoftSerializer>();
serialization.ContentTypeKey("NewtonsoftJson");
var settings = new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto,
Converters =
{
new IsoDateTimeConverter
{
DateTimeStyles = DateTimeStyles.RoundtripKind
}
}
};
serialization.Settings(settings);
endpointConfiguration.RegisterMessageMutator(new MessageBodyWriter());
var externalNewtonsoftJson = endpointConfiguration.AddDeserializer<NewtonsoftSerializer>();
externalNewtonsoftJson.ContentTypeKey("NewtonsoftJson");
return endpointConfiguration;
}
Any idea why this might be happening and how I can stop this from occurring?
P.S. at the moment I am using the LearningTransport.