-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timestamp: invalid argument #49
Comments
We will look into it
[Lior Nabat - Chat @ Spike](https://spikenow.com/r/a/?ref=spike-organic-signature&_ts=1y5bdb) [1y5bdb]
On February 13, 2023 at 14:47 GMT, Alessandro1996 ***@***.***> wrote:
I'm using kubemq to communicate with other projects, using the CQRS pattern. My project's language is Python, the other projects' language is Java.
The problem I encountered happens when I receive a response of a query and process it by means of kubemq-Python libary, while the response is built using kubemq-Java library.
Here is the error traceback:
Grpc Exception in send_request:'[Errno 22] Invalid argument' Traceback (most recent call last): File "project\venv\lib\site-packages\kubemq\commandquery\lowlevel\initiator.py", line 68, in send_request return Response(inner_response) File "project\venv\lib\site-packages\kubemq\commandquery\response.py", line 60, in __init__ self.timestamp = datetime.fromtimestamp(request.Timestamp) OSError: [Errno 22] Invalid argument
Reproduction steps
- [Java] Code a "handler", which simply echoes any message body of the incoming queries
- [Java] Subscribe to a "query channel", passing the "handler";
- [Python] Write a "message body", encoded in UTF-8
- [Python] Invoke a "send_request" with resquest="message body" and channel="query channel"
- [Java] Automatically execute the "handler", sending the "Response"
- [Python] Receive the "Response" <--- Here comes the error, while parsing the timestamp of the message
Source of error
By debugging, the source is found to be in the different way of setting the timestamp, which defers between Java and Python library. The incompatibility can be seen in the following snippets (came from the cited libraries): Java works with timestamps in milliseconds, while Python works with timestamps in seconds
Java code in kubemq-java-sdk/src/main/java/io/kubemq/sdk/commandquery/Response.java
Kubemq.Response Convert() { return Kubemq.Response.newBuilder() .setClientID(Optional.ofNullable(clientID).orElse("")) .setRequestID(requestID) .setReplyChannel(replyChannel) .setMetadata(Optional.ofNullable(metadata).orElse("")) .setBody(ByteString.copyFrom(body)) .setCacheHit(cacheHit) .setTimestamp(Converter.ToUnixTime(timestamp)) <------------------------------- .setExecuted(executed) .setError(Optional.ofNullable(error).orElse("")) .putAllTags(Optional.ofNullable(tags).orElse(new HashMap<String,String>())) .build(); }
where Converter.ToUnixTime(timestamp) is in kubemq-java-sdk/src/main/java/io/kubemq/sdk/tools/Converter.java
public static long ToUnixTime(LocalDateTime timestamp) { return timestamp.atZone(TimeZone.getDefault().toZoneId()).toInstant().toEpochMilli(); }
Python code in kubemq/commandquery/response.py
def convert(self): return InnerResponse( ClientID=self.client_id or "", RequestID=self.request_id, ReplyChannel=self.reply_channel, Metadata=self.metadata or "", Body=self.body, CacheHit=self.cache_hit, Timestamp=int((self.timestamp - epoch).total_seconds()), <------------------------------- Executed=self.executed, Error=self.error )
—
Reply to this email directly, [view it on GitHub](#49), or [unsubscribe](https://github.com/notifications/unsubscribe-auth/AK5WGXHR4NQJF4GM6XC6FXTWXJCP7ANCNFSM6AAAAAAU2LM4LQ).
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm using kubemq to communicate with other projects, using the CQRS pattern. My project's language is Python, the other projects' language is Java.
The problem I encountered happens when I receive a response of a query and process it by means of kubemq-Python libary, while the response is built using kubemq-Java library.
Here is the error traceback:
Reproduction steps
Source of error
By debugging, the source is found to be in the different way of setting the timestamp, which defers between Java and Python library. The incompatibility can be seen in the following snippets (came from the cited libraries): Java works with timestamps in milliseconds, while Python works with timestamps in seconds
Java code in
kubemq-java-sdk/src/main/java/io/kubemq/sdk/commandquery/Response.java
where
Converter.ToUnixTime(timestamp)
is inkubemq-java-sdk/src/main/java/io/kubemq/sdk/tools/Converter.java
Python code in
kubemq/commandquery/response.py
The text was updated successfully, but these errors were encountered: