These are chat archives for spring-cloud/spring-cloud

9th
Aug 2017
Benjamin Ihrig
@ihrigb
Aug 09 2017 10:02
Hi, I got a question concerning cloud connectors.
Following situation. I have a binding of a custom (third party) service and implemented a ServiceInfoCreator for it. At the end there will be three separate Java services created from this, for which I have ServiceConnectorCreators. So my question is, if Cloud Connector Core is able to create these three services during startup, or just create "first to come" (or fail)?
Thanks!
Ziemowit
@Ziemowit
Aug 09 2017 10:16

Hi guys!

Are you able to tell me...
When I use @FeignClient which thread pool is used then?

Because recently I got exception on @FeignClient call:

...
Caused by: java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.FutureTask@7a8b6861 rejected from java.util.concurrent.ThreadPoolExecutor@6eb737e8[Running, pool size = 10, active threads = 10, queued tasks = 0, completed tasks = 5580]

So I have the feeling that there is used a pool which I have create for scheduled tasks.

@Configuration
@EnableScheduling
public class SchedulingConfig {

  @Bean
  public TaskScheduler taskScheduler() {
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.setPoolSize(10);
    return taskScheduler;
  }

}

Are you able to tell me if my assumption is correct?

James Howe
@OrangeDog
Aug 09 2017 10:17
ThreadPoolExecutor != ThreadPoolTaskScheduler
Ziemowit
@Ziemowit
Aug 09 2017 10:18

Yes indeed you have right!
So then I should define:

@Bean
public ThreadPoolTaskExecutor taskExecutor() {
}

right?

And customize it to my needs? Because right now I have no explicit configuration for it so probably some default is taken.

Dave Syer
@dsyer
Aug 09 2017 11:01
@ihrigb I didn't understand the question
Andrey Saksonov
@andreysaksonov
Aug 09 2017 11:10

hi, I have weird problem with dependencies

Application startup failed java.lang.InstantiationException: java.util.Map$Entry at sun.misc.Unsafe.allocateInstance(Native Method) at com.thoughtworks.xstream.converters.reflection.SunLimitedUnsafeReflectionProvider.newInstance(SunLimitedUnsafeReflectionProvider.java:82)

this happens on reading job executions in spring batch on app startup
however, if I remove

compile('org.springframework.cloud:spring-cloud-starter-eureka')

everything works as expected
so I think eureka starter override some dependency which breaks deserialization of spring batch jobs

any advices how to workaround?
Dave Syer
@dsyer
Aug 09 2017 11:14
Don't use eureka with Spring Batch?
Andrey Saksonov
@andreysaksonov
Aug 09 2017 11:14
:)
Dave Syer
@dsyer
Aug 09 2017 11:15
I think it's the jettison XML serializer
Eureka uses a different version
I have no idea if it works with the one that Batch uses
Andrey Saksonov
@andreysaksonov
Aug 09 2017 11:15
Gradle: org.codehaus.jettison:jettison:1.2
Gradle: org.codehaus.jettison:jettison:1.3.7
many thanks!
Benjamin Ihrig
@ihrigb
Aug 09 2017 11:16
@dsyer If I provide a ServiceInfoCreator and a ServiceConnectorCreator, cloud connector core components will initialize the connector as a bean, if the service is bound to the app (detected via accept methods and comparing tags and so on). Suppose I have more than one ServiceConnectorCreator to consume one ServiceInfo, would coud connector core initialize all connectors or only one?
Dave Syer
@dsyer
Aug 09 2017 11:16
I don't know. I expect it's obvious from the source code though.
I don't think anything is created by default is it?
Maybe with Spring Boot autoconfig it is?
Dave Syer
@dsyer
Aug 09 2017 11:23
Right. That's optional though.
I guess if you use Spring Boot you get it by default.
Benjamin Ihrig
@ihrigb
Aug 09 2017 11:23
yes, and I want it. But my question is, how this would behave if I want two or more beans per bound service instance.
Dave Syer
@dsyer
Aug 09 2017 11:27
I think you only get one bean per service info
I guess maybe that could be a @Configuration?
I never tried it.
Benjamin Ihrig
@ihrigb
Aug 09 2017 11:28
I can create them myself with a @Configuration class, but ran into duplicate bean issues with it. So now I create my three services with @ConditionalOnMissingBean
Dave Syer
@dsyer
Aug 09 2017 11:28
That sounds fragile
I'm not a big fan of connectors
Can't you just use autoconfig?
Benjamin Ihrig
@ihrigb
Aug 09 2017 11:29
No, I use AbstractCloudConfiguration to initialize them and it works like a charm.
This is autoconfig
Dave Syer
@dsyer
Aug 09 2017 11:29
I don't understand why anyone needs to use connectors in autoconfig
You could just create beans conditional on environment properties
Benjamin Ihrig
@ihrigb
Aug 09 2017 11:30
they are initialized via a autoconfig class
yes I could
Andrey Saksonov
@andreysaksonov
Aug 09 2017 11:44
@dsyer org.springframework.batch.core.configuration.annotation.DefaultBatchConfigurer allows to override only JobRepository factory method
but creation of jobExplorer is inlined :(
so I need to implement new BatchConfigurer to set same xml serializer both to jobRepository and jobExplorer
Dave Syer
@dsyer
Aug 09 2017 11:46
I'm not really sure
You could raise it as an issue in Spring Batch
We could shade the dependency, or make it more configurable.
Andrey Saksonov
@andreysaksonov
Aug 09 2017 11:47
to workaround in current version (now) I want just replace implementation of org.springframework.batch.core.repository.ExecutionContextSerializer to jackson-based
Dave Syer
@dsyer
Aug 09 2017 12:09
It probably won't be backwards compatible
i.e. your old data will be unreadable