public IJobQueue Register(IConsumerRun run)
        {
            this.run = run;
            IConsumerContext ctx = Turbine.Consumer.AppUtility.GetConsumerContext();
            //Guid consumerId = ctx.Id;
            //Guid consumerId = Guid.NewGuid();
            String hostname = ctx.Hostname;
            String appName  = run.SupportedApplications.ElementAtOrDefault(0);

            Debug.WriteLine(String.Format("Register({0}) as {1}, {2}", appName, run.ConsumerId, hostname), this.GetType().Name);
            using (ProducerContext db = new ProducerContext())
            {
                // TODO: Registering as a single application is dubious.
                // IF support multiple apps in single consumer need to expose that via the database ( update SCHEMA!! )
                var app      = db.Applications.Single(a => a.Name == appName);
                var consumer = new Turbine.Data.Entities.JobConsumer
                {
                    Application = app,
                    Id          = run.ConsumerId,
                    hostname    = hostname,
                    processId   = System.Diagnostics.Process.GetCurrentProcess().Id,
                    keepalive   = DateTime.UtcNow,
                    status      = "up"
                };
                db.Consumers.Add(consumer);
                db.SaveChanges();
            }
            queue = AppUtility.GetJobQueue(run);
            //((DBJobQueue)queue).consumerId = consumerId;
            return(queue);
        }
        protected virtual IJobConsumerContract GetNextJob()
        {
            IJobQueue queue = AppUtility.GetJobQueue(this);
            var       job   = queue.GetNext(this);

            if (job != null && IsSupported(job) == false)
            {
                Debug.WriteLine(String.Format("Application {0} is not supported", job.ApplicationName), GetType().Name);
                Debug.WriteLine("QUEUE: " + queue, GetType().Name);
                //return null;
                throw new Exception(String.Format("Application {0} is not supported", job.ApplicationName));
            }
            return(job);
        }