Skip to content

Long values are not sent correctly with PubSub #686

Description

@yschneider-bosch

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:

Activity

  1. modified the milestones: v1.6, v1.5 on Feb 16, 2022
  2. tanvigour commented on Mar 10, 2022

    @tanvigour
    Contributor

    /assign

  3. mukundansundar commented on Mar 21, 2022

    @mukundansundar
    Contributor

    I think this might be related to dapr/dapr#3837.

  4. shubham1172 commented on Mar 21, 2022

    @shubham1172
    Member
  5. mukundansundar commented on Mar 21, 2022

    @mukundansundar
    Contributor

    I think we need to add a simple test in the IT suite for pubsub to test for this scenario and create a PR for the same here. So that once the fix is merged in dapr, we can verify it is also fixed via the SDK.

  6. tanvigour commented on Mar 21, 2022

    @tanvigour
    Contributor

    Thanks @mukundansundar I'll add the test for this in pubsub and create a PR. Any estimate on when this fix will be merged?

  7. shubham1172 commented on Mar 21, 2022

    @shubham1172
    Member

    @tanvigour we are targeting it for v1.7

  8. mukundansundar commented on Mar 21, 2022

    @mukundansundar
    Contributor

    @tanvigour The fix was merged few minutes back in components-contrib .... This needs to be picked up in runtime.

  9. mukundansundar commented on Mar 22, 2022

    @mukundansundar
    Contributor

    @tanvigour Can probably finish this once dapr/dapr#4409 is merged ....

  10. tanvigour commented on Mar 22, 2022

    @tanvigour
    Contributor

    yes! keeping an eye on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions