public void Publish(ImageUploadedMessage message) { _channel.BasicPublish( exchange: string.Empty, // direct exchange routingKey: _queueName, body: Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message))); }
public async Task <ImageUploadedMessage> Handle(Stream imageStream) { var(imageId, uploadedOn) = await _storage.Save(imageStream); var message = new ImageUploadedMessage { ImageId = imageId, UploadedOn = uploadedOn }; _mqClient.Publish(message); return(message); }
public ImageRecognizedMessage OnImageUploaded(ImageUploadedMessage message) { var bytes = _storage.ReadFile(message.ImageId); if (bytes == null) { return(null); } return(new ImageRecognizedMessage { ImageId = message.ImageId, UploadedOn = message.UploadedOn, Categories = _recognizer.GetCategories(bytes) }); }