BackEndDataProvider with async updates: refreshItem/refreshAll not working

Hi
I am trying to get an example app running which uses a data provider which is updated asynchronously. I am using Vaadin 14 and in the backend I use Axon Framework’s subscription queries.
The idea:
The data provider instance get’s notified from my backend that data has changed and then I call refreshItem() on the data provider, so that a grid is refreshed with updated data. But the UI does not get updated. I already read read the docs on async updates + collaborative views and I also have @Push annotation on my view.

If I call the refreshItem/refreshAll methods from the UI view, the update of the UI works fine, but it does not work if triggered from a lambda in the data provider.

Does anybody have any ideas how to solve this?

thanks
Klaus

If I call the refreshItem/refreshAll methods from the UI view, the update of the UI works fine, but it does not work if triggered from a lambda in the data provider.

Do you use ui.access(() -> dataProvider.refreshAll()) ?

Tatu Lund:

If I call the refreshItem/refreshAll methods from the UI view, the update of the UI works fine, but it does not work if triggered from a lambda in the data provider.

Do you use ui.access(() -> dataProvider.refreshAll()) ?

Hi
yes, I also tried with ui.access(() → {}) in the data provider.
I think the special situation is that I am calling the refresh from inside the data provider object
and this happens in a different thread than the “normal” UI view.

Here is a code snippet from the data provider (based on an Axon example giftcard-demo):

protected Stream<CardSummary> fetchFromBackEnd(Query<CardSummary, String> query) {
...
    fetchQueryResult = queryGateway.subscriptionQuery(fetchCardSummariesQuery,
            ResponseTypes.multipleInstancesOf(CardSummary.class),
            ResponseTypes.instanceOf(CardSummary.class));

    fetchQueryResult.updates().subscribe(
            cardSummary -> {
                if (ui != null) {
                    ui.access(() -> {
                        refreshItem(cardSummary);
                    });
                }
            });

The refreshItem() call above does not do anything.