In what area(s)?
/area runtime
What version of Dapr?
1..5.0
Expected Behavior
Events with Long values are sent and received correctly.
Actual Behavior
Large long values are slightly different when received by the consumer. For example when the value 590518626939830271 is sent, the event received by the consumer has the value 590518626939830300.
Steps to Reproduce the Problem
The pubsub example was adjusted to demonstrate this issue:
Publisher.java
...
/**
* This is the entry point of the publisher app example.
* @param args Args, unused.
* @throws Exception A startup Exception.
*/
public static void main(String[] args) throws Exception {
try (DaprClient client = new DaprClientBuilder().build()) {
for (int i = 0; i < NUM_MESSAGES; i++) {
String message = String.format("This is message #%d", i);
//Publishing messages
client.publishEvent(
PUBSUB_NAME,
TOPIC_NAME,
new WithLong(590518626939830271L),
singletonMap(Metadata.TTL_IN_SECONDS, MESSAGE_TTL_IN_SECONDS)).block();
System.out.println("Published message: " + message);
try {
Thread.sleep((long) (1000 * Math.random()));
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
return;
}
}
// This is an example, so for simplicity we are just exiting here.
// Normally a dapr app would be a web service and not exit main.
System.out.println("Done.");
}
}
WithLong.java
package io.dapr.examples.pubsub.http;
public class WithLong {
public Long value;
public WithLong(Long value) {
this.value = value;
}
public WithLong() {
}
}
SubscriberController.java
...
/**
* Handles a registered publish endpoint on this app.
* @param cloudEvent The cloud event received.
* @return A message containing the time.
*/
@Topic(name = "testingtopic", pubsubName = "${myAppProperty:messagebus}")
@PostMapping(path = "/testingtopic")
public Mono<Void> handleMessage(@RequestBody(required = false) CloudEvent<WithLong> cloudEvent) {
return Mono.fromRunnable(() -> {
try {
System.out.println("Subscriber got: " + cloudEvent.getData());
System.out.println("Subscriber got: " + cloudEvent.getData().value);
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
...
Results when running the modified example:
INFO[0004] dapr initialized. Status: Running. Init Elapsed 4536.042ms app_id=subscriber instance=MacBook-Pro-von-Yoav.local scope=dapr.runtime type=log ver=1.6.0
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@644c09e5
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@1a0d2d33
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@932cc54
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@206ed09f
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@1c216f73
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@7b64ed98
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@4ef7c13c
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@793a10ba
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@178d181a
== APP == Subscriber got: 590518626939830300
== APP == Subscriber got: io.dapr.examples.pubsub.http.WithLong@6920325d
== APP == Subscriber got: 590518626939830300
Release Note
RELEASE NOTE:
In what area(s)?
What version of Dapr?
1..5.0
Expected Behavior
Events with Long values are sent and received correctly.
Actual Behavior
Large long values are slightly different when received by the consumer. For example when the value 590518626939830271 is sent, the event received by the consumer has the value 590518626939830300.
Steps to Reproduce the Problem
The pubsub example was adjusted to demonstrate this issue:
Publisher.java
WithLong.java
SubscriberController.java
Results when running the modified example:
Release Note
RELEASE NOTE: