# Integration framework for Jersey app?

**URL:** <https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952>\
**Category:** Elasticsearch\
**Created:** [February 28, 2013, 2:14pm UTC](https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952 "2013-02-28T14:14:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![timrobertson100](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timrobertson100/32/2467_2.png) [@timrobertson100](https://discuss.elastic.co/u/timrobertson100)\
**Post date:** [February 28, 2013, 2:14pm UTC](https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952/1 "2013-02-28T14:14:55Z")

</div>

Hi all,

I have a simple RESTful application (Jersey, Guice, MyBATIS) and would like  
to add search support using ES (previously we've used SOLR).

My app is all Guice wired, and I was thinking I would do a method  
interceptor for the mutator methods, and then either maintain the index or  
fire a RabbitMQ message and use the RMQ river (probably I would do the  
former).

It seems to me though, that what I am trying to do is so common there might  
be a framework already for this?

I have googled a bit, but found nothing specific. Am I missing something?  
(I am a newbie in ES)

Ideally I would expect I can have something like this with a single  
annotation to maintain the index, which would be handled by some method  
interceptor:

@Singleton  
@Path("node")  
public class NodeResource implements NodeService {

private final NodeMapper nodeMapper;

@Inject  
public NodeResource(NodeMapper nodeMapper) {  
this.nodeMapper = nodeMapper;  
}

@PUT  
@SOME\_ANNOTATION\_HERE  
@Override  
public void update(Node entity) {  
WithMyBatis.update(nodeMapper, entity);  
}  
...  
}

Any suggestions from those with experience would be greatly appreciated (we  
can tolerate short lived inconsistency, and the index is going to be small).

Cheers,  
Tim

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Paul\_Sanwald\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_sanwald_2/32/881_2.png) [@Paul\_Sanwald\_2](https://discuss.elastic.co/u/Paul_Sanwald_2)\
**Post date:** [February 28, 2013, 6:40pm UTC](https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952/2 "2013-02-28T18:40:06Z")

</div>

Hi Tim,  
So, not sure this is quite the answer you're looking for, but I also  
have a java webapp with an elasticsearch component, and I've found it  
useful to fire up my elasticsearch nodes in my webapp itself, I use  
[https://github.com/elasticsearch/elasticsearch-transport-wares](https://github.com/elasticsearch/elasticsearch-transport-wares) to do this.  
Then, in web.xml I just:  
  
node  
org.elasticsearch.wares.NodeServlet  
1

I have one node per instance of my web application; I actually prefer this,  
but this route does remove the ability to separate your elasticsearch nodes  
from your web application (the plus side is you don't have to manage both).

Then, when I want to use it from a controller or similar, I just inject a  
(spring configured, in my case) TransportClient. Pretty sure you could  
guice configure a TransportClient relatively easily, it just needs a few  
basic things like hostname/port/clusterName.

Hope this helps!

--paul

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![timrobertson100](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timrobertson100/32/2467_2.png) [@timrobertson100](https://discuss.elastic.co/u/timrobertson100)\
**Post date:** [February 28, 2013, 7:09pm UTC](https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952/3 "2013-02-28T19:09:30Z")

</div>

Thanks Paul,

That is not too disimilar to what I have done this afternoon, but I went  
for an embedded node started with Guice, so then I Guice injects a regular  
client in the code.

How do you manage your index please? Are you just scattering calls to  
TransportClient all around the code, or have you done some kind of cross  
cutting approach (like method interceptors)?

Cheers,  
Tim

On Thu, Feb 28, 2013 at 7:40 PM, Paul Sanwald [paul@redowlanalytics.com](mailto:paul@redowlanalytics.com)wrote:

> Hi Tim,  
> So, not sure this is quite the answer you're looking for, but I also  
> have a java webapp with an elasticsearch component, and I've found it  
> useful to fire up my elasticsearch nodes in my webapp itself, I use  
> [GitHub - elastic/elasticsearch-transport-wares: Servlet transport for Elasticsearch](https://github.com/elasticsearch/elasticsearch-transport-wares) to do  
> this. Then, in web.xml I just:  
>   
> node  
> org.elasticsearch.wares.NodeServlet  
> 1
> 
> I have one node per instance of my web application; I actually prefer  
> this, but this route does remove the ability to separate your elasticsearch  
> nodes from your web application (the plus side is you don't have to manage  
> both).
> 
> Then, when I want to use it from a controller or similar, I just inject a  
> (spring configured, in my case) TransportClient. Pretty sure you could  
> guice configure a TransportClient relatively easily, it just needs a few  
> basic things like hostname/port/clusterName.
> 
> Hope this helps!
> 
> --paul
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Paul\_Sanwald\_2](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/paul_sanwald_2/32/881_2.png) [@Paul\_Sanwald\_2](https://discuss.elastic.co/u/Paul_Sanwald_2)\
**Post date:** [February 28, 2013, 7:30pm UTC](https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952/4 "2013-02-28T19:30:12Z")

</div>

Hi Tim,  
probably a bit old school, but I have a searchIndexDAO class that has  
the client injected, and my jersey resources all just inject the DAO and  
use that, instead of a TransportClient directly. So really my  
TransportClient is only ever injected in one place in the code. I did this  
for mostly for reuse reasons, although a little of the old Separation Of  
Concerns doesn't kill me here I suppose :).

my index is managed on AWS, I use the ec2 discovery and s3 gateway, and use  
a special security group for node discovery.

--paul

On Thursday, February 28, 2013 2:09:30 PM UTC-5, Tim Robertson wrote:

> Thanks Paul,
> 
> That is not too disimilar to what I have done this afternoon, but I went  
> for an embedded node started with Guice, so then I Guice injects a regular  
> client in the code.
> 
> How do you manage your index please? Are you just scattering calls to  
> TransportClient all around the code, or have you done some kind of cross  
> cutting approach (like method interceptors)?
> 
> Cheers,  
> Tim
> 
> On Thu, Feb 28, 2013 at 7:40 PM, Paul Sanwald \<[pa...@redowlanalytics.com](mailto:pa...@redowlanalytics.com)\<javascript:\>
> 
> > wrote:
> 
> > Hi Tim,  
> > So, not sure this is quite the answer you're looking for, but I also  
> > have a java webapp with an elasticsearch component, and I've found it  
> > useful to fire up my elasticsearch nodes in my webapp itself, I use  
> > [GitHub - elastic/elasticsearch-transport-wares: Servlet transport for Elasticsearch](https://github.com/elasticsearch/elasticsearch-transport-wares) to do  
> > this. Then, in web.xml I just:  
> >   
> > node  
> > org.elasticsearch.wares.NodeServlet  
> > 1
> > 
> > I have one node per instance of my web application; I actually prefer  
> > this, but this route does remove the ability to separate your elasticsearch  
> > nodes from your web application (the plus side is you don't have to manage  
> > both).
> > 
> > Then, when I want to use it from a controller or similar, I just inject a  
> > (spring configured, in my case) TransportClient. Pretty sure you could  
> > guice configure a TransportClient relatively easily, it just needs a few  
> > basic things like hostname/port/clusterName.
> > 
> > Hope this helps!
> > 
> > --paul
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![timrobertson100](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timrobertson100/32/2467_2.png) [@timrobertson100](https://discuss.elastic.co/u/timrobertson100)\
**Post date:** [February 28, 2013, 7:37pm UTC](https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952/5 "2013-02-28T19:37:53Z")

</div>

Thanks Paul

On Thu, Feb 28, 2013 at 8:30 PM, Paul Sanwald [paul@redowlanalytics.com](mailto:paul@redowlanalytics.com)wrote:

> Hi Tim,  
> probably a bit old school, but I have a searchIndexDAO class that has  
> the client injected, and my jersey resources all just inject the DAO and  
> use that, instead of a TransportClient directly. So really my  
> TransportClient is only ever injected in one place in the code. I did this  
> for mostly for reuse reasons, although a little of the old Separation Of  
> Concerns doesn't kill me here I suppose :).
> 
> my index is managed on AWS, I use the ec2 discovery and s3 gateway, and  
> use a special security group for node discovery.
> 
> --paul
> 
> On Thursday, February 28, 2013 2:09:30 PM UTC-5, Tim Robertson wrote:
> 
> > Thanks Paul,
> > 
> > That is not too disimilar to what I have done this afternoon, but I went  
> > for an embedded node started with Guice, so then I Guice injects a regular  
> > client in the code.
> > 
> > How do you manage your index please? Are you just scattering calls to  
> > TransportClient all around the code, or have you done some kind of cross  
> > cutting approach (like method interceptors)?
> > 
> > Cheers,  
> > Tim
> > 
> > On Thu, Feb 28, 2013 at 7:40 PM, Paul Sanwald [pa...@redowlanalytics.com](mailto:pa...@redowlanalytics.com)wrote:
> > 
> > > Hi Tim,  
> > > So, not sure this is quite the answer you're looking for, but I also  
> > > have a java webapp with an elasticsearch component, and I've found it  
> > > useful to fire up my elasticsearch nodes in my webapp itself, I use  
> > > [https://github.com/\*\*elasticsearch/elasticsearch-\*\*transport-wares](https://github.com/ **elasticsearch/elasticsearch-** transport-wares)[https://github.com/elasticsearch/elasticsearch-transport-wares](https://github.com/elasticsearch/elasticsearch-transport-wares)to do this. Then, in web.xml I just:  
> > >   
> > > node\</servlet-\*\*name\>  
> > > org. **elasticsearch.wares.**  
> > > NodeServlet  
> > > 1\</load-on-\*\*startup\>
> > > 
> > > I have one node per instance of my web application; I actually prefer  
> > > this, but this route does remove the ability to separate your elasticsearch  
> > > nodes from your web application (the plus side is you don't have to manage  
> > > both).
> > > 
> > > Then, when I want to use it from a controller or similar, I just inject  
> > > a (spring configured, in my case) TransportClient. Pretty sure you could  
> > > guice configure a TransportClient relatively easily, it just needs a few  
> > > basic things like hostname/port/clusterName.
> > > 
> > > Hope this helps!
> > > 
> > > --paul
> > > 
> > > --  
> > > You received this message because you are subscribed to the Google  
> > > Groups "elasticsearch" group.  
> > > To unsubscribe from this group and stop receiving emails from it, send  
> > > an email to elasticsearc...@\*\*[googlegroups.com](http://googlegroups.com).
> > > 
> > > For more options, visit [https://groups.google.com/\*\*groups/opt\_out](https://groups.google.com/**groups/opt_out)[https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out)  
> > > .
> > 
> > --  
> > You received this message because you are subscribed to the Google Groups  
> > "elasticsearch" group.  
> > To unsubscribe from this group and stop receiving emails from it, send an  
> > email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> > For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 2:48am UTC](https://discuss.elastic.co/t/integration-framework-for-jersey-app/10952/6 "2017-07-06T02:48:58Z")

</div>


