Skip to content

Commit

Permalink
Simplify Dapr Messaging interface
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Ciocanu committed Jul 25, 2024
1 parent 06e2a12 commit a126fe7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public interface DaprMessagingOperations<T> {
* @param topic the topic to send the message to or {@code null} to send to the
* default topic
* @param message the message to send
* @return the id assigned by the broker to the published message
*/
Void send(String topic, T message);
void send(String topic, T message);

/**
* Create a {@link SendMessageBuilder builder} for configuring and sending a message.
Expand Down Expand Up @@ -53,15 +52,13 @@ interface SendMessageBuilder<T> {

/**
* Send the message in a blocking manner using the configured specification.
*
* @return the id assigned by the broker to the published message
*/
Void send();
void send();

/**
* Uses the configured specification to send the message in a non-blocking manner.
*
* @return a future that holds the id assigned by the broker to the published message
* @return a Mono that completes when the message has been sent
*/
Mono<Void> sendAsync();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ public DaprMessagingTemplate(DaprClient daprClient, String pubsubName) {
}

@Override
public Void send(String topic, T message) {
return doSend(topic, message);
public void send(String topic, T message) {
doSend(topic, message);
}

@Override
public SendMessageBuilder<T> newMessage(T message) {
return new SendMessageBuilderImpl<>(this, message);
}

private Void doSend(String topic, T message) {
return doSendAsync(topic, message).block();
private void doSend(String topic, T message) {
doSendAsync(topic, message).block();
}

private Mono<Void> doSendAsync(String topic, T message) {
Expand Down Expand Up @@ -73,8 +73,8 @@ public SendMessageBuilder<T> withTopic(String topic) {


@Override
public Void send() {
return this.template.doSend(this.topic, this.message);
public void send() {
this.template.doSend(this.topic, this.message);
}

@Override
Expand Down

0 comments on commit a126fe7

Please sign in to comment.