/// <summary> /// Publishes a message /// </summary> /// <param name="message"></param> /// <returns></returns> public bool Publish(MessageModel message) { try { Validate(message, "Message cannot be null"); Channel.BasicReturn += BasicReturn; ExchangeService.Declare(name: message.ExchangeName, queue: message.RoutingKey, type: message.SendType); Channel.BasicPublish(message.GetPublicationAddress(), message.BasicProperties, message.GetBytes()); return(true); } catch (OperationInterruptedException ex) { Logger.Warn(ex.Message); throw new ServiceException("Publish Service Exception: Queue still in use or is not empty the likely cause, please see log for more details."); } catch (Exception ex) { Logger.Error(ex.Message); throw new ServiceException("Publish Service Exception: please see log for more details."); } }