private BrokeredMessage SendToBrokeredMessageService(Microsoft.ServiceBus.Messaging.BrokeredMessage azureMessage) { var inputMessage = ConvertToMessage(azureMessage); var client = new BrokeredMessageServiceClient(Forwarder); return(client.Submit(inputMessage)); }
private BrokeredMessage ConvertToMessage(Microsoft.ServiceBus.Messaging.BrokeredMessage azureMessage) { var message = new BrokeredMessage { MessageType = azureMessage.Label }; var body = azureMessage.GetBody <Stream>(); var streamReader = new StreamReader(body); message.BodyJson = streamReader.ReadToEnd(); return(message); }
public object HandleRequestResponse(Microsoft.ServiceBus.Messaging.BrokeredMessage message) { if (message == null) { throw new ApplicationException("Message is null"); } var outputMessage = SendToBrokeredMessageService(message); return(GetResponseBodyAsStream(outputMessage)); }
private void Watcher_Changed(object sender, FileSystemEventArgs e) { var path = Path.Combine(filePath, watchedFile); Thread.Sleep(1000); using (var fileStream = new FileStream(path, FileMode.Open)) { var message = new Microsoft.ServiceBus.Messaging.BrokeredMessage(fileStream); message.Properties.Add("StatusConfiguration", true); azureTopicClient.Send(message); } }
static void Main(string[] args) { Console.WriteLine("Processing start"); var reader = new AzureMessageReader(); Microsoft.ServiceBus.Messaging.BrokeredMessage message = null; do { message = reader.RecieveNextMessage(); if (message != null) { Console.WriteLine(reader.LastResult.GetType().Name + ": " + reader.LastResult.ToString()); } } while (true); }
static void Main(string[] args) { string connString = string.Format("Endpoint=sb://{0}.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey={1}", SB_NAMESPACE, SB_KEY); createQueue(connString); var client = Microsoft.ServiceBus.Messaging.QueueClient.CreateFromConnectionString(connString, QUEUE_NAME); var message = new Microsoft.ServiceBus.Messaging.BrokeredMessage(); message.Properties.Add("CustomProperty", "Value1"); message.Properties.Add("CustomProperty2", "Value2"); client.Send(message); }
private static void SendMessage(string message, string queueName) { var client = Microsoft.ServiceBus.Messaging.QueueClient.Create(queueName); //using fully qualified namespace so you can see where it resides var brokeredMessage = new Microsoft.ServiceBus.Messaging.BrokeredMessage(message); //using fully qualified namespace so you can see where it resides try { client.Send(brokeredMessage); } catch (Microsoft.ServiceBus.Messaging.MessagingException e) //using fully qualified namespace so you can see where it resides { if (!e.IsTransient) //indicates whethere you should retry or not = along the lines of network issues. { Console.WriteLine(e.Message); throw; } else { //HandleTransientErrors(e); } } }