Skip to content

[FS] Frame not being read correctly #170

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

Closed
jenkoian opened this issue Aug 16, 2017 · 7 comments · Fixed by #181
Closed

[FS] Frame not being read correctly #170

jenkoian opened this issue Aug 16, 2017 · 7 comments · Fixed by #181
Labels

Comments

@jenkoian
Copy link
Contributor

jenkoian commented Aug 16, 2017

Not sure if this is a bug or if I've done something not quite right, but I get the following error when certain messages are attempted to be consumed:

[LogicException]
  Cannot decode json message 'JSON HERE'

Digging into it, the frames seem to be getting split between a | and a { meaning the following isn't getting hit and thus the message isn't read from the file correctly.

https://github.com/php-enqueue/enqueue-dev/blob/master/pkg/fs/FsConsumer.php#L172

Is there a reason 64 was chosen? Was it just a random number and I've been desperately unlucky?

@makasim
Copy link
Member

makasim commented Aug 16, 2017

Just a random number, The message extraction logic is much much simpler if the message length is predictable

@makasim
Copy link
Member

makasim commented Aug 16, 2017

I've never run into this but it could still be a bug.

@makasim makasim added the bug label Aug 16, 2017
@jenkoian
Copy link
Contributor Author

Can confirm that if I change my message by a few characters it works as expected, so guess I was just unlucky, but yeah sounds like a bug.

@makasim
Copy link
Member

makasim commented Aug 16, 2017

Could you post a message that causes it?

@jenkoian
Copy link
Contributor Author

This is the one I was running into issues with, changed ids to x's but kept the length the same. If you change unsubscribe to unscribe it then works ok.

{
	"body": "{\"consumerId\":\"user:xxxxxx\",\"producerId\":\"user:xxxxxx\",\"type\":\"unsubscribe\"}",
	"properties": {
		"enqueue.topic_name": "__command__",
		"enqueue.command_name": "updateConsumerNetwork",
		"enqueue.processor_name": "enqueue.client.router_processor",
		"enqueue.processor_queue_name": "default"
	},
	"headers": {
		"content_type": "text\/plain",
		"message_id": "9cb6dcb9-8b6c-402a-ae61-3cd6b321c150",
		"timestamp": 1502689812,
		"reply_to": null,
		"correlation_id": ""
	}
}

@jenkoian
Copy link
Contributor Author

jenkoian commented Aug 18, 2017

What about a new file for each message? I think that's what bernard does but haven't had time to look into properly https://github.com/bernardphp/bernard/blob/master/src/Driver/FlatFileDriver.php

@makasim
Copy link
Member

makasim commented Aug 28, 2017

It failed on message size equal to 24. the queue must not be empty

$producer->send($queue, $context->createMessage(str_repeat('a', 23)));
$producer->send($queue, $context->createMessage(str_repeat('a', 24)));
Received: a
Sent: 2
Received: aa
Sent: 3
Received: aaa
Sent: 4
Received: aaaa
Sent: 5
Received: aaaaa
Sent: 6
Received: aaaaaa
Sent: 7
Received: aaaaaaa
Sent: 8
Received: aaaaaaaa
Sent: 9
Received: aaaaaaaaa
Sent: 10
Received: aaaaaaaaaa
Sent: 11
Received: aaaaaaaaaaa
Sent: 12
Received: aaaaaaaaaaaa
Sent: 13
Received: aaaaaaaaaaaaa
Sent: 14
Received: aaaaaaaaaaaaaa
Sent: 15
Received: aaaaaaaaaaaaaaa
Sent: 16
Received: aaaaaaaaaaaaaaaa
Sent: 17
Received: aaaaaaaaaaaaaaaaa
Sent: 18
Received: aaaaaaaaaaaaaaaaaa
Sent: 19
Received: aaaaaaaaaaaaaaaaaaa
Sent: 20
Received: aaaaaaaaaaaaaaaaaaaa
Sent: 21
Received: aaaaaaaaaaaaaaaaaaaaa
Sent: 22
Received: aaaaaaaaaaaaaaaaaaaaaa
Sent: 23
Received: aaaaaaaaaaaaaaaaaaaaaaa
Sent: 24


Time: 12.19 seconds, Memory: 4.00MB

There was 1 error:

1) Enqueue\Fs\Tests\Spec\FsSendAndReceiveTimeToLiveMessagesFromQueueTest::test
LogicException: Cannot decode json message '{"body":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa","properties":[],"headers":[]}                                                                                                                               |{"body":"aaaaaaaaaaaaaaaaaaaaaaaa","properties":[],"headers":[]}'

/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/FsConsumer.php:101
/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/FsContext.php:119
/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/FsConsumer.php:109
/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php:27

Caused by
InvalidArgumentException: The malformed json given. Error 4 and message Syntax error

/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/FsMessage.php:225
/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/FsConsumer.php:92
/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/FsContext.php:119
/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/FsConsumer.php:109
/Users/makasim/projects/enqueue/enqueue-sandbox/dev/pkg/fs/Tests/Spec/FsSendAndReceiveTimeToLiveMessagesFromQueueTest.php:27

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants