Tyler Day
Tyler Day

Reputation: 1718

Setting initial state of new saga

We are in the process of migrating a legacy system to nservicebus 5.0. What is generally the best way to migrate our business data to saga data? For example, if we had an OrderCancellationPolicy saga, that only allowed cancellation within 2 days, how would past orders from the legacy system create these new sagas in the correct state?

I see two options. The first being to write some sql script to prepopulate the saga persistence tables (we are using nhibernate persistence). The other being to create some kind of special import message, such as MigrateOrderDataCmd, that contains the data from the legacy order. An import script could send out these messages which the sagas could handle and set the saga data that way.

Any guidance in this area is appreciated.

Upvotes: 0

Views: 134

Answers (1)

Dennis van der Stelt
Dennis van der Stelt

Reputation: 2178

Theoretically I'd go for option two, or a version of it. Imagine your saga being down for a day and messages are piling up in the queue. With messages from a day coming in, you'd want to verify when the message was sent, or add a custom DateTime to the message yourself.

When the saga finally picks up the message, it knows it should not set the timeout two days in the future, but rather the time the message took to be delivered into the saga. That way when you migrate your current state, all messages get a proper timeout set.

On the other hand, if you've got a really large set of running processes, you might want to investigate how to propagate the tables. I have no hands on experience adding records to those tables myself, just changing them. :)

Upvotes: 1

Related Questions