1 of 1 people found this helpful
A very long time ago I ran a Snappy Compression POC and the results were not very promising (memory consumption was quite high and there was additional delay caused by the compression).
So I would recommend measuring performance, payloads and number of created objects very carefully before investing more into compression.
But let me go back to your questions... You want to use both REST and Memcached so you probably need to turn on Compatibility mode. I'm not sure how the compression interceptor fits into this, so I would disable it and focus on integrating REST and Memcached services at first.
REST Server is a bit tricky because this is not a Web App. It's based on Netty and you need to use a RestServerConfigurationBuilder to prepare configuration and kick it off by creating an instance of NettyRestServer and calling start method. Of course things like Actuator won't work with it (as I mentioned before... it's not a typical web app).
There's also another idea which might work. Our REST server contains a class called Server. It's nothing more than JAX-RS annotated resource which handles all REST operations in Infinispan. You could probably use that somehow and instruct Spring to pick it up (but I'm not entirely sure how - probably you would need to look it up in Spring's manual).
Hi Sebastian, first of all thank you for the tips, I will try first using the compatibility mode and integrating it as you described in the beginning. However, if it doesn't work too well, and by that I mean, if it is too much work or the results were not that favorable, I will try implementing my own REST server interface for it. It should not be very hard since Infinispan has already that Server class, so I can base most of my code in that. But, I will do it using a spring-boot, to provide a better and easy solution not only for me, but if other people are interested in using such features, and don't want to configure all that stuff, they can check later on my github.
I will try those solutions on this weekend, and on Sunday night, probably on Monday I will let you know.
Thanks for helping me out.
Hi Sebastian, I just solved my initial problem. Some part of your answer, really helped, when you talked about the NettyRestServer. Now I could integrate the Rest Server with Memcached Server, and have everything on both of them working. I just found in the beginning a bit confusing using that war file as a dependency in maven, but after solving that, it was just a matter of sharing the same CacheManager with MemcachedServer and the NettyRestServer.
However, now it brings me a new problem, that is: Everything works IF I dont have custom interceptors in the configuration of my cache. Because, if I add a custom interceptor, everything starts, and I can use my interceptor, but when I use anything from the rest server, let's say I want to use a GET method that lists all keys in my cache, it gives an error saying:
2016-09-25 22:25:29.394 WARN 56018 --- [ntLoopGroup-5-1] io.netty.channel.DefaultChannelPipeline : An exception was thrown by a user handler's exceptionCaught() method while handling the following exception:
java.lang.IllegalStateException: Already committed
at org.jboss.resteasy.plugins.server.netty.NettyHttpResponse.reset(NettyHttpResponse.java:148) ~[resteasy-netty4-3.0.11.Final.jar:na]
at org.jboss.resteasy.plugins.server.netty.RequestHandler.channelRead0(RequestHandler.java:62) ~[resteasy-netty4-3.0.11.Final.jar:na]
at io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:105) ~[netty-all-4.0.36.Final.jar:4.0.36.Final]
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:292) [netty-all-4.0.36.Final.jar:4.0.36.Final]
at io.netty.channel.AbstractChannelHandlerContext.access$600(AbstractChannelHandlerContext.java:32) [netty-all-4.0.36.Final.jar:4.0.36.Final]
at io.netty.channel.AbstractChannelHandlerContext$7.run(AbstractChannelHandlerContext.java:283) [netty-all-4.0.36.Final.jar:4.0.36.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:358) [netty-all-4.0.36.Final.jar:4.0.36.Final]
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:374) [netty-all-4.0.36.Final.jar:4.0.36.Final]
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:112) [netty-all-4.0.36.Final.jar:4.0.36.Final]
at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:137) [netty-all-4.0.36.Final.jar:4.0.36.Final]
at java.lang.Thread.run(Thread.java:745) [na:1.8.0_102]
Any ideas on how to add a custom interceptor when having a MemcachedServer and a NettyRestServer ?
The stacktrace you sent looks like a result of an error which happened before (an exception caught in RequestHandler:62 which caused connection to be reset).
Could you please debug it further? What exception caused it? What happened before that?
Hi Sebastian, thanks for your help but after many attempts, I decided to create a new REST API using spring-boot for infinispan, since I think this way other people can benefit from my code and also make it more flexible.
No problem. Sorry it didn't work in your case
Once you implemented the REST server in Spring Boot, would you be so kind to share it with me? Maybe our approach needs to be more flexible to support such use cases in the future.