Book Image

Learning NServiceBus - Second Edition

By : David Boike
Book Image

Learning NServiceBus - Second Edition

By: David Boike

Overview of this book

Table of Contents (18 chapters)
Learning NServiceBus Second Edition
About the Author
About the Reviewers

Ending a saga

When the user receives this email, they are obviously going to be very excited to join your site, so they are going to click on it immediately. Let's handle this next.

In the website's HomeController class, add the following action method:

public ActionResult VerifyUser(string email, string code)
  var cmd = new UserVerifyingEmailCmd
    EmailAddress = email,
    VerificationCode = code

  return Json(new { sent = cmd });

This should look similar to the CreateUser action method that we already have. The routing information we have in the Web.config file routes all messages from our UserService.Messages assembly to the UserService endpoint, so we shouldn't need to add anything there.

Now we can handle this new message within our saga. This new message cannot possibly start the saga because our business process cannot create it until after the saga has started. So we must implement IHandleMessages<UserVerifyingEmailCmd> on the saga just...