Esempio n. 1
0
      bool IsDirty(MessageBufferPolicy policy)
      {
         if(m_CountTextBox.Text != "")
         {
            if(Convert.ToInt32(m_CountTextBox.Text) != policy.MaxMessageCount)
            {
               return true;
            }
         }

         if(m_ExpirationTime.Text != policy.ExpiresAfter.TotalMinutes.ToString())
         {
            return true;
         }

         switch(m_OverflowComboBox.Text)
         {
            case "Reject":
            {
               if(policy.OverflowPolicy != OverflowPolicy.RejectIncomingMessage)
               {
                  return true;
               }
               break;
            }            
            default:
            {
               throw new InvalidOperationException("Unrecognized overflow value");
            }
         }
         return false;
      }
Esempio n. 2
0
      public NewBufferDialog(string serviceNamespace)
      {
         InitializeComponent();

         BaseAddress = ServiceBusEnvironment.CreateServiceUri("https",serviceNamespace,"").AbsoluteUri;
         if(BaseAddress.EndsWith(@"/") == false)
         {
            BaseAddress += @"/";
         }

         m_AddressTextBox.Text = BaseAddress;
         OnTextChanged(this,EventArgs.Empty);


         MessageBufferPolicy policy = new MessageBufferPolicy();

         m_ExpirationTime.Text = policy.ExpiresAfter.TotalMinutes.ToString();
         m_CountTextBox.Text = policy.MaxMessageCount.ToString();

         int overflowIndex = 0;
         switch(policy.OverflowPolicy)
         {
            case OverflowPolicy.RejectIncomingMessage:
            {
               overflowIndex = 0;
               break;
            }
            default:
            {
               throw new InvalidOperationException("Unrecognized overflow value");
            }
         }
         m_OverflowComboBox.Text = m_OverflowComboBox.Items[overflowIndex] as string;
      }
Esempio n. 3
0
 private static MessageBufferPolicy GetMessageBufferPolicy()
 {
     MessageBufferPolicy messageBufferPolicy = new MessageBufferPolicy()
     {
         ExpiresAfter = TimeSpan.FromMinutes(10d),
         MaxMessageCount = 1
     };
     return messageBufferPolicy;
 }
      static internal MessageBufferPolicy CreateBufferPolicy()
      {
         MessageBufferPolicy policy = new MessageBufferPolicy();                
         policy.Discoverability = DiscoverabilityPolicy.Public;
         policy.ExpiresAfter = TimeSpan.FromMinutes(10);
         policy.MaxMessageCount = 50;

         return policy;
      }
Esempio n. 5
0
      void OnCreate(object sender,EventArgs e)
      {
         Debug.Assert(m_AddressTextBox.Text != BaseAddress);

         MessageBufferPolicy policy = new MessageBufferPolicy();
         policy.Discoverability = DiscoverabilityPolicy.Public;

         if(m_CountTextBox.Text != "")
         {
            policy.MaxMessageCount = Convert.ToInt32(m_CountTextBox.Text);
         }

         if(m_ExpirationTime.Text != "")
         {
            policy.ExpiresAfter = TimeSpan.FromMinutes(Convert.ToInt32(m_ExpirationTime.Text));
         }

         switch(m_OverflowComboBox.Text)
         {
            case "Reject":
            {
               policy.OverflowPolicy = OverflowPolicy.RejectIncomingMessage;
               break;
            }     
            default:
            {
               throw new InvalidOperationException("Unknown overflow value");
            }            
         }
         if(m_AddressTextBox.Text.EndsWith(@"/") == false)
         {
            m_AddressTextBox.Text += @"/";
         }
         try
         {
            Client = MessageBufferClient.CreateMessageBuffer(Credential,new Uri(m_AddressTextBox.Text),policy);
         }
         catch(Exception exception)
         {
            MessageBox.Show("Unable to create buffer: " + exception.Message,"Service Bus Explorer",MessageBoxButtons.OK,MessageBoxIcon.Error);
            return;
         }

         Close();
      }
      static void CreateBuffer(string bufferAddress,MessageBufferPolicy policy,TransportClientEndpointBehavior credential)
      {
         if(bufferAddress.EndsWith("/") == false)
         {
            bufferAddress += "/";
         }         
         
         Uri address = new Uri(bufferAddress);

         if(BufferExists(address,credential))
         {
            MessageBufferClient client = MessageBufferClient.GetMessageBuffer(credential,address);
            client.DeleteMessageBuffer();
         }  
         MessageBufferClient.CreateMessageBuffer(credential,address,policy);
      }
Esempio n. 7
0
        private MessageBufferClient GetOrCreateQueue(TransportClientEndpointBehavior sharedSecredServiceBusCredential, Uri queueUri, ref MessageBufferPolicy queuePolicy)
        {
            MessageBufferClient client;

            try
            {
                client = MessageBufferClient.GetMessageBuffer(sharedSecredServiceBusCredential, queueUri);
                MessageBufferPolicy currentQueuePolicy = client.GetPolicy();
                queuePolicy = currentQueuePolicy;
                // Queue already exists.
                return(client);
            }
            //catch (EndpointNotFoundException)
            catch (FaultException)
            {
                // Exception when retrieving the current queue policy.
                // Queue Not found; absorb and make a new queue below.
                // Other exceptions get bubbled up.
            }
            catch (Exception)
            {
            }
            try
            {
                client = MessageBufferClient.CreateMessageBuffer(sharedSecredServiceBusCredential, queueUri, queuePolicy);
            }
            catch (Exception)
            {
                throw;
            }
            //Created new Queue.
            return(client);
        }
Esempio n. 8
0
        static void CreateBuffer(string bufferAddress, TransportClientEndpointBehavior credential)
        {
            MessageBufferPolicy policy = CreateBufferPolicy();

            CreateBuffer(bufferAddress, policy, credential);
        }
Esempio n. 9
0
      void OnUpdate(object sender,EventArgs e)
      {
         MessageBufferPolicy policy = new MessageBufferPolicy();
         policy.Discoverability = DiscoverabilityPolicy.Public;

         if(m_ExpirationTime.Text != "")
         {
            policy.ExpiresAfter = TimeSpan.FromMinutes(Convert.ToInt32(m_ExpirationTime.Text));
         }
         if(m_CountTextBox.Text != "")
         {
            policy.MaxMessageCount = Convert.ToInt32(m_CountTextBox.Text);
         }

         switch(m_OverflowComboBox.Text)
         {
            case "Reject":
            {
               policy.OverflowPolicy = OverflowPolicy.RejectIncomingMessage;
               break;
            }            
            default:
            {
               throw new InvalidOperationException("Unrecognized overflow value");
            }
         }
         ApplyPolicy(policy);  
      }
Esempio n. 10
0
      void OnReset(object sender,EventArgs e)
      {
         DialogResult result = MessageBox.Show("Are you sure you want to reset the buffer to it's default?","Service Bus Explorer",MessageBoxButtons.YesNo,MessageBoxIcon.Exclamation);
         if(result == DialogResult.No)
         {
            return;
         }
         MessageBufferPolicy policy = new MessageBufferPolicy();
         policy.Discoverability = DiscoverabilityPolicy.Public;

         ApplyPolicy(policy);  
      }
Esempio n. 11
0
      void ApplyPolicy(MessageBufferPolicy policy)
      {
         try
         {
            Uri address = new Uri(RealAddress.AbsoluteUri.Replace(@"sb://",@"https://"));

            MessageBufferClient client = MessageBufferClient.GetMessageBuffer(Credential,address);
            client.DeleteMessageBuffer();
            MessageBufferClient.CreateMessageBuffer(Credential,address,policy);
            Explore();
         }
         catch(Exception exception)
         {
            MessageBox.Show("Error applying change: " + exception.Message,"Service Bus Explorer",MessageBoxButtons.OK,MessageBoxIcon.Error);
         }
      }