Immediate application shutdown after succesful start

gerhardo
gerhardo Member Posts: 6

Hi !
I have the following problem and no clue why the application behaves as described:
I created a spring boot cloud stream application with gradle or maven (same behaviour) and added a subscription to a durable queue for consuming messages send to the topic. The application starts succesful but is followed by an immediate shutdown. It looks like someone is pressing Ctrl-C to stop the application.

 :: Spring Boot ::        (v2.2.6.RELEASE)

2020-06-03 10:55:09.200  INFO 1272 --- [           main] spring.boot.Application                  : Starting Application on CE33088 with PID 1272 (C:\Users\geotte\work\dev\nas\template\spring-boot-solace\bin\main started by geotte in C:\Users\geotte\work\dev\nas\template\spring-boot-solace)
...
2020-06-03 10:55:15.432  INFO 1272 --- [           main] spring.boot.Application                  : Started Application in 7.563 seconds (JVM running for 9.291)
2020-06-03 10:55:15.450  INFO 1272 --- [extShutdownHook] c.s.j.protocol.impl.TcpClientChannel     : Channel Closed (smfclient 2)
2020-06-03 10:55:15.457  INFO 1272 --- [extShutdownHook] c.s.s.c.s.b.i.JCSMPInboundChannelAdapter : Stopping consumer flow from queue app/created/consumer.Q.app.inbox <inbound adapter ID: 73a4f0c0-f608-4218-b0e6-9fc0ffa74db9>
...

My Gradle build file looks like this:

plugins {
    id 'java'
    id 'org.springframework.boot' version '2.2.6.RELEASE'
    id 'io.spring.dependency-management' version '1.0.9.RELEASE'
}

repositories {
    // Use jcenter for resolving dependencies.
    // You can declare any Maven/Ivy/file repository here.
    jcenter()
}

dependencies {
    implementation platform('org.springframework.cloud:spring-cloud-dependencies:Hoxton.SR3')
    implementation platform('com.solace.spring.cloud:solace-spring-cloud-bom:1.0.0')
    implementation 'com.solace.spring.cloud:spring-cloud-starter-stream-solace'
}

If i add a web starter to the application the application keeps running because of the tomcat and receives events. But this can not be the solution.
Thank you and best regards,
Gerhard

Comments

  • uherbst
    uherbst Member, Employee Posts: 121 Solace Employee

    Just a guess: You have no permissions to subscribe - maybe something in your acl profile or client-profile.
    Do you have access to broker logs ? Have a look at event.log.
    If not: If you have access to cli, you can do something like

    show log event lines 20
    
  • gerhardo
    gerhardo Member Posts: 6

    Ok, finally I found the "solution":
    The application must have a consumer and a supplier and both must be listed in the function paragraf in the solace stream. If I omit the supplier from the application or does not name it in the descriptor the application shuts down immediatly.
    Now the working application looks like this:

    @SpringBootApplication
    public class Application {
    
        private static final Logger logger = LoggerFactory.getLogger(Application.class);
    
        public static void main(String[] args) {
            SpringApplication.run(Application.class);
        }
    
        @Bean
        public Consumer<String> appCreatedConsumer() {
            return String -> {
                System.out.println("String created: " + String);
            };
        }
    
        @Bean
        public Supplier<String> appCreatedSupplier() {
            return () -> new String("Test");
        }
    }
    

    and my application.xml looks like this:

    spring:
      cloud:
        stream:
          function:
            definition: appCreatedConsumer;appCreatedSupplier
          bindings:
            appCreatedConsumer-in-0:
              group: Q.app.inbox
              destination: app/created/consumer
    solace:
      java:
        host: 'tcp://192.168.99.100:55555'
        msgVpn: default
        clientUsername: admin
        clientPassword: admin
    logging:
      level:
        root: info
        org:
          springframework: info
    

    BR Gerhard

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 914 admin

    Hi @gerhardo,
    What you've found is indeed a bug that we're already working on a fix for and it will be fixed in the next release of the Solace Spring Cloud Stream binder. Both solutions that you've found will work in the meantime (adding a web starter or having a supplier as part for your microservice) but once the next release is available those workarounds will no longer be necessary.
    -Marc

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 914 admin

    Actually, looks like the fix has already been merged into the master branch if you want to try it out prior to the next release: https://github.com/SolaceProducts/solace-spring-cloud/pull/5

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 914 admin

    And a release with this fix has been cut! It should be up in maven central sometime tomorrow.
    In the meantime you can find it here: https://github.com/SolaceProducts/solace-spring-cloud/releases/tag/1.0.1
    -Marc

  • gerhardo
    gerhardo Member Posts: 6

    Hi @marc
    the new version 1.0.1 works as expected without the above workarounds. Thx.
    BR Gerhard

  • marc
    marc Member, Administrator, Moderator, Employee Posts: 914 admin

    Excellent, thanks for letting us know!