Reputation: 119
I have a weird issue happening once I install my azure C# functions in the portal.
Currently, I have a consumption plan with 3 C# functions in it. Each of the functions reacts to a service bus queue trigger, each having its own queue.
The first functions read from its queue and then sends 1 message to the next function. I can currently see only one message in the next queue if I disable the function on the portal.
The second function reads the message from the queue and then starts processing it. It then logs completed, but a second instance of the same message is then read from the queue and the function tries to process that.
The log from the second function reading the first message is:
2018-10-24T02:52:58.562 [Info] Function started (Id=fae4c5a0-5df5-47dd-ae8e-76784bc0405e) 2018-10-24T02:52:58.562 [Info] 2018-10-24 02:52:58.562 +00:00 [Information] Push Processor - trackingid:
b0cdd010-2301-4fa2-9da8-731dd795e145
- noticeid:201276
- received for processing on enqueuedatetc:10/24/2018 2:52:58 AM
with sequenceNumber:36
, deliverycount:1
That call then ends with log:
2018-10-24T02:52:59.406 [Info] Function completed (Success, Id=fae4c5a0-5df5-47dd-ae8e-76784bc0405e, Duration=842ms)
But then the same message is read again:
2018-10-24T02:52:59.214 [Info] Function started (Id=f1d364da-e7be-4e66-b300-4211d7941a2a) 2018-10-24T02:52:59.245 [Info] 2018-10-24 02:52:59.234 +00:00 [Information] Processor - trackingid:
b0cdd010-2301-4fa2-9da8-731dd795e145
- id:201276
- received for processing on enqueuedatetc:10/24/2018 2:52:59 AM
with sequenceNumber:37
, deliverycount:1
What I can see is that the sequence number is diff for the same message, even though the queue displays only one message and only one message was sent to the queue.
The last call log for this is then:
2018-10-24T02:52:59.417 [Info] Function completed (Success, Id=f1d364da-e7be-4e66-b300-4211d7941a2a, Duration=195ms)
Actions taken:
We run .net 4.7 using the service bus nuget Microsoft.Azure.WebJobs.ServiceBus 2.2.0
for all C# functions.
Adding something to the queue:
var brokeredQueueMessage = new BrokeredMessage(message);
await QueueClient.Value.SendAsync(brokeredQueueMessage);
Function run method:
[FunctionName("Processor")]
public static async Task Run(
[ServiceBusTrigger("processorqueue-dev", AccessRights.Manage, Connection = "ServiceBusConnection")]
BrokeredMessage myQueueItem,
TraceWriter log)
{
It would perhaps seem that it has to do with when the second function sends messages to another third queue for processing by third function. At this stage I haven't deployed the third function yet.
It does make use of a batching static function to send to queue async. It does use the BatchSendAsync:
await messageSender.SendBatchAsync(batchList);
If the secodn functions doesn't have any messages to send, it doesn't seem to be running twice.
Upvotes: 1
Views: 2700
Reputation: 1494
Sequence number is a unique 64-bit integer assigned to a message when ever a message is en-queued into a Service Bus Queue. There is no possibility that a same message can have two different sequence numbers.
Message Id is not unique and you can set same Message Id for multiple messages.
What I can see is, duplicate messages may be sent to the Second Queue. Please check whether same message is sent to the second Queue multiple times from the functions.
Code sample of first and second function will be helpful for providing more insights.
You can also check for the Incoming messages metric to determine the total number of messages sent to the Queue.
Upvotes: 2