Skip to content
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

nsqd: defer is not working as expected #1433

Open
cychub opened this issue Dec 13, 2022 · 1 comment
Open

nsqd: defer is not working as expected #1433

cychub opened this issue Dec 13, 2022 · 1 comment

Comments

@cychub
Copy link

cychub commented Dec 13, 2022

Based on the document, we only need pass defer parameter in ms to achieve message delay delivery.
https://nsq.io/components/nsqd.html#post-pub

  • consumer
const nsq = require('nsqjs')
const moment = require('moment')

// reader
const reader = new nsq.Reader('sample_topic', 'sample_topic', {
  lookupdHTTPAddresses: 'nsqlookupd:4161'
})

reader.connect()

reader.on('message', msg => {
  console.log('Received message [%s] [%s]: %s', moment.utc().format('YYYY-MM-DD HH:mm:ss:SSS'), msg.id, msg.body.toString())
  setTimeout(() => {
    msg.finish()
  }, 1000)
});

pre-request part, will generate the current time in ms.

var moment = require('moment');
var date = moment.utc().format('YYYY-MM-DD HH:mm:ss:SSS');
pm.environment.set("now", date);

in the request

{
    "text": "some message",
    "message  ": [{{now}}]
}
  • output
nsq-demo-client-1      | Received message [2022-12-13 14:37:15:684] [11bc612bb5c88000]: {
nsq-demo-client-1      |     "text": "some message",
nsq-demo-client-1      |     "message  ": [2022-12-13 14:37:12:336]
nsq-demo-client-1      | }

expect
the Received message should be 5 seconds later comparing with the timestamp in the message body.

actual
the Received message is always within the defer ms.

@mreiferson
Copy link
Member

Going to need the nsqd logs with --log-level=debug enabled to debug.

@mreiferson mreiferson changed the title defer is not working as expected nsqd: defer is not working as expected Dec 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants