Re: Why so many port used when I use camel-netty4-http

2015-04-14 Thread Yuffie
Hi,Willem
Thanks for your help!
I think I need to read the document carefully first. 
Again, thank you!



--
View this message in context: 
http://camel.465427.n5.nabble.com/Why-so-many-port-used-when-I-use-camel-netty4-http-tp5765433p5765810.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Why so many port used when I use camel-netty4-http

2015-04-14 Thread Yuffie
Hi,Yogesh.
Thanks for help!
Since I don't have a Linux environment, I don't if it work on Linux. But it
work in win7.
And I will try what you said.
Again thank you.



--
View this message in context: 
http://camel.465427.n5.nabble.com/Why-so-many-port-used-when-I-use-camel-netty4-http-tp5765433p5765806.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Why so many port used when I use camel-netty4-http

2015-04-14 Thread Willem Jiang
Hi Yuffie

I just went through the link which explains that why windows need to establish 
loopback connection for selector. It looks like you use camel camel-netty4-http 
to build a proxy to route the message for you. 

Now back to camel-netty4-http, there is a producer pool which cache the Channel 
object for about 300 seconds and 100 max idle per camel-netty4-http endpoint. 
If you don’t want keep the connection open for a while, you may think to set 
*producerPoolEnabled* option to be false, then camel-netty4-http will don’t  
pool the connection for you.

If you want to try to turn the producer pool yourself, please check this[1] and 
search ProducerPool for more information.

[1]https://camel.apache.org/netty4

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 15, 2015 at 9:51:53 AM, Yuffie (yuffie.pa...@gmail.com) wrote:
> Hi,Willem.
> this is my RouteBuilder:
> ---
> public class MobileRouteBuilder extends RouteBuilder implements
> PropertyConstants {
>  
> private String port;
>  
> public void setPort(String port) {
> this.port = port;
> }
>  
> private Tracer tracer = new Tracer();
>  
> /**
> * 设置tracer的开关
> *
> * @param exchange
> * tracer
> * @return String
> *
> */
> public void setTracing(Exchange exchange) {
> Message in = exchange.getIn();
> String enabletracer = (String) in.getHeader("tracer");
> if (enabletracer.equalsIgnoreCase("true")) {
> tracer.setEnabled(true);
> in.setBody("tracer on");
> } else {
> tracer.setEnabled(false);
> in.setBody("tracer off");
> }
> }
>  
> @Override
> public void configure() throws Exception {
>  
> // 通过手动新建tracer并设置setEnabled(false),能够在路由中加入一个不启用的tracer
> tracer.setEnabled(false);
> getContext().addInterceptStrategy(tracer);
>  
> Set keyset =
> IntegrationServiceUtil.integrationServiceMap.keySet();
> Map routeMap = new HashMap();
> String value = null;
> StringBuffer strbuf = new StringBuffer();
> for (String k : keyset) {
> value = IntegrationServiceUtil.integrationServiceMap.get(k);
> if (value != null) {
> URL url = new URL(value);
> if (url.getPort()<0) {
> strbuf.append("netty4-http:")
>  
> .append(url.getProtocol()).append("://").append(url.getHost()).append(":80").append(url.getFile())
>   
> .append("?" +
> "bridgeEndpoint=true&throwExceptionOnFailure=false");
> } else {
> strbuf.append("netty4-http:").append(value)
> .append("?" +
> "bridgeEndpoint=true&throwExceptionOnFailure=false");
> }
> routeMap.put(k, strbuf.toString());
> }
> value = null;
> strbuf = new StringBuffer();
> }
>  
> from("netty4-http:http://0.0.0.0:"; + port + "/rest?" +
> "bridgeEndpoint=true&matchOnUriPrefix=true")
> .process(new LogProcessor())
> .process(new UTF8ToGBKProcessor())
> .process(new AdapterProcessor())
> .process(new IfAddUccodeProcess())
> .choice()
> .when(header("serviceNickName").isNull())
> .to(routeMap.get("business"))
> .when(header("serviceNickName").isEqualTo(PRODUCTNICK))
> .to(routeMap.get("i6p"))
> .when(header("serviceNickName").isEqualTo(WORKFLOWNICK))
> .to(routeMap.get("workflow"))
> .when(header("serviceNickName").isEqualTo(BUSINESSNICK))
> .to(routeMap.get("business"))
> .when(header("serviceNickName").isEqualTo(NETCALLNICK))
> .to(routeMap.get("netcallservice"))
> .when(header("serviceNickName").isEqualTo(AUTHNICK))
> .to(routeMap.get("EnterpriseInfoService"))
> .when(header("serviceNickName").isEqualTo(UPDATENICK))
> .to(routeMap.get("NetCallUpdateService"))
>  
> .when(header("serviceNickName").isEqualTo("LoopbackDetection"))
> .bean(new LoopbackDetectionEndpoint())
> .when(header("serviceNickName").isEqualTo("SetTracing"))
> .beanRef("mobileRouteBuilder", "setTracing")
> .endChoice()
>  
> .end();
>  
> from("servlet:///?matchOnUriPrefix=true&bridgeEndpoint=true")
> .process(new ServletAdapterProcessor())
> .choice()
> .when(header("serviceNickName").isEqualTo(AUTHNICK))
> .process(new SplitProcessor())
> .choice()
>  
> .when(header("EnterpriseInfoServiceRoute").isEqualTo("getauthusers"))
> .to(routeMap.get("EnterpriseInfoService"))
> .bean(new GetNCInfoEndpoint())
>  
> .when(header("EnterpriseInfoServiceRoute").isEqualTo("authdevices"))
> .process(new IfCanAuthProcessor())
> .choice()
> .when(header("CanAuth").isEqualTo("true"))
>  
> .to(routeMap.get("EnterpriseInfoService"))
> .endChoice()
>  
> .when(header("EnterpriseInfoServiceRoute").isEqualTo("other"))
> .to(routeMap.get("EnterpriseInfoService"))
> .endChoice()
> .when(header("serviceNickName").isEqualTo(PRODUCTNICK))
> .to(routeMap.get("i6p"))
> .when(header("serviceNickName").isEqualTo("properties"))
> .bean(new PropertyEndpoint())
> .endChoice()
> .end();
> }
> }
>  
> ---
>  
> And this is deployed in the Tomcat.
>  
> And we find that it maybe an issue of netty:
> http://blog.csdn.net/haoel/article/details/2224055
>  
>  
>  

Re: Why so many port used when I use camel-netty4-http

2015-04-14 Thread yogu13
Hello,

Apart from the above can you provide us following info !!

1. How many ports are opened (delta) for the route which is getting
created?? You can do this by taking a note of all the ports opened when you
application is down and then take a note of the ports open once your
application is up and remove the common ports from the list

2. How does tomcat come into picture? is this deployed on tomcat ? what port
is your tomcat working on.

3. What version of OS and JDK and camel are you using.

Regards,
-Yogesh



--
View this message in context: 
http://camel.465427.n5.nabble.com/Why-so-many-port-used-when-I-use-camel-netty4-http-tp5765433p5765799.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Why so many port used when I use camel-netty4-http

2015-04-14 Thread yogu13
Thanks!

Is this working properly in any of the environments ?

Also you try configuring the bootstrap options like keepAlive, Timeout's and
disconnect for netty endpoint ?

check "Reusing same server bootstrap configuration with multiple routes"
section in http://camel.apache.org/netty4-http.html

Regards,
-Yogesh



--
View this message in context: 
http://camel.465427.n5.nabble.com/Why-so-many-port-used-when-I-use-camel-netty4-http-tp5765433p5765802.html
Sent from the Camel - Users mailing list archive at Nabble.com.


Re: Why so many port used when I use camel-netty4-http

2015-04-14 Thread Yuffie
Hi,Willem.
this is my RouteBuilder:
---
public class MobileRouteBuilder extends RouteBuilder implements
PropertyConstants {

private String port;

public void setPort(String port) {
this.port = port;
}

private Tracer tracer = new Tracer();

/**
 * 设置tracer的开关
 * 
 * @param exchange
 *tracer
 * @return String
 * 
 */
public void setTracing(Exchange exchange) {
Message in = exchange.getIn();
String enabletracer = (String) in.getHeader("tracer");
if (enabletracer.equalsIgnoreCase("true")) {
tracer.setEnabled(true);
in.setBody("tracer on");
} else {
tracer.setEnabled(false);
in.setBody("tracer off");
}
}

@Override
public void configure() throws Exception {

// 通过手动新建tracer并设置setEnabled(false),能够在路由中加入一个不启用的tracer
tracer.setEnabled(false);
getContext().addInterceptStrategy(tracer);

Set keyset =
IntegrationServiceUtil.integrationServiceMap.keySet();
Map routeMap = new HashMap();
String value = null;
StringBuffer strbuf = new StringBuffer();
for (String k : keyset) {
value = IntegrationServiceUtil.integrationServiceMap.get(k);
if (value != null) {
URL url = new URL(value);
if (url.getPort()<0) {
strbuf.append("netty4-http:")
   
.append(url.getProtocol()).append("://").append(url.getHost()).append(":80").append(url.getFile())
.append("?" +
"bridgeEndpoint=true&throwExceptionOnFailure=false");
} else {
strbuf.append("netty4-http:").append(value)
.append("?" +
"bridgeEndpoint=true&throwExceptionOnFailure=false");
}
routeMap.put(k, strbuf.toString());
}
value = null;
strbuf = new StringBuffer();
}

from("netty4-http:http://0.0.0.0:"; + port + "/rest?" +
"bridgeEndpoint=true&matchOnUriPrefix=true")
.process(new LogProcessor())
.process(new UTF8ToGBKProcessor())
.process(new AdapterProcessor())
.process(new IfAddUccodeProcess())
.choice()
.when(header("serviceNickName").isNull())
.to(routeMap.get("business"))
.when(header("serviceNickName").isEqualTo(PRODUCTNICK))
.to(routeMap.get("i6p"))
.when(header("serviceNickName").isEqualTo(WORKFLOWNICK))
.to(routeMap.get("workflow"))
.when(header("serviceNickName").isEqualTo(BUSINESSNICK))
.to(routeMap.get("business"))
.when(header("serviceNickName").isEqualTo(NETCALLNICK))
.to(routeMap.get("netcallservice"))
.when(header("serviceNickName").isEqualTo(AUTHNICK))
.to(routeMap.get("EnterpriseInfoService"))
.when(header("serviceNickName").isEqualTo(UPDATENICK))
.to(routeMap.get("NetCallUpdateService"))
   
.when(header("serviceNickName").isEqualTo("LoopbackDetection"))
.bean(new LoopbackDetectionEndpoint())
.when(header("serviceNickName").isEqualTo("SetTracing"))
.beanRef("mobileRouteBuilder", "setTracing")
.endChoice()

.end();

from("servlet:///?matchOnUriPrefix=true&bridgeEndpoint=true")
.process(new ServletAdapterProcessor())
.choice()
.when(header("serviceNickName").isEqualTo(AUTHNICK))
.process(new SplitProcessor())
.choice()
   
.when(header("EnterpriseInfoServiceRoute").isEqualTo("getauthusers"))
.to(routeMap.get("EnterpriseInfoService"))
.bean(new GetNCInfoEndpoint())
   
.when(header("EnterpriseInfoServiceRoute").isEqualTo("authdevices"))
.process(new IfCanAuthProcessor())
.choice()
.when(header("CanAuth").isEqualTo("true"))
   
.to(routeMap.get("EnterpriseInfoService"))
.endChoice()
   
.when(header("EnterpriseInfoServiceRoute").isEqualTo("other"))
.to(routeMap.get("EnterpriseInfoService"))
.endChoice()
.when(header("serviceNickName").isEqualTo(PRODUCTNICK))
.to(routeMap.get("i6p"))
.when(header("serviceNickName").isEqualTo("properties"))
.bean(new PropertyEndpoint())
.endChoice()
.end();
}
}

---

Re: Why so many port used when I use camel-netty4-http

2015-04-09 Thread Willem Jiang
I don’t think camel-netty4-http can open those ports like you side.

What’s your camel route looks like?
Did you just deploy the camel route inside the tomcat?


--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 7, 2015 at 8:24:05 PM, Yuffie (yuffie.pa...@gmail.com) wrote:
> Hi,
> when I use netty4-http compoment, I found it use a lot ports which I have
> not defined in my program:
>  
> 协议 本地地址 外部地址 状态 PID
> TCP 0.0.0.0:80 0.0.0.0:0 LISTENING 1080
> TCP 0.0.0.0:135 0.0.0.0:0 LISTENING 992
> TCP 0.0.0.0:445 0.0.0.0:0 LISTENING 4
> TCP 0.0.0.0:1025 0.0.0.0:0 LISTENING 560
> TCP 0.0.0.0:1026 0.0.0.0:0 LISTENING 676
> TCP 0.0.0.0:1027 0.0.0.0:0 LISTENING 480
> TCP 0.0.0.0:1028 0.0.0.0:0 LISTENING 1036
> TCP 0.0.0.0:1042 0.0.0.0:0 LISTENING 668
> TCP 0.0.0.0:3306 0.0.0.0:0 LISTENING 2924
> TCP 0.0.0.0:8009 0.0.0.0:0 LISTENING 10368
> TCP 0.0.0.0:8080 0.0.0.0:0 LISTENING 10368
> TCP 0.0.0.0:8082 0.0.0.0:0 LISTENING 10368
> TCP 0.0.0.0:12025 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:12110 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:12119 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:12143 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:12465 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:12563 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:12993 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:12995 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:27275 0.0.0.0:0 LISTENING 1460
> TCP 0.0.0.0:62332 0.0.0.0:0 LISTENING 1512
> TCP 127.0.0.1:1135 0.0.0.0:0 LISTENING 8496
> TCP 127.0.0.1:8005 0.0.0.0:0 LISTENING 10368
> TCP 127.0.0.1:1 0.0.0.0:0 LISTENING 2980
> TCP 127.0.0.1:10015 0.0.0.0:0 LISTENING 1512
> TCP 127.0.0.1:12025 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:12110 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:12119 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:12143 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:12465 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:12563 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:12993 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:12995 0.0.0.0:0 LISTENING 1460
> TCP 127.0.0.1:17568 127.0.0.1:17570 ESTABLISHED 1620
> TCP 127.0.0.1:17570 127.0.0.1:17568 ESTABLISHED 10368
> TCP 127.0.0.1:17573 127.0.0.1:17574 ESTABLISHED 10368
> TCP 127.0.0.1:17574 127.0.0.1:17573 ESTABLISHED 10368
> TCP 127.0.0.1:17575 127.0.0.1:17576 ESTABLISHED 10368
> TCP 127.0.0.1:17576 127.0.0.1:17575 ESTABLISHED 10368
> TCP 127.0.0.1:17580 127.0.0.1:17581 ESTABLISHED 10368
> TCP 127.0.0.1:17581 127.0.0.1:17580 ESTABLISHED 10368
> TCP 127.0.0.1:17582 127.0.0.1:17583 ESTABLISHED 10368
> TCP 127.0.0.1:17583 127.0.0.1:17582 ESTABLISHED 10368
> TCP 127.0.0.1:17584 127.0.0.1:17585 ESTABLISHED 10368
> TCP 127.0.0.1:17585 127.0.0.1:17584 ESTABLISHED 10368
> TCP 127.0.0.1:17586 127.0.0.1:17587 ESTABLISHED 10368
> TCP 127.0.0.1:17587 127.0.0.1:17586 ESTABLISHED 10368
> TCP 127.0.0.1:17588 127.0.0.1:17589 ESTABLISHED 10368
> TCP 127.0.0.1:17589 127.0.0.1:17588 ESTABLISHED 10368
> TCP 127.0.0.1:17590 127.0.0.1:17591 ESTABLISHED 10368
> TCP 127.0.0.1:17591 127.0.0.1:17590 ESTABLISHED 10368
> TCP 127.0.0.1:17592 127.0.0.1:17593 ESTABLISHED 10368
> TCP 127.0.0.1:17593 127.0.0.1:17592 ESTABLISHED 10368
> TCP 127.0.0.1:17594 127.0.0.1:17595 ESTABLISHED 10368
> TCP 127.0.0.1:17595 127.0.0.1:17594 ESTABLISHED 10368
> TCP 127.0.0.1:17596 127.0.0.1:17597 ESTABLISHED 10368
> TCP 127.0.0.1:17597 127.0.0.1:17596 ESTABLISHED 10368
> TCP 127.0.0.1:17598 127.0.0.1:17599 ESTABLISHED 10368
> TCP 127.0.0.1:17599 127.0.0.1:17598 ESTABLISHED 10368
> TCP 127.0.0.1:17600 127.0.0.1:17601 ESTABLISHED 10368
> TCP 127.0.0.1:17601 127.0.0.1:17600 ESTABLISHED 10368
> TCP 127.0.0.1:17602 127.0.0.1:17603 ESTABLISHED 10368
> TCP 127.0.0.1:17603 127.0.0.1:17602 ESTABLISHED 10368
> TCP 127.0.0.1:17604 127.0.0.1:17605 ESTABLISHED 10368
> TCP 127.0.0.1:17605 127.0.0.1:17604 ESTABLISHED 10368
> TCP 127.0.0.1:27275 0.0.0.0:0 LISTENING 1460
> TCP 192.168.6.111:139 0.0.0.0:0 LISTENING 4
> TCP 192.168.6.111:1173 180.153.160.237:80 CLOSE_WAIT 9064
> TCP 192.168.6.111:1195 180.153.160.237:80 CLOSE_WAIT 9064
> TCP 192.168.6.111:1197 180.153.160.237:80 CLOSE_WAIT 9064
> TCP 192.168.6.111:1240 180.153.160.237:80 CLOSE_WAIT 9064
> TCP 192.168.6.111:1642 180.153.160.237:80 CLOSE_WAIT 9064
> TCP 192.168.6.111:2938 180.149.138.98:80 ESTABLISHED 7868
> TCP 192.168.6.111:13364 60.28.215.83:80 ESTABLISHED 7868
> TCP 192.168.6.111:17234 119.161.83.27:443 ESTABLISHED 7868
> TCP 192.168.6.111:17327 180.153.160.237:80 CLOSE_WAIT 9064
> TCP 192.168.6.111:17606 119.161.83.27:443 ESTABLISHED 7868
> TCP 192.168.6.111:17619 119.161.83.27:443 ESTABLISHED 7868
> TCP 192.168.6.111:17621 119.161.83.27:443 ESTABLISHED 7868
> TCP 192.168.6.111:17640 119.161.83.27:443 ESTABLISHED 7868
> TCP 192.168.6.111:17641 119.161.83.27:443 TIME_WAIT 0
> TCP 192.168.6.111:17646 164.46.204.84:443 SYN_SENT 1460
> TCP 192.168.6.111:17647 180.149.153.11:80 ESTABLISHED 7868
> TCP [::]:135 [::]:0 LISTENING 992
> TCP [::]:445 [::]:0 LISTENING 4
>