spinettaro / delphi-event-bus

Delphi Event Bus (for short DEB) is an Event Bus framework for Delphi
Apache License 2.0
459 stars 105 forks source link

Request/Reply pattern #66

Open ccy opened 3 years ago

ccy commented 3 years ago

The Delphi-Event-Bus library works great for pub/sub pattern. Is that possible to use the library for request/reply pattern?

spinettaro commented 2 years ago

hi @ccy , might you provide an example to better understand the request?

wloochacz commented 2 years ago

Clear @ccy, it's simple using DEB - for example, this way:

  1. you send an IRequest message from a TClient object, which also subscribes to the IReply message.
  2. the TService object subscribes to the IRequest message. When it gets it it starts a worker thread and processes something there.... When it finishes, it sends an IResponse message
  3. the TClient object receives an IResponse message when TService finishes processing its request.

Of course, you have to implement the IRequest, IResponse and TClient, TService types yourself, as you need them.