Skip to content

Commit 7d13105

Browse files
authored
Merge pull request #73 from dbl-x/feat_support_schema
move messageBuilder method to ProducerBase
2 parents 5f9889d + b5f0454 commit 7d13105

4 files changed

Lines changed: 42 additions & 33 deletions

File tree

openmessaging-api/src/main/java/io/openmessaging/api/Producer.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
* @version OMS 1.2.0
4242
* @since OMS 1.2.0
4343
*/
44-
public interface Producer extends Admin {
44+
public interface Producer extends ProducerBase, Admin {
4545

4646
/**
4747
* Sends a message to the specified destination synchronously, the destination should be preset to {@link
@@ -84,12 +84,4 @@ public interface Producer extends Admin {
8484
* @param callbackExecutor
8585
*/
8686
void setCallbackExecutor(final ExecutorService callbackExecutor);
87-
88-
/**
89-
* Create message builder, used for build message in a fluent way.
90-
*
91-
* @param <T>
92-
* @return
93-
*/
94-
<T> MessageBuilder<T> messageBuilder();
9587
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
* {@code ProducerBase} is the basic of other {@code Producer} interfaces
21+
* and is used to define some common methods.
22+
*
23+
* @version OMS 2.0.3
24+
* @since OMS 2.0.3
25+
*/
26+
public interface ProducerBase {
27+
28+
/**
29+
* Create message builder, used for build message in a fluent way.
30+
*
31+
* @param <T> the class of message's payload
32+
* @return MessageBuilder
33+
*/
34+
<T> MessageBuilder<T> messageBuilder();
35+
}

openmessaging-api/src/main/java/io/openmessaging/api/order/OrderProducer.java

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import io.openmessaging.api.Admin;
2121
import io.openmessaging.api.Message;
22-
import io.openmessaging.api.MessageBuilder;
22+
import io.openmessaging.api.ProducerBase;
2323
import io.openmessaging.api.SendResult;
2424

2525
/**
@@ -28,7 +28,7 @@
2828
* @version OMS 1.2.0
2929
* @since OMS 1.2.0
3030
*/
31-
public interface OrderProducer extends Admin {
31+
public interface OrderProducer extends ProducerBase, Admin {
3232

3333
/**
3434
* Send message in order
@@ -39,13 +39,4 @@ public interface OrderProducer extends Admin {
3939
* @return {@link SendResult} Message delivery result, including message Id.
4040
*/
4141
SendResult send(final Message message, final String shardingKey);
42-
43-
44-
/**
45-
* Create message builder, used for build message in a fluent way.
46-
*
47-
* @param <T>
48-
* @return
49-
*/
50-
<T> MessageBuilder<T> messageBuilder();
5142
}

openmessaging-api/src/main/java/io/openmessaging/api/transaction/TransactionProducer.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
import io.openmessaging.api.Admin;
2121
import io.openmessaging.api.Message;
22-
import io.openmessaging.api.MessageBuilder;
22+
import io.openmessaging.api.ProducerBase;
2323
import io.openmessaging.api.SendResult;
2424
import io.openmessaging.api.TransactionalResult;
2525

@@ -29,7 +29,7 @@
2929
* @version OMS 1.2.0
3030
* @since OMS 1.2.0
3131
*/
32-
public interface TransactionProducer extends Admin {
32+
public interface TransactionProducer extends ProducerBase, Admin {
3333

3434
/**
3535
* This method is used to send a transactional message. A transactional message is sent in three steps:
@@ -46,17 +46,8 @@ public interface TransactionProducer extends Admin {
4646
* @return Send result
4747
*/
4848
SendResult send(final Message message,
49-
final LocalTransactionExecuter localTransactionExecutor,
50-
final Object arg);
51-
52-
53-
/**
54-
* Create message builder, used for build message in a fluent way.
55-
*
56-
* @param <T>
57-
* @return
58-
*/
59-
<T> MessageBuilder<T> messageBuilder();
49+
final LocalTransactionExecuter localTransactionExecutor,
50+
final Object arg);
6051

6152
/**
6253
* Sends a transactional message

0 commit comments

Comments
 (0)