You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by mvolkomorov <22...@gmail.com> on 2021/03/04 23:47:33 UTC

ContinuousQuery and injected bean

Hello!

I have data-node and service-node with injected bean and doing
ContinuousQuery. 
I am getting the BinaryObjectException:
Failed to deserialize object [typeName=ru.mts.service.CaseListenerService]
class org.apache.ignite.binary.BinaryObjectException: Failed to read field
[name=query]

Chanching query field to transient leads to: 
(err) Failed to notify listener:
o.a.i.i.util.future.GridFutureChainListener@3a625d1borg.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'customBean' available
	at
org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition

customBean placed only at service.xml config.

// node filtering:

<property name="userAttributes">
            <map key-type="java.lang.String" value-type="java.lang.Boolean">
                <entry key="listener.service.node" value="true"/>
            </map>
        </property>
...
<property name="nodeFilter">
                        <bean class="ru.mts.config.ListenerNodeFilter"/>
                    </property>

...
public class QueryService implements Service {

    private static final String CACHE_NAME = "cases";

    @IgniteInstanceResource
    private static Ignite ignite;

    @LoggerResource
    private static IgniteLogger log;

    @SpringResource(resourceName = "customBean")
    private transient Properties queryProperties;
 
    private transient ContinuousQuery<CaseKey, Case> query;

    private IgniteCache<CaseKey, Case> cache;

    @Override
    public void init(ServiceContext serviceContext) throws Exception {

        try {
            cache = ignite.cache(CACHE_NAME);

            query = new ContinuousQuery<>();

            query.setInitialQuery(new ScanQuery<>((k, v) ->
                    v.getCaseStatus().equals(CaseStatus.CLOSED)));

            query.setRemoteFilterFactory(new
Factory<CacheEntryEventFilter&lt;CaseKey, Case>>() {
                @Override
                public CacheEntryEventFilter<CaseKey, Case> create() {
                    return new CacheEntryEventFilter<CaseKey, Case>() {
                        @Override
                        public boolean evaluate(CacheEntryEvent<? extends
CaseKey, ? extends Case> e) {
                            return
e.getValue().getCaseStatus().equals(CaseStatus.CLOSED);
                        }
                    };
                }
            });

            query.setLocalListener(events -> {
                for (CacheEntryEvent event : events) {
                  // some logic using my bean
                }

            });


        } catch (Exception e) {
            log.error("Listener service error : {}", e);
        }
    }

    @Override
    public void execute(ServiceContext serviceContext) {

        cache.query(query);
    }


 }



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: ContinuousQuery and injected bean

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

It is recommended to use inner static classes as remote filters or
runnables/callables, precisely because they don't bring parent class
instance with them, which will otherwise consume bandwidth and may cause
serialization issues.

Regards,
-- 
Ilya Kasnacheev


пт, 5 мар. 2021 г. в 12:10, mvolkomorov <22...@gmail.com>:

> Initially i need singleton service on single node to collect events from
> data
> nodes, and process them localy using my injected bean properties. It seems
> remoteFilterFactory requires the service to be remote too.
> Could somebody clarify me how exactly making service properties statical
> affects on service marshalling?
> When continuous query comes as ignite service property, should it be static
> or not?
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Re: ContinuousQuery and injected bean

Posted by mvolkomorov <22...@gmail.com>.
Initially i need singleton service on single node to collect events from data
nodes, and process them localy using my injected bean properties. It seems
remoteFilterFactory requires the service to be remote too.
Could somebody clarify me how exactly making service properties statical
affects on service marshalling?
When continuous query comes as ignite service property, should it be static
or not?



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/