You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by Maxim Volkomorov <22...@gmail.com> on 2020/07/29 11:40:16 UTC

restart service via service proxy

Hello!

I used a custom bean with properties for kafka streamer service at ignite
config.xml:

   <bean id="kafkaConsumerProperties"

class="org.springframework.beans.factory.config.PropertiesFactoryBean">
        <property name="singleton" value="true"/>
        <property name="properties">
            <props>
                <prop key="bootstrap.servers">localhost:9092</prop>
                <prop key="auto.offset.reset">latest</prop>
                <prop key="enable.auto.commit">true</prop>
                <prop key="group.id">ignite-consumer-group</prop>
                <prop
key="key.deserializer">org.apache.kafka.common.serialization.StringDeserializer</prop>
                <prop
key="value.deserializer">org.apache.kafka.common.serialization.StringDeserializer</prop>
            </props>
        </property>
    </bean>

Injected this bean using:
@SpringResource(resourceName = "kafkaConsumerProperties")
    private transient Properties kafkaConsumerProperties;

I have an ignite service with a custom REST API (Jersey).
I am trying to implement an ignite service method that can restart another
ignite service via ignite serviceProxy.
Calling this method at REST API:

class RESTController {

// some REST method signature here
Ignite ignite = Ignition.ignite();
RESTService restService =
ignite.services().serviceProxy(RESTService.SERVICE_NAME,
            RESTService.class, false);

restService.restartMyService("myServiceName");
}
}

public class RESTServiceImpl implements RESTService {

public void restartMyService(String serviceName) {

ignite.services().cancel(serviceName);
ignite.services().deployNodeSingleton(serviceName, new
KafkaConsumerService());
}
}

My error at method call:

[2020-07-28
14:58:32,123][ERROR][services-deployment-worker-#70][IgniteServiceProcessor]
Failed to initialize service (service will not be deployed):
KafkaCDRConsumerServiceorg.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'kafkaConsumerProperties' available

I believe that deployNodeSingleton() can't see @SpringResource injection. I
guess that proxyService calls operated at Ignite context. What are the
reasons? Is there a way to restart my service with injections?

Re: restart service via service proxy

Posted by akurbanov <an...@gmail.com>.
Hello,

Please take a look on a test code, is that the desired behaviour for your
service?

https://github.com/apache/ignite/blob/master/modules/spring/src/test/java/org/apache/ignite/spring/injection/GridServiceInjectionSpringResourceTest.java

Best regards,
Anton



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