Proper usage of the Redis MessageBus class #14238
-
I have some questions about the best way to make use of the OrchardCore.Redis.Bus IMessageBus implementation. I'm trying to use it to pass messages between separate instances in a high-availability cluster. In this particular instance, I'm trying to migrate from an in-memory cache to a distributed cache. I was trying to use the DocumentManager class to back this up, but I ran into some odd things where it wouldn't commit changes until after a full page reload. Perhaps I'd have better luck with an IVolatileDocumentManager? It's a little tricky trying to understand the internals of some of this stuff, even with digging through the source. I can inject an instance of the IMessageBus into a service, and subscribe to messages on a particular channel with the .SubscribeAsync() method. I don't see any way to unsubscribe that handler though. This seems like it would be a bad idea to subscribe to the message bus in a Transient or Scoped service, and even with a Singleton I'm seeing multiple invocations getting raised if I reload an OrchardCore tenant. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
@jtkech perhaps you can help Eric? |
Beta Was this translation helpful? Give feedback.
-
First you need We don't use too much You can take a look at About So any time the whole data are updated by an instance we also update the shared Note: Using a shared document state and doing things if its inner identifier changes (comparing to the local one), is another way to implement events, but with a better chance not to lose them which may be important (but not always).
Yes,
If you already have existing code using |
Beta Was this translation helpful? Give feedback.
-
Thanks for the pointers @jtkech |
Beta Was this translation helpful? Give feedback.
First you need
OC.Redis
features to have concrete implementations of distributed services.We don't use too much
IMessageBus
as we prefer in some places to rely on states than events.You can take a look at
DistributedSignal
which makes ourISignal
distributed, our default localSignal
is already event oriented that's whyDistributedSignal
usesIMessageBus
.About
IVolatileDocumentManager
we use it when we don't want to cache the whole data in a distributed cache but in a local memory cache. In that case we only share in the distributed cache a lightSomeStateDocument : Document
, knowing that anyDocument
has an inner identifier that changes on any update.So any time the whole data are up…