예제 #1
0
        public void Publish1000MessagesWithPropertiesAndHeaderTest()
        {
            var headers = new Dictionary <String, String>();

            headers.Add("MyHeader1", "MyHeaderValue1");
            headers.Add("MyHeader2", "MyHeaderValue2");
            headers.Add("MyHeader3", "MyHeaderValue3");
            headers.Add("MyHeader4", "MyHeaderValue4");
            headers.Add("MyHeader5", "MyHeaderValue5");
            var payload = "Publish1000MessagesWithPropertiesAndHeaderTest";

            for (int i = 0; i < 1000; i++)
            {
                var properties = new PublishProperties("appid", "correlationid", "messageid", userName, 2, headers);
                var body       = new PublishRequest(routingKey, payload + i, PublishRequest.PayloadEncodingEnum.String,
                                                    properties);
                var response = instance.PublishMessage(vhost, exchange, body);
                Assert.NotNull(response);
                Assert.True(response.Routed);
            }

            for (int i = 0; i < 1000; i++)
            {
                var request             = new ConsumeRequest(1, "ack_requeue_false", "auto", 50000000);
                var consumeResponseList = instance.ConsumeMessage(vhost, "shared.queue", request);
                var consumeResponse     = consumeResponseList[0];
                Assert.NotNull(consumeResponse);
                Assert.Equal(payload + i, consumeResponse.Payload);
                Assert.Equal(headers, consumeResponse.Properties.Headers);
            }
        }
예제 #2
0
        /// <inheritdoc />
        public virtual IMessageEnvelope Encode <TMessage>(TMessage message, string destination)
        {
            var p = new PublishProperties
            {
                Exchange = destination,
            };

            return(this.Encode <TMessage>(message, p));
        }
        /// <inheritdoc />
        public virtual IMessageEnvelope Encode(TMessage message, string exchange, string topic, bool mandatory)
        {
            var p = new PublishProperties
            {
                Exchange   = exchange,
                Mandatory  = mandatory,
                RoutingKey = topic,
            };

            return(this.Encode(message, p));
        }
예제 #4
0
        private static PublishProperties GetPublishProperties(string jobTitle)
        {
            var returnProperties = new PublishProperties
            {
                Author       = Settings.Default.NWD_AUTHOR,
                Comments     = Settings.Default.NWD_COMMENTS,
                Copyright    = Settings.Default.NWD_COPYRIGHT,
                Keywords     = Settings.Default.NWD_KEYWORDS,
                PublishDate  = DateTime.Now,
                PublishedFor = Settings.Default.NWD_PUBLISHEDFOR,
                Publisher    = Settings.Default.NWD_PUBLISHER,
                Subject      = Settings.Default.NWD_SUBJECT,
                Title        = jobTitle,
                AllowResave  = true
            };

            return(returnProperties);
        }
예제 #5
0
        private static PublishProperties GetPublishProperties(string jobTitle)
        {
            var returnProperties = new PublishProperties
            {
                Author = Settings.Default.NWD_AUTHOR,
                Comments = Settings.Default.NWD_COMMENTS,
                Copyright = Settings.Default.NWD_COPYRIGHT,
                Keywords = Settings.Default.NWD_KEYWORDS,
                PublishDate = DateTime.Now,
                PublishedFor = Settings.Default.NWD_PUBLISHEDFOR,
                Publisher = Settings.Default.NWD_PUBLISHER,
                Subject = Settings.Default.NWD_SUBJECT,
                Title = jobTitle,
                AllowResave = true
            };

            return returnProperties;
        }