-
Notifications
You must be signed in to change notification settings - Fork 120
Conversation
Holding off on merging this as @yharish991 and @ianpartridge are still working together on it. Their aim is to merge and release the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see this in my logs when I run this template:
[Container] [INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ default-kafka-application ---
[Container] [INFO] Changes detected - recompiling the module!
[Container] [INFO] Compiling 4 source files to /project/user-app/target/classes
[Container] [INFO] /project/user-app/src/main/java/application/config/KafkaProducer.java: /project/user-app/src/main/java/application/config/KafkaProducer.java uses unchecked or unsafe operations.
[Container] [INFO] /project/user-app/src/main/java/application/config/KafkaProducer.java: Recompile with -Xlint:unchecked for details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't able to get appsody run
to work with this template. Here's the error I see:
[Container] 2020-04-07 15:52:20.959 INFO 178 --- [ restartedMain] o.a.kafka.common.utils.AppInfoParser : Kafka version : 2.0.1
[Container] 2020-04-07 15:52:20.959 INFO 178 --- [ restartedMain] o.a.kafka.common.utils.AppInfoParser : Kafka commitId : fa14705e51bd2ce5
[Container] 2020-04-07 15:53:21.139 WARN 178 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
[Container] 2020-04-07 15:53:21.147 INFO 178 --- [ restartedMain] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
[Container] 2020-04-07 15:53:21.177 INFO 178 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
[Container] 2020-04-07 15:53:21.202 WARN 178 --- [ restartedMain] o.a.c.loader.WebappClassLoaderBase : The web application [ROOT] appears to have started a thread named [MemoryMXBean notification dispatcher] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
[Container] com.ibm.lang.management.internal.MemoryNotificationThread.processNotificationLoop(Native Method)
[Container] com.ibm.lang.management.internal.MemoryNotificationThread.run(MemoryNotificationThread.java:183)
[Container] 2020-04-07 15:53:21.260 INFO 178 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
[Container]
[Container] Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
[Container] 2020-04-07 15:53:21.274 ERROR 178 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed
[Container]
[Container] org.springframework.context.ApplicationContextException: Failed to start bean 'org.springframework.kafka.config.internalKafkaListenerEndpointRegistry'; nested exception is org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
[Container] at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
[Container] at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
[Container] at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
[Container] at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
[Container] at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
[Container] at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:893) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
[Container] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162) ~[spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:552) ~[spring-context-5.1.13.RELEASE.jar:5.1.13.RELEASE]
[Container] at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141) ~[spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:744) [spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:391) [spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] at org.springframework.boot.SpringApplication.run(SpringApplication.java:312) [spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1215) [spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1204) [spring-boot-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] at application.Main.main(Main.java:10) [classes/:na]
[Container] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_242]
[Container] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_242]
[Container] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_242]
[Container] at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_242]
[Container] at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.12.RELEASE.jar:2.1.12.RELEASE]
[Container] Caused by: org.apache.kafka.common.errors.TimeoutException: Timeout expired while fetching topic metadata
I pushed some changes to parameterize the KafkaTemplate, you should not see that in the logs anymore |
Can you try using the below docker-compose.yaml and run the appsody app with this command
|
I can confirm this works for me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me! Thanks @yharish991
Are the kafka tests ran as part of appsody test? I assume not because that would require the kafka server right? As part of the travis CI/CD build appsody test is ran so just wondering how that is handled. Thanks! |
They use a Spring |
Thanks Ian. |
0791abc
@skoh7645 can you merge this pr? |
``` | ||
appsody run --network kafka_default --docker-options "--env KAFKA_BOOTSTRAP_SERVERS=kafka:9092" | ||
``` | ||
`DOCKER_NETWORK_NAME` is the name of the docker network in which the kafka container is running. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command above uses kafka_default
directly as the docker network name, but was probably intended to use $DOCKER_NETWORK_NAME
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I intended the line 21 to be
appsody run --network DOCKER_NETWORK_NAME --docker-options "--env KAFKA_BOOTSTRAP_SERVERS=${KAFKA_BOOTSTRAP_SERVERS}"
``` but missed to add `--network` part, will fix that in the next pr
Checklist:
Read the Code of Conduct and Contributing Guidelines.
Followed the commit message guidelines.
Stack adheres to Appsody stack structure.
Modifying an existing stack:
stack.yaml
This PR adds a new
kafka
template to thejava-spring-boot2
stack.Related Issues:
Related to #695