You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@isis.apache.org by Erik de Hair <e....@pocos.nl> on 2018/05/09 10:14:57 UTC
Expected multiple ObjectUpdatedEvents but only 1 catched
Hi,
For the following scenario I expected an UpdatedEvent for each entity
being updated but I only receive one for the last updated entity. Is
that by design?
Example classes:
@PersistenceCapable(table = "entities")
@DomainObject(updatedLifecycleEvent = Entity.UpdatedEvent.class)
public class Entity {
public static class UpdatedEvent extends
org.apache.isis.applib.services.eventbus.ObjectUpdatedEvent<Entity>{ }
@Column(name = "activated", allowsNull = "false")
@Getter @Setter
private boolean activated;
public void activate(){
setActivated(true);
}
}
@DomainService(nature=NatureOfService.DOMAIN)
public class EntitySubscriber extends AbstractSubscriber {
@Subscribe
public void on(Entity.UpdatedEvent ev) {
// do something
}
}
@DomainService(nature = NatureOfService.DOMAIN)
public class EntityService {
public void activateAll(){
List<Entity> entities = <query result>;
for (Entity entity : entities) {
entity.activate();
}
}
}
Thanks,
Erik
Re: Expected multiple ObjectUpdatedEvents but only 1 catched
Posted by Andi Huber <ah...@apache.org>.
Hi Erik,
I managed to reproduce the issue, using your example code. I tested both axon and guava eventbus on the current master branch. I guess its reproducible with the latest release of 1.16. as well.
Seems to be a bug with
org.apache.isis.objectstore.jdo.datanucleus.service.eventbus.EventBusServiceJdo which skips event propagation, when it actually should not. (But I'm not really sure yet. Code seems to require some polishing, I guess.)
Cheers, Andi
On 2018/05/09 10:14:57, Erik de Hair <e....@pocos.nl> wrote:
> Hi,
>
> For the following scenario I expected an UpdatedEvent for each entity
> being updated but I only receive one for the last updated entity. Is
> that by design?
>
> Example classes:
>
> @PersistenceCapable(table = "entities")
> @DomainObject(updatedLifecycleEvent = Entity.UpdatedEvent.class)
> public class Entity {
> public static class UpdatedEvent extends
> org.apache.isis.applib.services.eventbus.ObjectUpdatedEvent<Entity>{ }
>
> @Column(name = "activated", allowsNull = "false")
> @Getter @Setter
> private boolean activated;
>
> public void activate(){
> setActivated(true);
> }
> }
>
> @DomainService(nature=NatureOfService.DOMAIN)
> public class EntitySubscriber extends AbstractSubscriber {
>
> @Subscribe
> public void on(Entity.UpdatedEvent ev) {
> // do something
> }
> }
>
> @DomainService(nature = NatureOfService.DOMAIN)
> public class EntityService {
>
> public void activateAll(){
> List<Entity> entities = <query result>;
>
> for (Entity entity : entities) {
> entity.activate();
> }
> }
> }
>
> Thanks,
> Erik
>
>
>