You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hzariv <hz...@ebay.com> on 2015/04/29 18:40:25 UTC

How to create case insensitive URI route with netty4-http?

I am using Camel netty4-http and want to create Consumer EndPoint which is
matches on case insensitive URI path. For example:

camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/Shopping");
or 
camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/shopping");

How can I do that?



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-case-insensitive-URI-route-with-netty4-http-tp5766517.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to create case insensitive URI route with netty4-http?

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Yeah I think there is some code that can be improved. I logged a ticket
https://issues.apache.org/jira/browse/CAMEL-8734

On Fri, May 1, 2015 at 9:54 PM, hzariv <hz...@ebay.com> wrote:
> I am trying to route a HTTP request from
> http://mycompany.com:8080/Shopping?..... to
> http://myservice.com:80/ws/svc/Shopping?..... which is my service end-point.
> Here is example of the code:
>
>
> public class ShopRoute extends RouteBuilder {
>
>         private CamelContext camelContext;
>
>
>         @Inject
>         public ShopRoute(CamelContext camelContext) {
>                 this.camelContext = camelContext;
>         }
>
>
>         @Override
>         public void configure() throws Exception {
>
>                 // This is my consumer
>                 Endpoint fromEndPoint =
> camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/Shopping");
>                 // This is my producer
>                 Endpoint shoppingLW = camelContext.getEndpoint(
>
> String.format("netty4-http:http://%s:80/ws/svc/Shopping?throwExceptionOnFailure=false",
> "myservice.com"));
>
>                 // route the request from http://mycompany.com:8080/Shopping?..... to
> http://myservice.com:80/ws/svc/Shopping?.....
>                 from(fromEndPoint).to(shoppingLW);
>         }
> }
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-create-case-insensitive-URI-route-with-netty4-http-tp5766517p5766580.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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/

Re: How to create case insensitive URI route with netty4-http?

Posted by hzariv <hz...@ebay.com>.
I am trying to route a HTTP request from
http://mycompany.com:8080/Shopping?..... to
http://myservice.com:80/ws/svc/Shopping?..... which is my service end-point.
Here is example of the code:


public class ShopRoute extends RouteBuilder {
	
        private CamelContext camelContext;
	
	
	@Inject
	public ShopRoute(CamelContext camelContext) {
		this.camelContext = camelContext;
	}


	@Override
	public void configure() throws Exception {
			
		// This is my consumer	
		Endpoint fromEndPoint =
camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/Shopping");
		// This is my producer
		Endpoint shoppingLW = camelContext.getEndpoint(
				
String.format("netty4-http:http://%s:80/ws/svc/Shopping?throwExceptionOnFailure=false",
"myservice.com"));
		
		// route the request from http://mycompany.com:8080/Shopping?..... to
http://myservice.com:80/ws/svc/Shopping?.....
		from(fromEndPoint).to(shoppingLW);
	}
}



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-case-insensitive-URI-route-with-netty4-http-tp5766517p5766580.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to create case insensitive URI route with netty4-http?

Posted by Claus Ibsen <cl...@gmail.com>.
On Thu, Apr 30, 2015 at 10:18 PM, hzariv <hz...@ebay.com> wrote:
> You are right. I turn on debug logging and I see what is happening. I have
> the following producer and consumer endpoints. Camel matches on the Consumer
> endpoint correctly (case insensitive) but the producer URL is created like:
> http://myapp.com:80/ws/svc/Shopping/shopping?callname=... (path is now
> /Shopping/shopping which is invalid) when I use /shopping on the request the
> producer URL is correct.
> How do I fix this?
>
> Consumer:
> camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/Shopping");
> Producer:
> camelContext.getEndpoint(String.format("netty4-http:http://%s:80/ws/svc/Shopping?throwExceptionOnFailure=false",
> "myapp.com"));
>

These 2 urls is not the same, one use port 8080, and the other port
80. And their context path is also different.

And its not clear what you do in your code. Do you do a consume ->
produce and expect somehow Camel to match those endpoints?
Can you explain and show code better?



> Hers is the DEBUG log:
>
> 11087 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] INFO  -
> ID-D-SJC-00531208-50165-1430420447613-0-2 >>> (route2)
> from(http://0.0.0.0:8080/Shopping) --> choice <<< Pattern:InOut,
> Headers:{Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,
> Accept-Encoding=gzip, deflate, Accept-Language=en-US,en;q=0.5, appid=xxxx,
> breadcrumbId=ID-D-SJC-00531208-50165-1430420447613-0-1,
> Cache-Control=max-age=0, callname=FindProducts, CamelHttpMethod=GET,
> CamelHttpPath=/shopping,
> CamelHttpQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
> CamelHttpRawQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
> CamelHttpUri=/shopping, CamelHttpUrl=http://0.0.0.0:8080/shopping,
> CamelNettyChannelHandlerContext=io.netty.channel.DefaultChannelHandlerContext@3042dc22,
> CamelNettyLocalAddress=/127.0.0.1:8080,
> CamelNettyRemoteAddress=/127.0.0.1:50489, Connection=keep-alive,
> Content-Length=0, Host=localhost:8080, If-Modified-Since=Thu, 30 Apr 2015
> 18:59:27 GMT, IncludeSelector=DomainHistogram, MaxEntries=2,
> ProductSort=Title, QueryKeywords=MC723LL, responseencoding=XML,
> SortOrder=Ascending, User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0)
> Gecko/20100101 Firefox/37.0, version=829},
> BodyType:org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache,
> Body:[Body is instance of org.apache.camel.StreamCache]
> 11128 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] INFO  -
> ID-D-SJC-00531208-50165-1430420447613-0-2 >>> (route2) choice -->
> http://myapp.com:80/ws/svc/Shopping <<< Pattern:InOut,
> Headers:{Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,
> Accept-Encoding=gzip, deflate, Accept-Language=en-US,en;q=0.5, appid=xxxx,
> breadcrumbId=ID-D-SJC-00531208-50165-1430420447613-0-1,
> Cache-Control=max-age=0, callname=FindProducts, CamelHttpMethod=GET,
> CamelHttpPath=/shopping,
> CamelHttpQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
> CamelHttpRawQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
> CamelHttpUri=/shopping, CamelHttpUrl=http://0.0.0.0:8080/shopping,
> CamelNettyChannelHandlerContext=io.netty.channel.DefaultChannelHandlerContext@3042dc22,
> CamelNettyLocalAddress=/127.0.0.1:8080,
> CamelNettyRemoteAddress=/127.0.0.1:50489, Connection=keep-alive,
> Content-Length=0, Host=localhost:8080, If-Modified-Since=Thu, 30 Apr 2015
> 18:59:27 GMT, IncludeSelector=DomainHistogram, MaxEntries=2,
> ProductSort=Title, QueryKeywords=MC723LL, responseencoding=XML,
> SortOrder=Ascending, User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0)
> Gecko/20100101 Firefox/37.0, version=829},
> BodyType:org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache,
> Body:[Body is instance of org.apache.camel.StreamCache]
> 11129 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - >>>>
> Endpoint[http://myapp.com:80/ws/svc/Shopping] Exchange[Message: [Body is
> instance of org.apache.camel.StreamCache]]
> 11138 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - Created
> new TCP client bootstrap connecting to myapp.com:80 with options:
> Bootstrap(group: NioEventLoopGroup, channelFactory: NioSocketChannel.class,
> options: {SO_KEEPALIVE=true, TCP_NODELAY=true, SO_REUSEADDR=true,
> CONNECT_TIMEOUT_MILLIS=10000}, handler:
> org.apache.camel.component.netty4.http.HttpClientInitializerFactory@765b53f)
> 11167 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - Creating
> connector to address: myapp.com:80
> 11169 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - Channel:
> [id: 0xae58aab0, /10.244.161.38:50490 => myapp.com/10.14.90.11:80] writing
> body: DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1,
> content: UnpooledUnsafeDirectByteBuf(ridx: 0, widx: 0, cap: 0))
> GET http://myapp.com:80/ws/svc/Shopping/shopping?callname=FindProducts.....
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-create-case-insensitive-URI-route-with-netty4-http-tp5766517p5766558.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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/

Re: How to create case insensitive URI route with netty4-http?

Posted by hzariv <hz...@ebay.com>.
You are right. I turn on debug logging and I see what is happening. I have
the following producer and consumer endpoints. Camel matches on the Consumer
endpoint correctly (case insensitive) but the producer URL is created like:
http://myapp.com:80/ws/svc/Shopping/shopping?callname=... (path is now
/Shopping/shopping which is invalid) when I use /shopping on the request the
producer URL is correct.
How do I fix this?

Consumer:
camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/Shopping");
Producer:
camelContext.getEndpoint(String.format("netty4-http:http://%s:80/ws/svc/Shopping?throwExceptionOnFailure=false",
"myapp.com"));

Hers is the DEBUG log:

11087 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] INFO  -
ID-D-SJC-00531208-50165-1430420447613-0-2 >>> (route2)
from(http://0.0.0.0:8080/Shopping) --> choice <<< Pattern:InOut,
Headers:{Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,
Accept-Encoding=gzip, deflate, Accept-Language=en-US,en;q=0.5, appid=xxxx,
breadcrumbId=ID-D-SJC-00531208-50165-1430420447613-0-1,
Cache-Control=max-age=0, callname=FindProducts, CamelHttpMethod=GET,
CamelHttpPath=/shopping,
CamelHttpQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
CamelHttpRawQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
CamelHttpUri=/shopping, CamelHttpUrl=http://0.0.0.0:8080/shopping,
CamelNettyChannelHandlerContext=io.netty.channel.DefaultChannelHandlerContext@3042dc22,
CamelNettyLocalAddress=/127.0.0.1:8080,
CamelNettyRemoteAddress=/127.0.0.1:50489, Connection=keep-alive,
Content-Length=0, Host=localhost:8080, If-Modified-Since=Thu, 30 Apr 2015
18:59:27 GMT, IncludeSelector=DomainHistogram, MaxEntries=2,
ProductSort=Title, QueryKeywords=MC723LL, responseencoding=XML,
SortOrder=Ascending, User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0)
Gecko/20100101 Firefox/37.0, version=829},
BodyType:org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache,
Body:[Body is instance of org.apache.camel.StreamCache]
11128 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] INFO  -
ID-D-SJC-00531208-50165-1430420447613-0-2 >>> (route2) choice -->
http://myapp.com:80/ws/svc/Shopping <<< Pattern:InOut,
Headers:{Accept=text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8,
Accept-Encoding=gzip, deflate, Accept-Language=en-US,en;q=0.5, appid=xxxx,
breadcrumbId=ID-D-SJC-00531208-50165-1430420447613-0-1,
Cache-Control=max-age=0, callname=FindProducts, CamelHttpMethod=GET,
CamelHttpPath=/shopping,
CamelHttpQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
CamelHttpRawQuery=callname=FindProducts&responseencoding=XML&appid=xxxx&version=829&QueryKeywords=MC723LL&MaxEntries=2&ProductSort=Title&IncludeSelector=DomainHistogram&SortOrder=Ascending,
CamelHttpUri=/shopping, CamelHttpUrl=http://0.0.0.0:8080/shopping,
CamelNettyChannelHandlerContext=io.netty.channel.DefaultChannelHandlerContext@3042dc22,
CamelNettyLocalAddress=/127.0.0.1:8080,
CamelNettyRemoteAddress=/127.0.0.1:50489, Connection=keep-alive,
Content-Length=0, Host=localhost:8080, If-Modified-Since=Thu, 30 Apr 2015
18:59:27 GMT, IncludeSelector=DomainHistogram, MaxEntries=2,
ProductSort=Title, QueryKeywords=MC723LL, responseencoding=XML,
SortOrder=Ascending, User-Agent=Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0)
Gecko/20100101 Firefox/37.0, version=829},
BodyType:org.apache.camel.component.netty4.http.NettyChannelBufferStreamCache,
Body:[Body is instance of org.apache.camel.StreamCache]
11129 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - >>>>
Endpoint[http://myapp.com:80/ws/svc/Shopping] Exchange[Message: [Body is
instance of org.apache.camel.StreamCache]]
11138 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - Created
new TCP client bootstrap connecting to myapp.com:80 with options:
Bootstrap(group: NioEventLoopGroup, channelFactory: NioSocketChannel.class,
options: {SO_KEEPALIVE=true, TCP_NODELAY=true, SO_REUSEADDR=true,
CONNECT_TIMEOUT_MILLIS=10000}, handler:
org.apache.camel.component.netty4.http.HttpClientInitializerFactory@765b53f)
11167 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - Creating
connector to address: myapp.com:80
11169 [Camel (camel-1) thread #0 - NettyEventExecutorGroup] DEBUG - Channel:
[id: 0xae58aab0, /10.244.161.38:50490 => myapp.com/10.14.90.11:80] writing
body: DefaultFullHttpRequest(decodeResult: success, version: HTTP/1.1,
content: UnpooledUnsafeDirectByteBuf(ridx: 0, widx: 0, cap: 0))
GET http://myapp.com:80/ws/svc/Shopping/shopping?callname=FindProducts.....



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-create-case-insensitive-URI-route-with-netty4-http-tp5766517p5766558.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to create case insensitive URI route with netty4-http?

Posted by Claus Ibsen <cl...@gmail.com>.
Can you tell more what you mean?

The netty4-http component uses a case insenstive uri path matcher.

On Wed, Apr 29, 2015 at 6:40 PM, hzariv <hz...@ebay.com> wrote:
> I am using Camel netty4-http and want to create Consumer EndPoint which is
> matches on case insensitive URI path. For example:
>
> camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/Shopping");
> or
> camelContext.getEndpoint("netty4-http:http://0.0.0.0:8080/shopping");
>
> How can I do that?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-create-case-insensitive-URI-route-with-netty4-http-tp5766517.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
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/