public string PushNextScheduleToAdminQueue(Schedule s, DateTime next) { string correlationid = ""; string env = ConfigurationManager.AppSettings.Get("Environment"); string queue = ConfigurationManager.AppSettings.Get(env.ToUpper() + ".AtulAdminQueue"); XmlDocument doc = s.GetScheduleMessageBodyXML(); string body = doc.InnerXml; List<KeyValuePair<string, string>> headerList = new List<KeyValuePair<string, string>>(); headerList.Add(new KeyValuePair<string, string>("VERB", "INITINSTANCE")); // scale tells how much to multiply the delay by, since the ESB system is passing the delay header from one queue to the next, thus doubling it. // when it's fixed, we can push config change to set scale to 1 and thus delay is intact. double timescale = Convert.ToDouble(ConfigurationManager.AppSettings.Get("MsgTimeScale")); // calculate delay by subtracting now from next scheduled date long delay = Convert.ToInt64(Math.Floor(next.Subtract(DateTime.Now).TotalMilliseconds * timescale)); // if they're scheduled for the next couple minutes, just push it now with no delay so that it doesn't get // caught in lag if (delay >= 100000) { headerList.Add(new KeyValuePair<string, string>("AMQ_SCHEDULED_DELAY", delay.ToString())); } correlationid = this.PushToQueue(queue, body, headerList); return correlationid; }