IAmStartedByMessage is not starting

nservicebus
sagas

(Bheesham Kumar) #1

I Created a saga application. in which i created three commands.

 public class SagaHandler : Saga<GroupSagaData>, IAmStartedByMessages<DataCommand>,
                                    IHandleMessages<SendDataCommand>

The GroupSagaData properties are.

public class GroupSagaData : IContainSagaData
    {
        public virtual Guid Id { get; set; }
        public virtual string OriginalMessageId { get; set; }
        public virtual string Originator { get; set; }
        public virtual Guid GroupId { get; set; }
        public virtual IList<SagaData> SagaDatas { get; set; }
    }

the DataCommand properties are

public class DataCommand : IMessage
    {
        public Guid Id { get; set; }
        public int NoOfElementsInGroup { get; set; }
        public int TotalNoOfRecordsInFiles { get; set; }
        public  Guid GroupId { get; set; }
        public string DataSource { get; set; }
        public DateTime JobStartTime { get; set; }
}

and

 public  class SendDataCommand :IMessage
    {
        public Guid GroupId { get; set; }
        public int NoOfElementsInGroup { get; set; }
        public int TotalNoOfRecordsInFiles { get; set; }

    }

I implemented like this.

       protected override void ConfigureHowToFindSaga(SagaPropertyMapper<GroupSagaData> mapper)
            {
                mapper.ConfigureMapping<DataCommand>(message => message.GroupId).ToSaga(sagaData => sagaData.GroupId);
                mapper.ConfigureMapping<SendDataCommand>(message => message.GroupId).ToSaga(sagaData => sagaData.GroupId);
            }

            public async Task Handle(DataCommand message, IMessageHandlerContext context)
            {
                 //some function
            }

when i am debugging,upto GroupSagaData is working fine. After it is not able to find IAmStartedByMessages and IHandleMessages.

In database tables are created GroupSagaData and DataCommand. but data is not moving from the tables. it is blocked in tables.

What I am doing wrong, please suggest


(Andreas Öhlund) #2

when i am debugging,upto GroupSagaData is working fine

Can you clarify? (GroupSagaData is just the contract for the sagas storage needs, you would debug into the messages being processed, ie DataCommand or SendDataCommand)

In database tables are created GroupSagaData and DataCommand

This sounds off, DataCommand is a message so there should be no tables created for it?

What saga storage are you using?

Cheers,

Andreas


(Bheesham Kumar) #3

when i am debugging,upto GroupSagaData is working fine

it means. in our application, we are creating the table. table columns are same as properties of class.
we also using nhibernate.

In database tables are created GroupSagaData and DataCommand

It means, as i mentioned above these are tables. so first data will come to GroupSagaData table and then move to DataCommand.

But the problem is it is not invoking the IAmStartedByMessages.
we are using SQL server.
i hope it helps.


(Andreas Öhlund) #4

So you have some code in your saga to add the data to a DataCommand table that you have created your self?

But the problem is it is not invoking the IAmStartedByMessages.

Are you using SqlPersistence? (https://docs.particular.net/persistence/sql/saga)

If yes you need to use the SqlSaga base class and not the Saga one.