camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Soto <alex.s...@envieta.com>
Subject Re: Using shared Netty configuration with Rest DSL
Date Tue, 26 May 2015 12:34:57 GMT
Hi,

It appears to be working with the following:

	<!— 
		SSL configuration Notice we read the certificate file from the user 
		home directory. {{env:HOME}} is expanded to the current user's home directory. 
	 -->
	<camel:sslContextParameters id="sslParams">
		<camel:keyManagers keyPassword="changeit">
			<camel:keyStore resource="{{env:HOME}}/localhost.jks"
				password="changeit" type="JKS" provider="SUN" />
		</camel:keyManagers>
		<camel:trustManagers>
			<camel:keyStore resource="{{env:HOME}}/localhost.jks"
				password="changeit" type="JKS" provider="SUN" />
		</camel:trustManagers>
	</camel:sslContextParameters>

	<!-- Netty's HTTP bootstrap configuration -->
	<bean id="configuration" class="org.apache.camel.component.netty4.http.NettySharedHttpServerBootstrapConfiguration">
		<property name="port" value="8890" />
		<property name="host" value="0.0.0.0" />
		<property name="backlog" value="50" />
		<property name="sslContextParameters" ref="sslParams" />
		<property name="ssl" value="true" />
	</bean>

	<!-- Netty HTTP server, which can be shared between multiple routes -->
	<bean id="sharedNettyHttpServer" 
		class="org.apache.camel.component.netty4.http.DefaultNettySharedHttpServer"
		init-method="start" 
		destroy-method="stop">
	
		<property name="nettyServerBootstrapConfiguration" ref="configuration" />
	</bean>

	<camelContext xmlns="http://camel.apache.org/schema/spring">
		<restConfiguration component="netty4-http" >
			<endpointProperty key="nettySharedHttpServer" value="#sharedNettyHttpServer" />
		</restConfiguration>

		<!-- REST Service Definition -->
		<rest path="/visitor/">
			<get uri="/">
				<camel:description>Return list of known visitors</camel:description>
				<to uri="direct:list" />
			</get>
		</rest>
		…


However, it is not clear from the documentation the difference between “componentProperty”
 and “endpointProperty” and when to use each, so please let me know if I am misusing this
in any way.

Best regards,
Alex soto

> On May 26, 2015, at 5:42 AM, Claus Ibsen <claus.ibsen@gmail.com> wrote:
> 
> Hi
> 
> Ah maybe there is a glitch configuring those on the component level?
> 
> You are welcome to log a JIRA so we wont forget. On the component
> level makes it configurable once for end users, when they eg use it
> with regular Camel routes, and not as much the rest-dsl.
> 
> 
> On Fri, May 22, 2015 at 2:47 PM, Alex Soto <alex.soto@envieta.com> wrote:
>> It is working now.  Thanks!
>> 
>> Best regards,
>> Alex soto
>> 
>>> On May 22, 2015, at 3:53 AM, Willem Jiang <willem.jiang@gmail.com> wrote:
>>> 
>>> You can setup the endpoint property just like this
>>> 
>>> <restConfiguration component="netty4-http” >
>>> <camel:componentProperty key=“configuration" value="#configuration"/>
>>> <camel:endpointProperty key=“nettySharedHttpServer" value="#sharedNettyHttpServer"/>
>>> <camel:endpointProperty key=“securityConfiguration" value=“#securityConfiguration"/>
>>> </restConfiguration>
>>> 
>>> BTW, you need to create the securityConfiguration yourself.
>>> 
>>> 
>>> 
>>> --
>>> 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 May 22, 2015 at 3:06:20 AM, Alex Soto (alex.soto@envieta.com) wrote:
>>>> I would like to reuse the same Netty Service that is configured outside of
the Rest DSL.
>>>> For example I have the Netty and SSL configuration:
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> type="JKS" provider="SUN"/>
>>>> 
>>>> 
>>>>> type="JKS" provider="SUN"/>
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>>> init-method="start" destroy-method="stop">
>>>> 
>>>> 
>>>> 
>>>> 
>>>> Now in my Camel Context I declare the Rest DSL:
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> 
>>>> However, it does not seem to be picking up the shared configuration. Log
file shows:
>>>> 
>>>> BootstrapFactory on port 0 is using bootstrap configuration: [NettyServerBootstrapConfiguration{protocol='tcp',
>>>> host=‘XXXXX.local', port=0, broadcast=false, sendBufferSize=65536, receiveBufferSize=65536,
>>>> receiveBufferSizePredictor=0, workerCount=0, bossCount=1, keepAlive=true,
tcpNoDelay=true,
>>>> reuseAddress=true, connectTimeout=10000, backlog=0, serverInitializerFactory=org.apache.camel.component.netty4.http.HttpServerInitializerFactory@2db0d008,
>>>> nettyServerBootstrapFactory=null, options=null, ssl=false, sslHandler=null,
>>>> sslContextParameters='null', needClientAuth=false, enabledProtocols='TLSv1,TLSv1.1,TLSv1.2,
>>>> keyStoreFile=null, trustStoreFile=null, keyStoreResource='null', trustStoreResource='null',
>>>> keyStoreFormat='JKS', securityProvider='SunX509', passphrase='null', bossGroup=null,
>>>> workerGroup=null, networkInterface='null’}]
>>>> 
>>>> I could not find any examples of how to accomplish this. Any hints?
>>>> 
>>>> Best regards,
>>>> Alex soto
>>> 
>> 
> 
> 
> 
> -- 
> Claus Ibsen
> -----------------
> Red Hat, Inc.
> Email: cibsen@redhat.com
> Twitter: davsclaus
> Blog: http://davsclaus.com
> Author of Camel in Action: http://www.manning.com/ibsen
> hawtio: http://hawt.io/
> fabric8: http://fabric8.io/


Mime
View raw message