Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning NServiceBus - Second Edition
  • Table Of Contents Toc
  • Feedback & Rating feedback
Learning NServiceBus - Second Edition

Learning NServiceBus - Second Edition - Second Edition

By : David Boike
4.8 (6)
close
close
Learning NServiceBus - Second Edition

Learning NServiceBus - Second Edition

4.8 (6)
By: David Boike

Overview of this book

If you are a .NET developer who wants to eliminate the problems related to defective third-party web service integration or batch job failures, then this is the book for you. It is also perfect for those of you who are new to NServiceBus and service-oriented architecture and would like to learn how you can streamline all of your development efforts.
Table of Contents (12 chapters)
close
close
11
Index

Creating a message assembly

The first step while creating an NServiceBus system is to create a messages assembly. Messages in NServiceBus are simply plain old C# classes. Like the WSDL document of a web service, your message classes form a contract by which services communicate with each other.

Follow these steps to create your solution:

  1. In Visual Studio, create a new project by creating a new class library. Name the project UserService.Messages and the solution, simply Example. This first project will be your messages assembly.
  2. Delete the Class1.cs file that came with the class project.
  3. From the NuGet Package Manager Console, run this command to install the NServiceBus package, which will add the reference to NServiceBus.Core.dll:
    PM> Install-Package NServiceBus –ProjectName UserService.Messages
    
  4. Add a new folder to the project called Commands.
  5. Add a new class file called CreateNewUserCmd.cs to the Commands folder.
  6. Add using NServiceBus; to the using block of the class file. It is very helpful to do this first so that you can see all the options available with IntelliSense.
  7. Mark the class as public and implement ICommand. This is a marker interface, so there is nothing you need to implement.
  8. Add the public properties for EmailAddress and Name.

When you're done, your class should look like this:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NServiceBus;

namespace UserService.Messages.Commands
{
  public class CreateNewUserCmd : ICommand
  {
    public string EmailAddress { get; set; }
    public string Name { get; set; }
  }
}

Congratulations! You've created a message. This new message will form the communication contract between the message sender and receiver. This is just a message; now you need to create a service that can receive and process it.

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning NServiceBus - Second Edition
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon