private async Task <ValidationResult> ValidateInput(string queueName, bool checkIfQueueExists) { //Validate input - Check if queueName is provided if (string.IsNullOrWhiteSpace(queueName)) { return new ValidationResult { IsValid = false, HttpResult = Request.CreateResponse(HttpStatusCode.BadRequest, "The parameter 'queueName' is mandatory") } } ; //Validate input - Check if queue exists if (checkIfQueueExists) { var serviceBusQueueClient = new ServiceBusQueueClient(_serviceBusConnString, queueName); if (await serviceBusQueueClient.QueueExists() == false) { return new ValidationResult { IsValid = false, HttpResult = Request.CreateResponse(HttpStatusCode.BadRequest, String.Format("The queue '{0}' does not exist", queueName)) } } ; } return(new ValidationResult { IsValid = true, HttpResult = Request.CreateResponse(HttpStatusCode.Accepted) }); } } }
public virtual void Dispose() { Host.Stop(); Host.Dispose(); ServiceBusQueueClient.Close(); DocumentClient?.Dispose(); }
public void Setup() { var settings = new ServiceBusSettings() { ConnectionString = "DevelopmentMode=true", QueueName = "booking" }; _client = new ServiceBusQueueClient(Options.Create <ServiceBusSettings>(settings)); }
public async Task GetMessageCount() { ServiceBusQueueClient client = new ServiceBusQueueClient(connectionString); var messages = await client.GetMessageCountAsync(queueName); Assert.AreEqual(messages >= 0, true); Trace.WriteLine(messages); }
public override void Dispose() { // host should already be stopped from test try { Host.Stop(); } catch { } Host.Dispose(); ServiceBusQueueClient.Close(); }
public async void ShouldSendMessage() { var client = new ServiceBusQueueClient(new QueueClientConfiguration { ConnectionString = "Endpoint=sb://sbplaylistmanager.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=yD/JLATqZXAaZcPoMWMCtdBf+0Bn/wRx/tFl2OWCZOI=", QueueName = "jobs" }); await client.EnqueueManagementJob(new ExecuteManagementJobCommand { ManagementJobId = Guid.Parse("0785932f-0e76-4ef8-8e68-bb54b2b94872") }); }
public async Task <HttpResponseMessage> CompleteMessage([FromUri] string queueName, [FromUri] string lockToken) { //Validate input var inputValidationResult = await ValidateInput(queueName, lockToken); if (inputValidationResult.IsValid == false) { return(inputValidationResult.HttpResult); } //Complete message var serviceBusQueueClient = new ServiceBusQueueClient(_serviceBusConnString, queueName); await serviceBusQueueClient.CompleteMessage(lockToken); return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task <HttpResponseMessage> GetQueueMessageCount([FromUri] string queueName) { //Validate input var inputValidationResult = await ValidateInput(queueName, true); if (inputValidationResult.IsValid == false) { return(inputValidationResult.HttpResult); } //Get and return message count var serviceBusQueueClient = new ServiceBusQueueClient(_serviceBusConnString, queueName); var messageCount = await serviceBusQueueClient.GetMessageCount(); return(Request.CreateResponse(HttpStatusCode.OK, new QueueMessageCount { messageCount = messageCount, queueName = queueName })); }
public void Dispose() { Host.Stop(); Host.Dispose(); ServiceBusQueueClient.Close(); }
public ServiceBusClaimCheckClient(string blobStorageConnString, string blobStorageContainerName, string serviceBusConnString, string queueName) { _claimCheckProvider = new BlobStorageClaimCheckProvider(blobStorageConnString, blobStorageContainerName); _serviceBusQueueClient = new ServiceBusQueueClient(serviceBusConnString, queueName); }