You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2019/08/21 21:14:49 UTC

[GitHub] [pulsar] sijie commented on a change in pull request #4993: [Transaction] handle command send with transaction messages

sijie commented on a change in pull request #4993: [Transaction] handle command send with transaction messages
URL: https://github.com/apache/pulsar/pull/4993#discussion_r316404921
 
 

 ##########
 File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
 ##########
 @@ -1048,8 +1051,29 @@ protected void handleSend(CommandSend send, ByteBuf headersAndPayload) {
 
         startSendOperation();
 
-        // Persist the message
-        producer.publishMessage(send.getProducerId(), send.getSequenceId(), headersAndPayload, send.getNumMessages());
+        if (isTxn) {
+            final long txnIdMostBits = send.getTxnidMostBits();
+            final long txnIdLeastBits = send.getTxnidLeastBits();
+            final long sequenceId = send.getSequenceId();
+            final long producerId = send.getProducerId();
+            TxnID txnID = new TxnID(txnIdMostBits, txnIdLeastBits);
+            headersAndPayload.retain();
+            producer.getTopic()
+                    .getTxnBuffer(true)
+                    .thenCompose(txnBuffer ->
+                                     txnBuffer.appendBufferToTxn(txnID, sequenceId, headersAndPayload))
+                    .thenAccept(position ->
+                                   ctx.writeAndFlush(
+                                       Commands.newSendReceipt(producerId, sequenceId, ((PositionImpl)position).getLedgerId(), ((PositionImpl)position).getEntryId())))
+                    .exceptionally(err -> {
+                        log.warn("Send transaction [{}] message to transaction buffer failed, {}", txnID, err.getCause().getMessage());
+                        ctx.writeAndFlush(Commands.newSendError(producerId, sequenceId, ServerError.UnknownError, err.getCause().getMessage()));
 
 Review comment:
   why it is `UnknownError`?

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services