Results 1 to 8 of 8

Thread: Is there a way to shutdown the listen created by connection factory?

  1. #1
    Join Date
    May 2012
    Posts
    1

    Default Is there a way to shutdown the listen created by connection factory?

    I'm using tcp-connection-factory to create a tcp server. However, I need to shutdown the server or the listener sometimes. How can I do it?

  2. #2
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    Add a <control-bus/> and send a message containing "@endpointName.stop()" to it.

    Or, inject the endpoint that uses the connection factory (TcpReceivingChannelAdapter or TcpInboundGateway) into one of your beans, and call stop() directly.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  3. #3
    Join Date
    May 2012
    Location
    186 Prince Ave Freeport, NY 11520
    Posts
    1

    Default

    Can we directly call stop() method, whenever we need to destroy the connection.

  4. #4
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    Yes; stop() will close all active connections and stop listening for any new ones. start() will start listening again.

    auto-startup="false" (on the endpoint) will prevent the framework from doing an initial start()
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  5. #5
    Join Date
    May 2012
    Posts
    3

    Default

    I called this.tcpinboundadapter.stop();
    tcpinboundadapteris tcp-outbound-channel-adapter injected to my bean. The adapter doesn't stop listening. I'm using 2.1. I also set auto-startup to false, it's still starting up. why?
    <int:control-bus input-channel="controlChannel"/>
    <int-ip:tcp-inbound-channel-adapter
    id="WA_InboundChannelAdapter" channel="WA_InboundChannel"
    connection-factory="WA_Server" auto-startup="false"/>

  6. #6
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    I just tested it and it works fine for me; doesn't start when auto-startup="false" and starts/stops fine.

    I suggest you run with debug logging to see what's happening.
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

  7. #7
    Join Date
    May 2012
    Posts
    3

    Default

    It works in Junit testing. but in our application, I can't stop the listener with the same code. I compared the logging,
    JUnit gives me the logging below.

    DEBUG: org.springframework.beans.factory.support.DefaultL istableBeanFactory - Returning cached instance of singleton bean 'WA_InboundChannelAdapter'
    WARN : org.springframework.integration.ip.tcp.connection. TcpNetServerConnectionFactory - Server Socket closed
    INFO : org.springframework.integration.ip.tcp.connection. TcpNetServerConnectionFactory - stopped WA_Server


    But our application, I don't see these three lines. the context file is the same. the code is the same. It appears the it couldn't find the adapter in our application. What could the possible cause of it?

  8. #8
    Join Date
    Mar 2010
    Location
    Gtr Philadelphia, PA
    Posts
    2,017

    Default

    It's impossible for auto-start="false" and stop() to work in one environment, but not in another, given the same versions of Spring Integration.

    I suggest you add some diagnostics to your code to ensure you are running with the right configuration, and you are calling stop().
    Gary P. Russell
    Spring Integration Team
    SpringSource, a division of VMware

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •