So I'm currently trying to get a Azure Bus Service to work in which I create a Queue and then a message is put on the queue and then received else where, and some code is ran using the data the message passed through. I've got everything set up and working, as in I can send a message and received it, however with some issues. Whilst researching I've discovered what seems to be two different methodologies to completing the same task.
Firstly:
Create a message:
public static void CreateMessage(string data, [ServiceBus("QueueName")] out string output)
{
output = data;
}
Receive a Message:
public static void ProcessMessage([ServiceBusTrigger("QueueName")] string data)
{
//Do something with data
}
Note: I am trying to use this methodology and whilst a message is being received, data is null when received. Any help with this would be much appreciated.
Secondly:
Create a message:
var client = QueueClient.CreateFromConnectionString(connectionString, queueName);
var message = new BrokeredMessage("This is a test message!");
client.Send(message);
Receive a message:
var queueName = "QueueName";
var client = QueueClient.CreateFromConnectionString(connectionString, queueName);
client.OnMessage(message =>
{
//do something with data
});
So a couple of questions.
1.What is the difference in these two methodologies, and where should each be applied?
2.Whilst I'm using the first methodology to try and simply send a string, can anyone tell me why 'data' is coming through as null, even though the message is received.