The message type 'EndOfStream' is not part of the service contract error while sending message to service broker

31 Views Asked by At

I have following service broker:

Message Type

USE [DEV]
GO
ALTER MESSAGE TYPE [TestUpdateMessageType] VALIDATION = WELL_FORMED_XML

Contract

USE [DEV]
GO
ALTER AUTHORIZATION ON CONTRACT::[TestContract] TO [dbo]

Queue

USE [DEV]
GO
ALTER QUEUE [dbo].[TestQueue] WITH STATUS = ON , RETENTION = OFF , POISON_MESSAGE_HANDLING (STATUS = OFF)

Service

USE [DEV]
GO
ALTER SERVICE [TestServiceName]  ON QUEUE [dbo].[TestQueue]

I am sending 100 records deserialized in XML format to this service broker queue using asp .net core. For sending this data, I am using stored procedure.

public async Task PushMessageToSBQ(string groupName, string payload)
{
    try
    {
        var dapperParameters = new DynamicParameters();
        dapperParameters.Add("@endpointGroup", groupName, dbType: DbType.String, direction: ParameterDirection.Input);
        dapperParameters.Add("@xmlPayload", payload, dbType: DbType.Xml, direction: ParameterDirection.Input);

        using (var executor = _executorFactory.GetDbExecutor())
        {
            executor.Execute([dbo].[SendMessage], dapperParameters, commandType: CommandType.StoredProcedure);
        }
    }
    catch (Exception ex)
    {
        throw;
    }
}

When I called this method I am getting following error.

Microsoft.Data.SqlClient.SqlException The message type 'EndOfStream' is not part of the service contract.

The [dbo].[SendMessage] which is used to send data is also working fine, I have checked it multiple time with different service broker queue. I don't know why this issue is occurring, what did I do wrong?

0

There are 0 best solutions below