You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/11/23 11:01:41 UTC

[GitHub] [dubbo] Coegle opened a new issue, #11002: How to make a generic invoke in a daemon coroutine?

Coegle opened a new issue, #11002:
URL: https://github.com/apache/dubbo/issues/11002

   - [x] I have searched the [issues](https://github.com/apache/dubbo/issues) of this repository and believe that this is not a duplicate.
   
   It's a Spring project. I want to run a daemon coroutine to invoke remote method. I start a coroutine after a Spring Component postConstruct and invoke the generic call. Exception as following: 
   ```
   [23/11/22 18:28:28:471 CST] DefaultDispatcher-worker-1 ERROR deploy.DefaultModuleDeployer:  [DUBBO] Dubbo Module[1.1.1] start failed: java.util.ConcurrentModificationException, dubbo version: 3.1.0, current host: 192.168.101.1
   java.util.ConcurrentModificationException
   	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1042)
   	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:996)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.exportMetadataService(DefaultApplicationDeployer.java:920)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.prepareApplicationInstance(DefaultApplicationDeployer.java:613)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.checkState(DefaultApplicationDeployer.java:824)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.notifyModuleChanged(DefaultApplicationDeployer.java:812)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.onModuleStarted(DefaultModuleDeployer.java:251)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:158)
   	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:223)
   	at com.gmair.schedproject.scheduler.service.GenericCallService.getConfig(GenericCallService.kt:28)
   	at com.gmair.schedproject.scheduler.service.GenericCallService.invoke(GenericCallService.kt:31)
   	at com.gmair.schedproject.scheduler.service.DaemonComponent$run$1.invokeSuspend(DaemonComponent.kt:19)
   	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
   	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
   [23/11/22 18:28:28:471 CST] DefaultDispatcher-worker-1  INFO metadata.ServiceInstanceMetadataUtils:  [DUBBO] Start registering instance address to registry., dubbo version: 3.1.0, current host: 192.168.101.1
   [23/11/22 18:28:28:481 CST] DefaultDispatcher-worker-1  WARN client.AbstractServiceDiscovery:  [DUBBO] No valid instance found, stop registering instance address to registry., dubbo version: 3.1.0, current host: 192.168.101.1
   [23/11/22 18:28:28:481 CST] DefaultDispatcher-worker-1 ERROR deploy.DefaultApplicationDeployer:  [DUBBO] Dubbo Application[1.1](scheduler) found failed module: Dubbo Module[1.1.1], dubbo version: 3.1.0, current host: 192.168.101.1
   java.util.ConcurrentModificationException
   	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1042)
   	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:996)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.exportMetadataService(DefaultApplicationDeployer.java:920)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.prepareApplicationInstance(DefaultApplicationDeployer.java:613)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.checkState(DefaultApplicationDeployer.java:824)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.notifyModuleChanged(DefaultApplicationDeployer.java:812)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.onModuleStarted(DefaultModuleDeployer.java:251)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:158)
   	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:223)
   	at com.gmair.schedproject.scheduler.service.GenericCallService.getConfig(GenericCallService.kt:28)
   	at com.gmair.schedproject.scheduler.service.GenericCallService.invoke(GenericCallService.kt:31)
   	at com.gmair.schedproject.scheduler.service.DaemonComponent$run$1.invokeSuspend(DaemonComponent.kt:19)
   	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
   	at kotlinx.coroutines.DispatchedTask
   Exception in thread "DefaultDispatcher-worker-1" java.util.ConcurrentModificationException
   	at java.base/java.util.ArrayList$Itr.checkForComodification(ArrayList.java:1042)
   	at java.base/java.util.ArrayList$Itr.next(ArrayList.java:996)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.exportMetadataService(DefaultApplicationDeployer.java:920)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.prepareApplicationInstance(DefaultApplicationDeployer.java:613)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.checkState(DefaultApplicationDeployer.java:824)
   	at org.apache.dubbo.config.deploy.DefaultApplicationDeployer.notifyModuleChanged(DefaultApplicationDeployer.java:812)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.onModuleStarted(DefaultModuleDeployer.java:251)
   	at org.apache.dubbo.config.deploy.DefaultModuleDeployer.start(DefaultModuleDeployer.java:158)
   	at org.apache.dubbo.config.ReferenceConfig.get(ReferenceConfig.java:223)
   	at com.gmair.schedproject.scheduler.service.GenericCallService.getConfig(GenericCallService.kt:28)
   	at com.gmair.schedproject.scheduler.service.GenericCallService.invoke(GenericCallService.kt:31)
   	at com.gmair.schedproject.scheduler.service.DaemonComponent$run$1.invokeSuspend(DaemonComponent.kt:19)
   	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
   	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:571)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:750)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:678)
   	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:665)
   ```
   
   Check [here](https://github.com/Coegle/dubboProject) to see the full demo project. Following is the main codes. The GenericCallService.invoke method works fine when I call it from TestController.
   
   ``` kotlin
   //  DaemonComponent.kt
   @Component
   final class DaemonComponent: DisposableBean {
       @Autowired
       private lateinit var genericCallService: GenericCallService
       @PostConstruct
       fun run() {
           CoroutineScope(Dispatchers.Default).launch {
               genericCallService.invoke(GenericCall("com.gmair.schedproject.TestInterface",
                   "message",
                   "com.gmair.schedproject.GenericCallParams", "{\"id\": 5}"))
           }
       }
   
       override fun destroy() {
           println("destroy")
       }
   }
   
   // GenericCallService.kt
   @Service
   class GenericCallService {
       private val applicationConfig = ApplicationConfig("scheduler")
       init {
           val registryConfig = RegistryConfig()
           registryConfig.address = "zookeeper://127.0.0.1:2181"
           applicationConfig.registry = registryConfig
       }
       private fun newConfig(inter: String): ReferenceConfig<GenericService> {
           val referenceConfig = ReferenceConfig<GenericService>()
           referenceConfig.setInterface(inter)
           referenceConfig.application = applicationConfig
           referenceConfig.generic = "true"
           return referenceConfig
       }
       private fun getConfig(inter: String): GenericService {
           return newConfig(inter).get()
       }
       fun invoke(params: GenericCall): Any {
           val genericService = getConfig(params.inter)
           val param = JSON.parseObject(params.genericCallParams, Class.forName(params.paramName))
           val map = genericService.`$invoke`(params.methodName, arrayOf(params.paramName), arrayOf<Any>(param)) as Map<*, *>
           return ObjectMapper().convertValue(map, Class.forName(map["class"] as String))
       }
   }
   ```
   
   Answer with Chinese is ok. Thanks!
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] Coegle commented on issue #11002: How to make a generic invoke in a daemon coroutine?

Posted by GitBox <gi...@apache.org>.
Coegle commented on issue #11002:
URL: https://github.com/apache/dubbo/issues/11002#issuecomment-1326230367

   I checked my code and removed dubbo-spring-boot-starter dependency, then It fixed. So I guess the problem is related with starting two dubbo services in one module.
   
   BTW, ReferenceConfig<XXX>.get() function performs well in concurrency situation.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #11002: How to make a generic invoke in a daemon coroutine?

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #11002:
URL: https://github.com/apache/dubbo/issues/11002#issuecomment-1326027082

   ```kt
       private fun getConfig(inter: String): GenericService {
           return newConfig(inter).get()
       }
   ```
   In the short term, can this function be called serially instead of concurrently?
   
   For this concurrency problem, I will take a closer look at what caused it and then optimize it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] Coegle closed issue #11002: How to make a generic invoke in a daemon coroutine?

Posted by GitBox <gi...@apache.org>.
Coegle closed issue #11002: How to make a generic invoke in a daemon coroutine?
URL: https://github.com/apache/dubbo/issues/11002


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org