File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
pulsar-client-api/src/main/java/org/apache/pulsar/client/api
pulsar-client/src/main/java/org/apache/pulsar/client/impl Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,21 @@ public interface Producer<T> extends Closeable {
132132 * @since 2.7.0
133133 */
134134 TypedMessageBuilder <T > newMessage (Transaction txn );
135+
136+ /**
137+ * Create a new message builder with transaction and schema, not required same parameterized type with the
138+ * producer.
139+ *
140+ * <p>After the transaction commit, it will be made visible to consumer.
141+ *
142+ * <p>After the transaction abort, it will never be visible to consumer.
143+ *
144+ * @return a typed message builder that can be used to construct the message to be sent through this producer
145+ * @see #newMessage()
146+ */
147+ <V > TypedMessageBuilder <V > newMessage (Schema <V > schema ,
148+ Transaction txn );
149+
135150 /**
136151 * Get the last sequence id that was published by this producer.
137152 *
Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ public TypedMessageBuilder<T> newMessage() {
7979 return new TypedMessageBuilderImpl <>(this , schema );
8080 }
8181
82+ @ Override
8283 public <V > TypedMessageBuilder <V > newMessage (Schema <V > schema ) {
8384 checkArgument (schema != null );
8485 return new TypedMessageBuilderImpl <>(this , schema );
@@ -92,6 +93,14 @@ public TypedMessageBuilder<T> newMessage(Transaction txn) {
9293 return new TypedMessageBuilderImpl <>(this , schema , (TransactionImpl ) txn );
9394 }
9495
96+ @ Override
97+ public <V > TypedMessageBuilder <V > newMessage (Schema <V > schema ,
98+ Transaction txn ) {
99+ checkArgument (txn instanceof TransactionImpl );
100+ checkArgument (schema != null );
101+ return new TypedMessageBuilderImpl <>(this , schema , (TransactionImpl ) txn );
102+ }
103+
95104 abstract CompletableFuture <MessageId > internalSendAsync (Message <?> message );
96105
97106 abstract CompletableFuture <MessageId > internalSendWithTxnAsync (Message <?> message , Transaction txn );
You can’t perform that action at this time.
0 commit comments