I want to set up my application to use Redis as Cache for sessions etc as well as run my Message Queues.
My application is a ASP.net MVC website along with ServiceStack based Json service provider. What is the optimal way to configure?
I want to be able to pass an IMessageQueueClient into my service classes and controllers so that I can add tasks to the queue.
I'm getting somewhat lost over what scope to make what. My code is as follows:
//Redis Client Manager
var pooledClientManager = new PooledRedisClientManager(ConfigurationManager.AppSettings.Get("RedisServer"));
pooledClientManager.NamespacePrefix = "myApp-";
For<IRedisClientsManager>().Singleton().Use(x => pooledClientManager);
//Cache
For<ICacheClient>().Use(c => c.GetInstance<IRedisClientsManager>().GetCacheClient());
//MQ
MyApplication.MqService = new RedisMqServer(pooledClientManager);
For<IMessageQueueClient>().Singleton(). Use(
x => MyApplication.MqService.CreateMessageQueueClient());
For<IMessageService>().Singleton().Use(x=>MyApplication.MqService);
I then later on call MyApplication.MqService.RegisterHandler(etc etc);
- This works but I'm not convinced I've got my scoping correct.
- The Namespace prefix doesn't work, and I need this feature.
Thanks for your help with this!