Prevent OneWay requests where no handler is registered for the service

I’d like to prevent OneWay requests where no handler is registered in the MQ Server. This is because requests are ending up on queues but never getting processed.

The request’s RequestAttributes doesn’t have the CallType set when the filters are executed so I can’t check it that way.

It appears the only option is to use a RestrictAttribute, but these would need adding to nearly every request DTO as only a few have MQ handlers. I thought about try to add the attribute dynamically, but it would need to handle if a RestrictAttribute was already present.

Are there any other ways to handle this?

Who’s submitting the One Way request, can’t you check then?

Our clients develop their own integrations against the API (the service is also hosted by them). They are not 100% aware of the internals. If they start using SendOneWay there is no indication that the request won’t be processed.

I’ve just added an overridable PublishMessage API where all internal PublishMessages are being routed through in this commit which you can override in your AppHost and perform any necessary checks there, e.g:

public override void PublishMessage<T>(IMessageProducer messageProducer, T message)
    if (messageProducer == null)
        throw new ArgumentNullException(nameof(messageProducer), "No IMessageFactory");


This change is available from v5.2.1 that’s now available on MyGet.


Thanks @mythz you’re a star. :heart: ServiceStack :blush:

1 Like