Is it possible to get an IEnumerable <Message> from a MessageQueue instance

I would like to use Linq in the MSMQ message queue. As far as I know, I would need to pass the message as an IEnumerable Howerver

var queryableQ = new MessageQueue(myQueuePath) as IEnumerable<Message>; 

leads to the fact that querableQ is null, which indicates that MessageQueue cannot be distinguished as such.

Is there any other approach that you can use to access MessageQueue using Linq.

(I know that GetAllMessages () will return an array, which, of course, is easily requested with Linq, but I would prefer not to bring the contents of the entire queue in memory)

+4
source share
1 answer

You need to use the Cast() operator:

 IEnumberable<Message> queryableQ = new MessageQueue(myQueuePath).Cast<Message>(); 
+5
source

Source: https://habr.com/ru/post/1369673/


All Articles