コード例 #1
0
        /// <summary>
        /// Create a new Message with Binary (byte) Content for Publishing to an Exchange
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="exchange">The Exchange to Publish this Message to</param>
        /// <param name="routingKey">The Routing Key for this Message</param>
        /// <param name="bytes">The Binary (byte) Data for this Message</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="BinaryPublishMessage"/> Instance ready to be Published</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string exchange, string routingKey, ReadOnlyMemory <byte> bytes, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            PublishMessage message = CreateNew(client, exchange, routingKey, type, mode);

            message.Body        = bytes;
            message.ContentType = ContentTypes.Binary;

            return(message);
        }
コード例 #2
0
        /// <summary>
        /// Create a new Message with Binary (byte) Content for Publishing a Reply directly to a Queue
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="replyTo">The Name of the Queue to Directly Publish to</param>
        /// <param name="receivedMessageId">The ID of the Message that is being Replied to</param>
        /// <param name="bytes">The Binary (byte) Data for this Message</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="BinaryPublishMessage"/> Instance ready to be Published</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string replyTo, Guid receivedMessageId, ReadOnlyMemory <byte> bytes, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            PublishMessage message = CreateNew(client, replyTo, receivedMessageId, type, mode);

            message.Body        = bytes;
            message.ContentType = ContentTypes.Binary;

            return(message);
        }
コード例 #3
0
        /// <summary>
        /// Create a new Message with JSON Content for Publishing a Reply directly to a Queue
        /// </summary>
        /// <param name="client">A <see cref="RabbitMQClient"/> Instance</param>
        /// <param name="replyTo">The Name of the Queue to Directly Publish to</param>
        /// <param name="receivedMessageId">The ID of the Message that is being Replied to</param>
        /// <param name="json">The JSON Data for this Message</param>
        /// <param name="type">The Type of Message</param>
        /// <param name="mode">The Publishing Mode for this Message</param>
        /// <returns>A New <see cref="JSONPublishMessage"/> Instance ready to be Published</returns>
        public static PublishMessage CreateNew(RabbitMQClient client, string replyTo, Guid receivedMessageId, JToken json, string type = "", PublishMode mode = PublishMode.BrokerConfirm)
        {
            if (json == null)
            {
                throw new ArgumentNullException(nameof(json));
            }

            PublishMessage message = CreateNew(client, replyTo, receivedMessageId, type, mode);

            message.Body            = Encoding.UTF8.GetBytes(json.ToString(Formatting.None));
            message.ContentType     = ContentTypes.JSON;
            message.ContentEncoding = "utf8";

            return(message);
        }