Open jiangxin0503 opened 1 week ago
Hi Xin,
We discussed the issue with the shim and decided to offer an option to skip the initialization of the event queue in the shim. This ensures that the event queue is not initialized twice. If you skip the initialization in the shim, you can initialize the module in your project. However, ensure that you incorporate the events defined in the shim into your own event queue configuration.
Regarding your second question: The better approach is to use registerAsEventProcessor: false in Service A. The isEventQueueActive option is more suitable for temporarily disabling the event queue, for example, during a deployment. Do you already use Redis? If events are published in separate applications, it is recommended to use the same Redis instance for both applications. This significantly speeds up the processing time for newly published events. Without Redis, app A won't be immediately notified about new events, and they will be processed during the next periodic poll (depending on your configuration).
I hope this answers your questions. If not, feel free to reach out.
Best regards, Max
Hi @soccermax ,
Thank you for the information; it's really helpful. Please find below my additional questions:
server.js
. However, there is an error caused by the default initialization at https://github.com/cap-js-community/event-queue/blob/main/cds-plugin.js#L9.
Bcause when i install the lib, the cds env for event-queue is
Even i do not config event-queue in my package.json
registerAsEventProcessor
looks good, especially since we are already using Redis. However, is the option registerAsEventProcessor
intended for all events within one app? If registerAsEventProcessor: false
is configured in App A, does this mean that all events will only be published in App A and cannot be consumed in App A? We have a scenario where:
Thank you. Xin
Hi Xin,
there is a new shim version (cds-shim: 0.5.48) with a new env option (process.env.EVENT_QUEUE_CUSTOM_INIT). You can use this option to init the event-queue your self, but as said copy over the shim events into your own config file.
Regarding the empty event-queue config it seems that cds changed there behaviour regarding this or this happens in combination with shim. Let me test this. But if you init the event-queue yourself you can simply do it via plugin. But nevertheless this should also work via coding, I'll check this.
Regarding App A and B, this case is not implemented yet. But this is not a big thing, if I find some time next week I'll start/do it. I would imagine something like this. What do you think?
events:
- type: Email
subType: Task
impl: ./srv/util-service/mail-service/business/EventQueueNotificationProcessor
load: 1
appNames:
- app-a
- type: Fiori
subType: Task
impl: ./srv/util-service/mail-service/business/EventQueueNotificationProcessor
load: 1
appNames:
- app-b
Hi Max, Thanks for your quick action.
For the case App A and App B, the config looks good. So does this mean once i publish the message, it should specify the consumer/processor ? like
await publishEvent(tx, {
type: "Email",
subType: "Task",
appNames: [app-a], // then only app a can process the event ?
payload: JSON.stringify({
recipients: ["alice@wonder.land"],
}),
});
Thanks. Regards, Xin
No the idea is that you specify this in the configuration like in the example above. So this would be in the config yml:
events:
- type: Email
subType: Task
impl: ./srv/util-service/mail-service/business/EventQueueNotificationProcessor
load: 1
appNames:
- app-a
- type: Fiori
subType: Task
impl: ./srv/util-service/mail-service/business/EventQueueNotificationProcessor
load: 1
appNames:
- app-b
Would this work for you?
Hi Max,
OK, I think I got your point now.
Please kindly correct me if i am wrong:
like the config, the Email task configs as app-a, it means the process of Email Task will only be processed in app-a.
Then no matter the Email Task event is pulished in app-a , app-b, or even app-c, the process of this task will only happen in app-a. Then i think it works. Many Thanks. Regards, Xin
yes exactly. I'll implement that in the near future, Thanks for the input
Hi Colleagues
But there is error when init![image](https://github.com/cap-js-community/event-queue/assets/12246583/4bb1ce30-d2bd-4f67-a9c8-3fe962aac7dd)
Then the coding level initialization is not successed, because it will anyway return saying that init is done,
Question: Does this mean there is only ONE chance to init the event-queue? but we have case like: we use cds-shim, in cds-shim, there is event initialized, but we also want to initialized by our own event but in case the config file from cds.eventQueue. configFilePath is initialized, the cds-shim's event will not register
Does this support multiple event init or register
sEventQueueActive
false, and B fortrue
, correct ?Any other points needs to be taken care ?
Many thanks for your help.
Regards, Xin