This is part of the NServiceBus Upgrade Guide from Version 5 to 6, which also includes the following individual upgrade guides for specific components:
Feature Details
- Assembly Scanning Changes in NServiceBus Version 6
- No Async Suffix
- Dependency Injection Changes in NServiceBus Version 6
- Deprecated TransportMessage in NServiceBus Version 6
- Endpoint API changes in NServiceBus Version 6
- Extension Seam Changes in NServiceBus Version 6
- Migrate handlers and sagas to Version 6
- Header API changes in NServiceBus Version 6
- Messaging Changes in NServiceBus Version 6
- Moving away from IBus in Version 6
- Recoverability Changes in Version 6
- Serialization Changes in NServiceBus Version 6
- Subscription Changes in NServiceBus Version 6
- Transaction Configuration Changes in NServiceBus Version 6
Transports
- Azure Service Bus Transport (Legacy) Upgrade Version 6 to 7
- RabbitMQ Transport Upgrade Version 3 to 4
- SQL Server Transport Upgrade Version 2 to 3
- SQL Server Transport Upgrade - Supporting Unicode in Headers
Persistence
- Upgrade from NServiceBus Azure Version 6
- NHibernate Persistence Upgrade Version 6 to 7
- NHibernate Persistence - Resolving incorrect timeout table indexes
- RavenDB Persistence Upgrade from 3 to 4
Hosting
Other
- Moving to the DataBus AzureBlobStorage Package
- Azure Cloud Services Host Upgrade Version 6 to 7
- NServiceBus.Azure package deprecated
- Gateway Upgrade Version 1 to 2
- NServiceBus Testing Upgrade Version 5 to 6
- Callback Changes in NServiceBus Version 6
- Migrating the distributor to use sender-side distribution
- Tool and Helper Changes in NServiceBus Version 6
Setting headers on outgoing messages
Headers are now set using the new Send
/Reply
or Publish
options. Bus.
is no longer available.
See also: Header Manipulation.
Setting outgoing headers for the entire endpoint
NServiceBus allows setting headers that are applied to all outgoing messages for the entire endpoint. In version 6, this can be done using:
endpointConfiguration.AddHeaderToAllOutgoingMessages("MyGlobalHeader", "some static value");
Setting headers on the outgoing pipeline
Headers for outgoing messages can now be set using context.
on pipelines such as:
// For NServiceBus version 6.x
public class OutgoingBehavior :
Behavior<IOutgoingLogicalMessageContext>
{
public override Task Invoke(IOutgoingLogicalMessageContext context, Func<Task> next)
{
var headers = context.Headers;
headers["MyCustomHeader"] = "My custom value";
return next();
}
}
// For NServiceBus version 5.x
public class OutgoingBehavior :
IBehavior<OutgoingContext>
{
public void Invoke(OutgoingContext context, Action next)
{
var headers = context.OutgoingMessage.Headers;
headers["MyCustomHeader"] = "My custom value";
next();
}
}
Also note that headers can only be set on the outgoing pipeline.