这是indexloc提供的服务,不要输入任何密码
Skip to content

MessageCache

busterwood edited this page Feb 4, 2018 · 7 revisions

Create a MessageCache to cache messages received via input queue, e.g. a multicast queue. Messages are cached by label, only the last message for a label is cached.

Properties:

  • CachePrefix the prefix used to identify cache request messages, defaults to cache

Methods:

  • StartAsync() starts the cache
  • StopAsync() stops the cache
  • Dispose() also stops the cache

Why?

Applications often want the last known value for a multicast subject, e.g. the last known market price, or last held position, or current market exposure.

Reading the cache

You can request the last message for a Label by sending a message to the input queue with the Label prefixed by cache. and the message ResponseQueue property set.

For example, to get the last message for label Price.123 send a message to the cache's input queue with:

  • Label set to cache.Price.123
  • AppSpecific set to CacheAction.Read (0)
  • ResponseQueue set to the format name of the queue to send a reply to

The cache will reply to the ResponseQueue with:

  • all the fields of the last message for that subject, Body, Extension etc, or an empty message if no value is cached.
  • CorrelationId set to the Id of the request message

Remove a message from the cache

For example, to remove the last message for label Price.123 send a message to the cache's input queue with:

  • Label set to cache.Price.123
  • AppSpecific set to CacheAction.Remove (5)

List the keys stored in the cache

To list the keys in the cache send a message with:

  • Label set to cache
  • AppSpecific set to CacheAction.ListKeys (1)
  • ResponseQueue set to the format name of the queue to send a reply to

The cache will reply to the ResponseQueue with a message with:

  • Body set a UTF-8 string containing multiple lines, one key per line.
  • CorrelationId set to the Id of the request message

To clear the cache

To remove all entries from the cache send a message to the caches input queue with:

  • Label set to cache
  • AppSpecific set to CacheAction.Clear (9)
Clone this wiki locally