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 14:34:39 UTC

Initialise properties at implemented CacheEntryUpdatedListener

Hi, guys!

Is it possible to initialize my property with an injected resource at inner
static class of Ignite Service?

    private static class LocalListener implements
CacheEntryUpdatedListener<CaseKey, Case> {

        @SpringResource(resourceName = "kafkaProducerProperties")
        private static Properties kafkaProducerProperties;

        private static KafkaProducer<String, String> kafkaProducer;

        @Override
        public void onUpdated(Iterable<CacheEntryEvent&lt;? extends CaseKey,
? extends Case>> events) throws CacheEntryListenerException {
            for (CacheEntryEvent event : events) {

I want the kafkaProducer to be initialized with new
KafkaProducer(kafkaProducerProperties) like this:
kafkaProducer = new KafkaProducer<>(kafkaProducerProperties); 




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

Re: Initialise properties at implemented CacheEntryUpdatedListener

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

Just declare the field as transient, and then apply if (f == null) f =
initialValue() pattern.

Regards,
-- 
Ilya Kasnacheev


чт, 4 мар. 2021 г. в 17:34, mvolkomorov <22...@gmail.com>:

> Hi, guys!
>
> Is it possible to initialize my property with an injected resource at inner
> static class of Ignite Service?
>
>     private static class LocalListener implements
> CacheEntryUpdatedListener<CaseKey, Case> {
>
>         @SpringResource(resourceName = "kafkaProducerProperties")
>         private static Properties kafkaProducerProperties;
>
>         private static KafkaProducer<String, String> kafkaProducer;
>
>         @Override
>         public void onUpdated(Iterable<CacheEntryEvent&lt;? extends
> CaseKey,
> ? extends Case>> events) throws CacheEntryListenerException {
>             for (CacheEntryEvent event : events) {
>
> I want the kafkaProducer to be initialized with new
> KafkaProducer(kafkaProducerProperties) like this:
> kafkaProducer = new KafkaProducer<>(kafkaProducerProperties);
>
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>