question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Long values are not sent correctly with PubSub

See original GitHub issue

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:

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
mukundansundarcommented, Mar 21, 2022

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.

1reaction
mukundansundarcommented, Mar 22, 2022

@tanvigour Can probably finish this once https://github.com/dapr/dapr/pull/4409 is merged …

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle message failures | Cloud Pub/Sub
This page explains how to handle such processing failures by using a subscription retry policy or by forwarding undelivered messages to a dead-letter...
Read more >
Not Receiving Proper Subscription Messages from Pub/Sub
This one took far to long to figure out, and the solution turned out to be quite simple. I was surprised that for...
Read more >
Amazon Simple Notification Service (SNS) FAQs
Q: What happens to Amazon SNS messages if the subscribing endpoint is not available? If a message cannot be successfully delivered on the...
Read more >
Google Cloud Pub/Sub Reliability User Guide: Part 1 Publishing
This might happen due to a network issue between your application and the Pub/Sub service or a regional outage of Pub/Sub. The issue...
Read more >
Google Cloud Pub/Sub - Asynchronous Messaging
Message not acknowledged before the deadline is sent again. ... Message retention duration specifies how long Pub/Sub retains messages after ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found