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
worker监听消息需要添加消息类型判断 worker monitoring message needs to add message type judgment #72
Comments
Sorry, but I am not sure I understand what you mean. As far as I understood, you are suggesting to add a message type check because the worker can be run by many threads. If that is true, then a message type check is already done statically. Runtime checks are not required. By convention, all the workers are forked from one place and by one handler. It's the WorkerRunner. The WorkerRunner has the following requirements: export class WorkerRunner<
WorkerParameters extends TWorkerParameters = TWorkerParameters,
> extends EventEmitter {
constructor(
redisClient: RedisClient,
workersDir: string,
keyLock: string,
workerParameters: WorkerParameters,
workerPool?: WorkerPool,
) {
// ...
}
} So the parameters we pass to WorkerRunner should be of the When the consumer creates the WorkerRunner instance it specifies this.workerRunner = new WorkerRunner<IConsumerWorkerParameters>(...) The DelayWorker subprocess receives the message and expect it to be of process.on('message', (payload: string) => {
const params: IConsumerWorkerParameters = JSON.parse(payload);
setConfiguration(params.config);
RedisClient.getNewInstance((err, client) => {
if (err) throw err;
else if (!client) throw new EmptyCallbackReplyError();
else new DelayWorker(client, params, false).run();
});
}); The workers are NOT supposed to be run by a RedisSMQ client directly. They are internal parts of the library and by no means you should use them in your application. Adding to that, I fear that you are wrongly using this library and I am surprised by this screenshot: How did you get that!? If you are having an issue please show me a full example of your code so we can discuss it. |
better provide code for re-produce. |
是因为worker收到了其他主线程发送的消息,并不是redis-smq的线程,而是Egg框架的线程发送的,所以需要判断来源 |
Please provide a full example. |
当使用子进程运行redis-smq时,process监听到的message就会收到主进程发送的消息,进行一个类型安全的判断是必要的,因为会受到其他线程发送的消息污染 |
Thank you. Now I see what you are talking about. I haven't used the Egg framework before. So RedisSMQ workers may catch messages from the main process sent by Egg framework. This issue will be fixed ASAP. |
OK,我不太了解Egg框架的源码,所以不能提供代码示例给你,抱歉 |
As I said before |
This issue has been fixed in v6.2.1 |
Closing as resolved. |
多谢 |
The text was updated successfully, but these errors were encountered: