Skip to content

Latest commit

 

History

History
35 lines (23 loc) · 1.2 KB

messages-as-interfaces.md

File metadata and controls

35 lines (23 loc) · 1.2 KB
title summary component reviewed related redirects
Interfaces as messages
Define interfaces as messages in NServiceBus to support multiple inheritance scenarios
core
2024-04-04
nservicebus/messaging/dynamic-dispatch-and-routing
nservicebus/messages-as-interfaces
nservicebus/messaging/interfaces-as-messages

Events can be created on the fly from interfaces without first defining an explicit class implementing the interfaces. This technique can be used to support multiple inheritance for polymorphic routing scenarios. In general, it is recommended to use dedicated, simple types as messages instead.

Sending interface messages

Interface messages can be sent using the following syntax:

snippet: InterfaceSend

Replies are supported via:

snippet: InterfaceReply

Publishing interface messages

Interface messages can be published using the following syntax:

snippet: InterfacePublish

Creating interface messages with IMessageCreator

If an interface message is needed before calling Send or Publish, use IMessageCreator directly to create the message instance:

snippet: IMessageCreatorUsage