title: Servicestack.Redis Pub/Sub limitations with other nested Redis commands
body: <p>I am having a great experience with ServiceStack &amp; Redis, but I'm confused by ThreadPool and Pub/Sub within a thread, and an apparent limitation for accessing Redis within a message callback.  The actual error I get states that I can only call "Subscribe" or "Publish" within the "current context".  This happens when I try to do another Redis action from the message callback.</p>
  
  <p>I have a process that must run continuously.  In my case I can't just service a request one time, but must keep a thread alive all the time doing calculations (and controlling these threads from a REST API route is ideal).  Data must come in to the process on a regular basis, and data must be published.  The process must also store and retrieve data from Redis.  I am using routes and services to take data in and store it in Redis, so this must take place async from the "calculation" process.  I thought pub/sub would be the answer to glue the pieces together, but so far that does not seem possible.</p>
  
  <p>Here is how my code is currently structured (the code with the above error).  This is the callback for the route that starts the long term "calculation" thread:</p>
  
  <pre><code>    public object Get(SystemCmd request)
      {
          object ctx = new object();
          TradingSystemCmd SystemCmd = new TradingSystemCmd(request, ctx);
  
          ThreadPool.QueueUserWorkItem(x =&gt;
          {
              SystemCmd.signalEngine();
          });
          return (retVal);  // retVal defined elsewhere
      }
  </code></pre>
  
  <p>Here is the SystemCmd.signalEngine():</p>
  
  <pre><code>       public void signalEngine(){
  
          using (var subscription = Redis.CreateSubscription())
          {            
              subscription.OnSubscribe = channel =&gt;
              {
              };
  
              subscription.OnUnSubscribe = channel =&gt;
              {
              };
  
              subscription.OnMessage = (channel, msg) =&gt;
              {
  
                      TC_CalcBar(channel, redisTrade);
  
              };
  
  
              subscription.SubscribeToChannels(dmx_key); //blocking
          }
      }
  </code></pre>
  
  <p>The "TC_CalcBar" call does processing on data as it becomes available. Within this call is a call to Redis for a regular database accesses (and the error).  What I could do would be to remove the Subscription and use another method to block on data being available in Redis.  But the current approach seemed quite nice until it failed to work. :-)</p>
  
  <p>I also don't know if the ThreadPool has anything to do with the error, or not.</p>