Hibernate search coordination strategy. Can we intercept the event creating process in order to define priority order of events?

Hello,

My requirement is. I want to give highest priority to the events generated by performing CRUD operation on main entity and lower priority to the events generated (on main entity )by performing CRUD operations on its connected objects with relation.

Is it possible in hibernate search?

Thanks.

Hey,

Outbox events are not prioritised; indexing agents split the work among themselves and process their subsets of events. So even if you intercept the event, that won’t help much …

Hello,

I will explain my requirement again.

I have X (main entity having index )entity and Y entity. Y entity is relational entity having relationship with X.

Here one Y entity can be connected to 20000 main entity (X).

If someone updates Y entity it’s ok if that changes reflected in index after some time. But I want to update my index immediately if someone changes field in main entity i.e X.

But what happening here, if someone updates the Y entity and this entity is connected to around 20000 X entity then around 20000 events are generated for main Entity. At the same time if user updates one of the field in main entity (X) then here event will be generated but won’t be processed instantly as outbox table already has 20000 event.

But I want to priorities the event generated by changes in main entity not event generated by changes in connected entities.

Let me know if you need any other info.

Thanks.

Sure :smiley:, let me reiterate … events in the outbox event table do not have a priority … so you cannot put one event to get processed before the other. In other words:

Can we intercept the event creating process in order to define priority order of events?

no, not at the moment.

You could start a conditional massindexer (Hibernate Search 7.2.2.Final: Reference Documentation) to index your “main” entity, since massindexing will pause the processing of events (Hibernate Search 7.2.2.Final: Reference Documentation). But I wouldn’t consider that an elegant solution :smiley:

also, what would you do if 20000 users go and update main entities and you get 20000 events in the queue anyway… I don’t know much about your use cases, but I’d consider adjusting the user expectations …

See also: