File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
openmessaging-api/src/main/java/io/openmessaging/api Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ * Licensed to the Apache Software Foundation (ASF) under one or more
3
+ * contributor license agreements. See the NOTICE file distributed with
4
+ * this work for additional information regarding copyright ownership.
5
+ * The ASF licenses this file to You under the Apache License, Version 2.0
6
+ * (the "License"); you may not use this file except in compliance with
7
+ * the License. You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ package io .openmessaging .api ;
18
+
19
+ /**
20
+ * The result of sending a OMS prepare message, this result can be used to commits or or rollback a prepare message.
21
+ *
22
+ * @version OMS 2.0.1
23
+ * @since OMS 2.0.1
24
+ */
25
+ public abstract class TransactionalResult extends SendResult {
26
+
27
+ /**
28
+ * Commits a transaction.
29
+ */
30
+ public abstract void commit ();
31
+
32
+ /**
33
+ * Rolls back a transaction.
34
+ */
35
+ public abstract void rollback ();
36
+
37
+ }
Original file line number Diff line number Diff line change 20
20
import io .openmessaging .api .Admin ;
21
21
import io .openmessaging .api .Message ;
22
22
import io .openmessaging .api .SendResult ;
23
+ import io .openmessaging .api .TransactionalResult ;
23
24
24
25
/**
25
26
* Send transactional message.
@@ -46,4 +47,18 @@ public interface TransactionProducer extends Admin {
46
47
SendResult send (final Message message ,
47
48
final LocalTransactionExecuter localTransactionExecutor ,
48
49
final Object arg );
50
+
51
+ /**
52
+ * Sends a transactional message
53
+ * <p>
54
+ * A transactional send result will be exposed to consumer if this prepare message send success, and then, you can
55
+ * execute your local transaction, when local transaction execute success, users can use {@link
56
+ * TransactionalResult#commit()} to commit prepare message,otherwise can use {@link TransactionalResult#rollback()}
57
+ * to roll back this prepare message.
58
+ * </p>
59
+ *
60
+ * @param message a prepare transactional message will be sent.
61
+ * @return the successful {@code TransactionalResult}.
62
+ */
63
+ TransactionalResult prepare (Message message );
49
64
}
You can’t perform that action at this time.
0 commit comments