コード例 #1
0
        public static void PurgeBuffer(Uri bufferAddress, TransportClientEndpointBehavior credential)
        {
            Debug.Assert(BufferExists(bufferAddress, credential));

            MessageBufferClient client = MessageBufferClient.GetMessageBuffer(credential, bufferAddress);
            MessageBufferPolicy policy = client.GetPolicy();

            client.DeleteMessageBuffer();
            MessageBufferClient.CreateMessageBuffer(credential, bufferAddress, policy);
        }
コード例 #2
0
        MessageBufferPolicy GetBufferPolicy(string address)
        {
            if (address.StartsWith(@"sb://"))
            {
                return(null);
            }

            Uri bufferAddress = new Uri(address);

            MessageBufferClient client = MessageBufferClient.GetMessageBuffer(Credential, bufferAddress);

            return(client.GetPolicy());
        }
コード例 #3
0
        internal static bool BufferExists(Uri bufferAddress, TransportClientEndpointBehavior credential)
        {
            try
            {
                MessageBufferClient client = MessageBufferClient.GetMessageBuffer(credential, bufferAddress);
                MessageBufferPolicy policy = client.GetPolicy();
                if (policy.TransportProtection != TransportProtectionPolicy.AllPaths)
                {
                    throw new InvalidOperationException("Buffer must be configured for transport protection");
                }
                return(true);
            }
            catch (FaultException exception)
            {
                Debug.Assert(exception.Message == "Policy could not be retrieved: ContentType is incorrect");
            }

            return(false);
        }
コード例 #4
0
        void OnPurge(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Are you sure you want to remove all messages?", "Service Bus Explorer", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

            if (result == DialogResult.No)
            {
                return;
            }
            try
            {
                Uri address = new Uri(RealAddress.AbsoluteUri.Replace(@"sb://", @"https://"));

                MessageBufferClient client = MessageBufferClient.GetMessageBuffer(Credential, address);
                MessageBufferPolicy policy = client.GetPolicy();
                ApplyPolicy(policy);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error purging buffer: " + exception.Message, "Service Bus Explorer", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
        private MessageBufferClient GetOrCreateQueue(TransportClientEndpointBehavior sharedSecredServiceBusCredential,
                                                     Uri queueUri, ref MessageBufferPolicy queuePolicy)
        {
            MessageBufferClient client;

            try
            {
                client      = MessageBufferClient.GetMessageBuffer(sharedSecredServiceBusCredential, queueUri);
                queuePolicy = client.GetPolicy();
                Console.WriteLine("Message buffer already exists at '{0}'.", client.MessageBufferUri);

                return(client);
            }
            catch (FaultException e)
            {
                // Not found. Ignore and make a new queue below.
                // Other exceptions get bubbled up.
            }

            client      = MessageBufferClient.CreateMessageBuffer(sharedSecredServiceBusCredential, queueUri, queuePolicy);
            queuePolicy = client.GetPolicy();
            Console.WriteLine("Message buffer created at '{0}'.", client.MessageBufferUri);
            return(client);
        }