セッションなどのキャッシュとして Redis を使用し、メッセージ キューを実行するようにアプリケーションをセットアップしたいと考えています。
私のアプリケーションは、ASP.net MVC Web サイトと ServiceStack ベースの Json サービス プロバイダーです。構成する最適な方法は何ですか?
IMessageQueueClient をサービス クラスとコントローラーに渡して、タスクをキューに追加できるようにしたいと考えています。
どの範囲で何を作ろうか迷っています。私のコードは次のとおりです。
//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);
その後、MyApplication.MqService.RegisterHandler(etc); を呼び出します。
- これは機能しますが、スコープが正しいとは確信していません。
- Namespace プレフィックスが機能しないので、この機能が必要です。
ご協力いただきありがとうございます。