Board index » delphi » MSMQ events (using ConnectionPoints)

MSMQ events (using ConnectionPoints)

  We are using MSMQ in Delphi, and using Binh Ly's EventSink code (which
uses IConnectionPoints interface) to link up incoming messages to events.
It seems like this method, instead of being implemented as windows messages,
instead acts like interrupts.
  Tracing our code via log messages, we see that when multiple messages
arrive in a short time, our code stops working on one message to process the
next, even though we have not dropped back to the message loop.  There does
not seem to be a way to "disable" the notifications while processing one
message.
  Does anyone know how we can prevent our current task from being
interrupted when a new message arrives, but still respond to the new
message(s) as soon as we're back to the message loop?
-Howard
 

Re:MSMQ events (using ConnectionPoints)


I successfully used Binh Ly's code in a DCOM-based client server system.  I
didn't encounter the same problem as you but did experience some
difficulties because the COM event mechansim is synchronous - the server
triggers an event in one client, waits for that client to process that
event, and then triggers the same event in the next client.  Some events
took a while for the clients to process which slowed down the server
significantly.  I overcame this by changing the client's event handler code.
Instead of processing the event within the handler, the handler just wraps
the event details in a standard windows message and posts it to the clients
main form using PostMessage.  This allowed the client to return control to
the server almost immeditely, the client would then just process the new
windows message.

This solution changed the COM event-handling process from a synchronous to
pseudo-asynchronous which I think is what you want to achieve.  Its not an
ideal solution because it depends on a well behaved client.  If anyone knows
how it could be solved in the server....

Quote
Howard Moon <hm...@landstar.com> wrote in message

news:85vpmh$dg93@bornews.borland.com...
Quote
>   Does anyone know how we can prevent our current task from being
> interrupted when a new message arrives, but still respond to the new
> message(s) as soon as we're back to the message loop?
> -Howard

Re:MSMQ events (using ConnectionPoints)


Perhaps one way is to create a second queue that you use internally. You can
queue messages into your second queue as they arrive and then process them
one by one from say a second thread. This will probably prevent messages
from getting lost if you have longer than expected processing times.

have fun
--
Binh Ly
Need help on COM development?
http://www.techvanguards.com

Quote
Howard Moon <hm...@landstar.com> wrote in message

news:85vpmh$dg93@bornews.borland.com...
Quote
>   We are using MSMQ in Delphi, and using Binh Ly's EventSink code (which
> uses IConnectionPoints interface) to link up incoming messages to events.
> It seems like this method, instead of being implemented as windows
messages,
> instead acts like interrupts.
>   Tracing our code via log messages, we see that when multiple messages
> arrive in a short time, our code stops working on one message to process
the
> next, even though we have not dropped back to the message loop.  There
does
> not seem to be a way to "disable" the notifications while processing one
> message.
>   Does anyone know how we can prevent our current task from being
> interrupted when a new message arrives, but still respond to the new
> message(s) as soon as we're back to the message loop?
> -Howard

Other Threads