public MetaTask[] RegisterTasks(IBrokerModule thisModule) { MetaTask t = new MetaTask() { intervalType = IntervalType.isolatedThread, ModuleName = thisModule.UniqueName, NameAndDescription = "Host for BSON service (BSON over TCP)" }; return(new MetaTask[] { t }); }
private int ConsumerEntry(QueueTask task) { //Console.WriteLine("consumer: {0}", task.ChannelName); //QueueTask task = pi as QueueTask; IBrokerModule mod = task.Module; // Pop item from queue ChannelAnteroom ch = task.Anteroom;//MessageChannels.GetAnteroom(task.ChannelName); if (ch.InternalEmptyFlag) { return(1); } TaskQueue.Providers.TaskMessage message = ch.Next(); if (message == null) { return(1); } //if (message == null) //{ // // this must be replaced with better way communication with message bus // Console.WriteLine("Consumer empty, suspended: {0}", task.ChannelName); // task.Suspended = true; // return; //} TaskQueue.Providers.TaskMessage item = message; bool updated = ((IModConsumer)mod.MI).Push(task.Parameters, ref message); if (updated) { message.Processed = true; message.ProcessedTime = DateTime.UtcNow; } updated = updated || (!Object.ReferenceEquals(item, message));// model is modified if (updated) { ch.Update(message); } ch.ChannelStatsOut.inc(); // inc stats return(0); }
public void Initialise(IBroker context, IBrokerModule thisModule) { logger = context.APILogger(); LoggerWrapper.logger = logger; if (broker != null) {// except } QueueService.ModProducer.broker = context; if (!System.Web.Hosting.HostingEnvironment.IsHosted) { appHost = new baseService(); appHost.Init(); } else { logger.Info("the code is hosted, can't start self hosted messaging service"); } }
public void RegisterTempTask(MetaTask mst, IBrokerModule module) { QueueTask t = new QueueTask() { ModuleName = mst.ModuleName, //Description = mst.NameAndDescription, ChannelName = mst.ChannelName, Anteroom = mst.ChannelName == null ? null : MessageChannels.GetAnteroom(mst.ChannelName), Parameters = null, intervalType = mst.intervalType, intervalValue = mst.intervalValue, NameAndDescription = mst.NameAndDescription }; if (t.Anteroom != null) { t.Anteroom.ChannelStatsIn = Statistics.InitialiseModel(new BrokerStat("chan_in", mst.ChannelName)); t.Anteroom.ChannelStatsOut = Statistics.InitialiseModel(new BrokerStat("chan_out", mst.ChannelName)); //t.Anteroom.ChannelStatistic = Statistics.InitialiseModel(new BrokerStat("channel", mst.ChannelName)); } //ModMod module = Modules.GetByName(t.ModuleName); //if (module == null) // throw new Exception("required qmodule not found."); TaskScheduler.PlanItemEntryPoint ep = TaskEntry; if (t.intervalType == IntervalType.isolatedThread) { ep = IsolatedTaskEntry; } t.JobEntry = ep; t.Module = module; t.Temp = true; Tasks.Add(t); UpdatePlan(); }
public void RegisterTempTask(MetaTask mst, IBrokerModule module) { if (module == null) { module = Modules.GetInstanceByName(mst.ModuleName); if (module == null) throw new Exception("RegisterTempTask: required module not found: " + mst.ModuleName); } QueueTask t = new QueueTask() { ModuleName = mst.ModuleName, //Description = mst.NameAndDescription, ChannelName = mst.ChannelName, Anteroom = mst.ChannelName == null ? null : MessageChannels.GetAnteroom(mst.ChannelName), Parameters = null, intervalType = mst.intervalType, intervalValue = mst.intervalValue, NameAndDescription = mst.NameAndDescription }; if (t.Anteroom != null && t.Anteroom.ChannelStatsIn == null) { t.Anteroom.ChannelStatsIn = Statistics.InitialiseModel(new BrokerStat("chan_in", mst.ChannelName)); t.Anteroom.ChannelStatsOut = Statistics.InitialiseModel(new BrokerStat("chan_out", mst.ChannelName)); //t.Anteroom.ChannelStatistic = Statistics.InitialiseModel(new BrokerStat("channel", mst.ChannelName)); } if (module.Role == ExecutionType.Consumer) { MessageChannels.AssignMessageTypeToChannel(t.ChannelName, ((IModConsumer)module.MI).AcceptsModel, t.ModuleName); } //ModMod module = Modules.GetByName(t.ModuleName); //if (module == null) // throw new Exception("required qmodule not found."); TaskScheduler.PlanItemEntryPoint ep = TaskEntry; if (t.intervalType == IntervalType.isolatedThread) { ep = IsolatedTaskEntry; } t.JobEntry = ep; t.Module = module; t.Temporary = true; //if (module.Role == ExecutionType.Consumer) //{ // if (!typeof(IModConsumer).IsAssignableFrom(module.MI.GetType())) // { // throw new Exception("Consumer module required a consumer interface"); // } // if (t.ChannelName == null) // { // throw new Exception("Consumer module required a channel"); // } // else // { // if (t.Anteroom.ChannelStatsIn == null && t.Anteroom.ChannelStatsIn == null)// first task for this channel? // { // // monitoring put operation // t.Anteroom.ChannelStatsIn = Statistics.InitialiseModel(new BrokerStat("chan_in", t.ChannelName)); // t.Anteroom.ChannelStatsOut = Statistics.InitialiseModel(new BrokerStat("chan_out", t.ChannelName)); // // set selector // TaskQueue.TQItemSelector selector = ((IModConsumer)module.MI).ConfigureSelector(); // // channel -> model(MType) // MessageChannels.AssignMessageTypeToChannel(t.ChannelName, ((IModConsumer)module.MI).AcceptsModel, t.ModuleName); // MessageChannel channel = MessageChannels.GetInstanceByName(t.ChannelName); // channel.consumerSelector = selector; // } // } //} Tasks.Add(t); UpdatePlan(); }
public MetaTask[] RegisterTasks(IBrokerModule thisModule) { return(null); }
public void Initialise(IBroker context, IBrokerModule thisModule) { }
public void Initialise(IBroker context, IBrokerModule thisModule) { logger = context.APILogger(); broker = context; }
public MetaTask[] RegisterTasks(IBrokerModule thisModule) { MetaTask t = new MetaTask() { intervalType = IntervalType.isolatedThread, ModuleName = thisModule.UniqueName, NameAndDescription = "Host for BSON service (BSON over TCP)" }; return new MetaTask[] { t }; }
public void Initialise(IBroker context, IBrokerModule thisModule) { emailSender = new Sender(context.APILogger()); }
public void InitialiseEntry(IBroker context, IBrokerModule thisModule) { MI.Initialise(context, thisModule); }
public MetaTask[] RegisterTasks(IBrokerModule thisModule) { return null; }