[
https://issues.apache.org/jira/browse/CAMEL-12103?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16309317#comment-16309317
]
Claus Ibsen commented on CAMEL-12103:
-------------------------------------
Okay reproduced this with your sample code, thanks.
And have a fix
The client is sending:
{code}
davsclaus:/Users/davsclaus/Downloads/$ groovy tcp-client.groovy
Sent 0
Sent 1
Sent 2
Sent 3
Sent 4
Sent 5
Caught: java.net.SocketException: Broken pipe (Write failed)
java.net.SocketException: Broken pipe (Write failed)
at tcp-client$_run_closure1_closure2.doCall(tcp-client.groovy:6)
at tcp-client$_run_closure1.doCall(tcp-client.groovy:2)
at tcp-client.run(tcp-client.groovy:1)
{code}
And the server is being stopped:
{code}
INFO - Apache Camel 2.21.0-SNAPSHOT (CamelContext: camel-1) is starting
INFO - JMX is enabled
INFO - Type converters loaded (core: 193, classpath: 11)
INFO - StreamCaching is not in use. If using streams then its recommended to
enable stream caching. See more details at
http://camel.apache.org/stream-caching.html
INFO - ServerBootstrap binding to localhost:8888
INFO - Netty consumer bound to: localhost:8888
INFO - Route: route1 started and consuming from: tcp://localhost:8888
INFO - Total 1 routes, of which 1 are started
INFO - Apache Camel 2.21.0-SNAPSHOT (CamelContext: camel-1) started in 0.573
seconds
INFO - Hey 0
INFO - Hey 1
INFO - Hey 2
^CINFO - Apache Camel 2.21.0-SNAPSHOT (CamelContext: camel-1) is shutting down
INFO - Starting to graceful shutdown 1 routes (timeout 300 seconds)
INFO - ServerBootstrap unbinding from localhost:8888
INFO - Netty consumer unbound from: localhost:8888
INFO - Route: route1 shutdown complete, was consuming from:
tcp://localhost:8888
INFO - Waiting as there are still 1 inflight and pending exchanges to
complete, timeout in 300 seconds. Inflights per route: [route1 = 1]
INFO - There are 1 inflight exchanges:
InflightExchange: [exchangeId=ID-davsclaus-pro-local-1514969347001-0-3,
fromRouteId=route1, routeId=route1, nodeId=process1, elapsed=0, duration=345]
INFO - Waiting as there are still 1 inflight and pending exchanges to
complete, timeout in 299 seconds. Inflights per route: [route1 = 1]
INFO - There are 1 inflight exchanges:
InflightExchange: [exchangeId=ID-davsclaus-pro-local-1514969347001-0-3,
fromRouteId=route1, routeId=route1, nodeId=process1, elapsed=0, duration=1351]
INFO - Graceful shutdown of 1 routes completed in 2 seconds
INFO - Apache Camel 2.21.0-SNAPSHOT (CamelContext: camel-1) uptime 11.935
seconds
INFO - Apache Camel 2.21.0-SNAPSHOT (CamelContext: camel-1) is shutdown in
2.058 seconds
{code}
> Camel unable to shutdown gracefully because Netty4 consumer keep receiving
> and adding inflight exchanges
> --------------------------------------------------------------------------------------------------------
>
> Key: CAMEL-12103
> URL: https://issues.apache.org/jira/browse/CAMEL-12103
> Project: Camel
> Issue Type: Bug
> Components: camel-netty4
> Affects Versions: 2.15.2
> Reporter: Yih Tsern
> Assignee: Claus Ibsen
> Fix For: 2.21.0
>
> Attachments: tcp-client.groovy, tcp-server.camel
>
>
> I'm using this URI: {{netty4:tcp://localhost:8888?sync=false&textline=true}}
> And I have this issue when initiating Camel shutdown using
> {{DefaultShutdownStrategy}}:
> # Camel suspends {{NettyConsumer}}
> ({{SingleTCPNettyServerBootstrapFactory}}), which only stops the "main" Netty
> channel, but _not_ the other Netty channels (i.e. socket connections)
> # Camel waits for routes to be empty of inflight & pending exchanges
> # (!) Those other Netty channels kept receiving data, which are turned into
> new exchanges
> ** As long as the TCP clients keep sending data into the channels + exchanges
> completing slower than send rate, routes will _never_ be empty of inflight &
> pending exchanges
> # Forced shutdown after 5 minutes (timed out)
> h2. To simulate the issue
> # Run the attached [^tcp-server.camel] Groovy script: {{groovy
> tcp-server.camel}}
> # After that has started, run the attached [^tcp-client.groovy]: {{groovy
> tcp-client.groovy}}
> # After tcp-client starts sending data over, stop the tcp-server (CTRL+C in
> Windows)
> # You should see something like this:
> {panel:title=cmd}
> INFO - Apache Camel 2.15.2 (CamelContext: camel-1) started in 1.015 seconds
> INFO - Hey 0
> INFO - Hey 1
> INFO - Hey 2
> INFO - Hey 3
> INFO - Apache Camel 2.15.2 (CamelContext: camel-1) is shutting down
> INFO - Starting to graceful shutdown 1 routes (timeout 300 seconds)
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete,
> timeout in 300 seconds.
> INFO - Hey 4
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete,
> timeout in 299 seconds.
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete,
> timeout in 298 seconds.
> INFO - Hey 5
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete,
> timeout in 297 seconds.
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete,
> timeout in 296 seconds.
> INFO - Hey 6
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete,
> timeout in 295 seconds.
> INFO - Waiting as there are still 1 inflight and pending exchanges to
> complete,
> timeout in 294 seconds.
> ...
> {panel}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)