-
Notifications
You must be signed in to change notification settings - Fork 84
ProtoBuf Serializer
First thing we're going to need to install the package for the ProtoBuf serializer:
Install-Package Nimbus.Serializers.Protobuf
Now we can go ahead and configure Nimbus as usual:
var connectionString = ConfigurationManager.AppSettings["AzureConnectionString"];
var typeProvider = new AssemblyScanningTypeProvider(Assembly.GetExecutingAssembly());
var messageHandlerFactory = new DefaultMessageHandlerFactory(typeProvider);
var bus = new BusBuilder()
.Configure()
.WithNames("MyApplication", Environment.MachineName)
.WithConnectionString(connectionString)
.WithTypesFrom(typeProvider)
.WithDefaultHandlerFactory(messageHandlerFactory)
.WithDefaultTimeout(TimeSpan.FromSeconds(10))
.WithProtoBufSerializer()
.Build();
bus.Start();
return bus;
The main thing to notice there is the ".WithProtoBufSerializer()". This is all you need for setup.
You'll need to make sure you configure your classes properly. You should read more into ProtoBuf but here's some basics to get you started:
[ProtoContract]
public class Person : IBusCommand
{
[ProtoMember(1)]
public string Message {get;set;}
}
Or if you hate attributes and you'd prefer you can configure the serializer at runtime:
var personDef = RuntimeTypeModel.Default.Add(typeof (Person), false);
personDef.Add(1, "Message");
Azure Service Bus
Windows Service Bus
Redis
In Process
Configuring Nimbus With Autofac
Configuring Nimbus With Windsor
Configuring Nimbus With Ninject
Sending a Command on the Bus
Publishing an Event on the Bus
Request Response
Multicast Request Response
Multicast Request Response - take First
Large Message Support