Exemple #1
0
        public async Task <InvokeResult> AddBinaryMessageAsync(byte[] buffer, DateTime startTimeStamp, String deviceId = "", String topic = "")
        {
            try
            {
                var message = new PipelineExecutionMessage()
                {
                    PayloadType       = MessagePayloadTypes.Binary,
                    BinaryPayload     = buffer,
                    CreationTimeStamp = startTimeStamp.ToJSONString()
                };

                Metrics.MessagesProcessed++;

                if (buffer != null)
                {
                    message.PayloadLength = buffer.Length;
                }

                var bytesProcessed = message.PayloadLength + (String.IsNullOrEmpty(topic) ? 0 : topic.Length);

                message.Envelope.DeviceId = deviceId;
                message.Envelope.Topic    = topic;

                var listenerInstruction = new PipelineExecutionInstruction()
                {
                    Name            = _listenerConfiguration.Name,
                    Type            = GetType().Name,
                    QueueId         = "N/A",
                    StartDateStamp  = startTimeStamp.ToJSONString(),
                    ProcessByHostId = ModuleHost.Id,
                    ExecutionTimeMS = (DateTime.UtcNow - startTimeStamp).TotalMilliseconds,
                };

                message.Instructions.Add(listenerInstruction);

                var planner            = PEMBus.Instance.Solution.Value.Planner.Value;
                var plannerInstruction = new PipelineExecutionInstruction()
                {
                    Name    = "Planner",
                    Type    = "Planner",
                    QueueId = "N/A",
                };

                message.CurrentInstruction = plannerInstruction;
                message.Instructions.Add(plannerInstruction);

                await _plannerQueue.EnqueueAsync(message);

                return(InvokeResult.Success);
            }
            catch (Exception ex)
            {
                PEMBus.InstanceLogger.AddException("ListenerModule_AddBinaryMessageAsync", ex);
                return(InvokeResult.FromException("ListenerModule_AddBinaryMessageAsync", ex));
            }
        }
Exemple #2
0
 protected async Task QueueForNextExecutionAsync(PipelineExecutionMessage message)
 {
     await _outputQueue.EnqueueAsync(message);
 }