Hi, 

I already replied to the confirmation email twice. Is there any other thing
I have to do?

The place were it hangs is when calling
ignite.services().deploy(serviceConfiguration()) from inside the bean
IgniteClusterSingletonStarter. The full code is in the first post. If I
remove that bean and simply provide ServiceConfiguration in the
IgniteConfiguration bean (code is also in the first post), I can see it's
registered by the logs from inside the init() method in the TestService
implementation. So basically, registering the cluster singleton through xml
configuration before create the Ignite instance works. If I create the
Ignite instance and then try to create the cluster singleton it hangs.  
I don't know exactly what you mean with reusing IgniteConfiguration,
CommunicationSPI and discoverySPI, sorry. The whole Ignite configuration is
attached in the first post. From there, what I do in some beans is inject
the Ignite instance to create a queue, a topic and listeners to node events.
This is the code for that. The only part missing in the code is the cluster
singleton that should produce messages to the distributed queue:

public TopicSubscriber(Ignite ignite,
                                                String topicName,
                                                Service service){
      this.service = service;
      this.ignite = ignite;
      this.topicName = topicName;
   }

   @PostConstruct
   private void initSubscriber() {
      ignite.message(ignite.cluster().forRemotes()).localListen(topicName,
(uuid, deleteRequest) -> {
         service.remove((Request) deleteRequest);
         return true;
      });
   }

public class EventListener {

   private final Service service;
   private final IgniteEvents igniteEvents;

   public PriceChangeAlertClusterEventListener(IgniteEvents igniteEvents,
                                               Service service) {
      this.service = service;
      this.igniteEvents = igniteEvents;
   }

   @PostConstruct
   private void initializeEventsListener() {
      igniteEvents.localListen(this::clearSubscriptions,
EventType.EVT_NODE_FAILED, EventType.EVT_NODE_JOINED,
EventType.EVT_NODE_LEFT);
   }

   private boolean clearSubscriptions(Event event) {
      service.unsubscribeAll();
      return true;
   }

public QueueConsumer(Service service
                                        IgniteQueue<QueueObject> queue) {
      this.service = service;
      this.queue = queue;
   }

   @PostConstruct
   private void startConsuming() {
      Executors.newFixedThreadPool(1).execute(() ->
service.update(queue.take()));
   }


The implementation of TestService is basically this 

public class TestService implements Service {
   @Override
   public void cancel(ServiceContext ctx) {
      log.info("Cancle");
   }

   @Override
   public void init(ServiceContext ctx) throws Exception {
      log.info("Init");
   }

   @Override
   public void execute(ServiceContext ctx) throws Exception {
      log.info("execute");
   }
}

Thanks. 



--
View this message in context: 
http://apache-ignite-users.70518.x6.nabble.com/Deploying-service-programmatically-hangs-the-app-tp6791p6807.html
Sent from the Apache Ignite Users mailing list archive at Nabble.com.

Reply via email to