kandersen82 commented on code in PR #109:
URL: https://github.com/apache/pulsar-dotpulsar/pull/109#discussion_r1018336836


##########
src/DotPulsar/Internal/Producer.cs:
##########
@@ -259,37 +283,74 @@ public async ValueTask<MessageId> Send(MessageMetadata 
metadata, TMessage messag
         try
         {
             var partition = await ChoosePartitions(metadata, 
cancellationToken).ConfigureAwait(false);
-            var producer = _producers[partition];
+            var subProducer = _producers[partition];
             var data = _options.Schema.Encode(message);
 
-            var messageId = await producer.Send(metadata.Metadata, data, 
cancellationToken).ConfigureAwait(false);
-
-            if (startTimestamp != 0)
-                DotPulsarMeter.MessageSent(startTimestamp, _meterTags);
+            var tcs = new TaskCompletionSource<MessageId>();
+            await subProducer.Send(new SendOp(metadata.Metadata, data, tcs, 
sendOpCancelable ? cancellationToken : CancellationToken.None), 
cancellationToken).ConfigureAwait(false);
 
-            if (activity is not null && activity.IsAllDataRequested)
+            _ = tcs.Task.ContinueWith(async task =>
             {
-                activity.SetMessageId(messageId);
-                activity.SetPayloadSize(data.Length);
-                activity.SetStatus(ActivityStatusCode.Ok);
-            }
+                if (startTimestamp != 0)
+                    DotPulsarMeter.MessageSent(startTimestamp, _meterTags);
+
+                if (task.IsFaulted || task.IsCanceled)
+                {
+                    FailActivity(task.IsCanceled ? new 
OperationCanceledException() : task.Exception!, activity);
+
+                    if (autoAssignSequenceId)
+                        metadata.SequenceId = 0;
+                }
 
-            return messageId;
+                CompleteActivity(task.Result, data.Length, activity);
+                try
+                {
+                    if (onMessageSent is not null)
+                        await 
onMessageSent.Invoke(task.Result).ConfigureAwait(false);

Review Comment:
   I am not exactly sure what you mean?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to