Endpoint handler to process any message in endpoint input queue

Hello,

Are there currently any examples that show how an endpoint can have a handler that will be able to process any message put into an endpoints queue ( event/message/command )?

@jtim08515 if you are saying that you want to write a handler that accepts a System.Object as the message type, you can do that, but I’m not sure there is a valid reason to do so:

  1. Unless you cast to other types within the handler, you will only have access to the methods on Object such as ToString(), etc. which generally are not very useful to performing business operations. In this case, I can only imagine that you are logging throughput or something like that, and that would be better done either using the Particular Service Platform’s monitoring capabilities or if you want to do something custom then you could use something like OpenTelemetry.
  2. If you do cast to another type, then it would be better to write handlers for those types instead.

For typed messages:

  1. Create a handler that accepts object (IHandleMessages<object>) as Adam shared
  2. Write a behavior to access the message object a later stage that has access to the message type after deserialization.

If you want raw access to untyped byte array message data and headers:

  1. Write a behavior to access the data in the IIncomingPhysicalMessageContext state
  2. Use the transport seam that allows raw messaging
  3. Use NServiceBus.Raw (also on Nuget)