Description
I noticed that when enabling advisories for expiration that Topic Subscriptions do not send the advisory. this is because the server code calls discard so the discard advisory is sent instead. This should be fixed so that if the message is expired by the subscription on the server (usually on dispatch) that the advisory sent is the expired and not discarded advisory.
Also, on another note, just like how we don't currently fire message consumed advisories for topic subscriptions for the same reason, expired advisories are not fired if the client does the expiration (only if server expires). This only applies to Topic subs (and not durable or queue subs) because Topic Subs are different in that they do not track the original message for dispatched messages.
This is done for performance and to save memory as default topic prefetch is quite high at Short.MAX (over 32k) so just some metadata is saved. We would need to track the original message to be able to use it when the acks were sent by the client for consumed, expiration, etc to do this but since this feature seems to be rarely used and off by default probably not worth it for now. If we ever wanted to fix it we would likely want to lower prefetch to be a lot lower (maybe default 1000) like durables to prevent blowing heap.