3

I am trying to develop a multi-agent application in F#. Here's what I'm trying to do:

  • Create few agents (say, 100).

  • Have these agents asynchronously communicate with each other, using events.

  • HOWEVER, a requirement is that each of these agents should have no knowledge of each other.

  • The essence of the above point is that, for an agent (say A1, who's the publisher in this case) to send an event to another agent (say A2, who's a subscriber), the agent A2 needs to instantiate A1 to receive notifications from it. Both the Events framework in F# and the Reactive Extensions (Rx) follow this instantiation methodology.

  • What I'm looking for is a F# based event-broker-framework/middleware that allows an agent to subscribe to an event without instantiating the agent which publishes that event. i.e. the agents do not have knowledge of other agents the system. They just know the list of events that exist, and subscribe to (one or more) events from that list. On receiving the subscribed event(s), the agent invokes one of its methods.

  • One solution I can think of for this is the Event Aggregator pattern (e.g. in Prism). But haven't seen any F# implementation of this pattern.

Any reference/pointers would be appreciated. Thanks in advance.

A.K
  • 91
  • 4

1 Answers1

0

You may be interested in reactive programming with the Reactive Extensions framework. It lets you create and manipulate event streams.

A basic introductory scenario would be to create a Subject to which your agents can subscribe or send events, thus acting as either producer or consumer.

I'm not sure if there are any concrete F# implementation of different eventing patterns, but the framework itself is incredibly powerful and definitely worth investigating in my opinion.

Honza Brestan
  • 10,637
  • 2
  • 32
  • 43
  • I may be wrong, but from what I understood, The Rx framework requires instantiation (as I've mentioned above). e.g. For an agent (say A1, who's the publisher in this case) to send an event to another agent (say A2, who's a subscriber), the agent A2 needs to instantiate A1 to receive notifications from it. What I'm looking for is a F# based event-broker-framework/middleware that allows an agent to subscribe to an event *without* instantiating the agent which publishes that event. i.e. the agents do not have knowledge of other agents the system. – A.K Sep 13 '14 at 07:06