# Automatically adding actions to TransportClient

**URL:** <https://discuss.elastic.co/t/automatically-adding-actions-to-transportclient/7784>\
**Category:** Elasticsearch\
**Created:** [May 21, 2012, 7:54am UTC](https://discuss.elastic.co/t/automatically-adding-actions-to-transportclient/7784 "2012-05-21T07:54:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alexander\_Reelsen](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@Alexander\_Reelsen](https://discuss.elastic.co/u/Alexander_Reelsen)\
**Post date:** [May 21, 2012, 7:54am UTC](https://discuss.elastic.co/t/automatically-adding-actions-to-transportclient/7784/1 "2012-05-21T07:54:48Z")

</div>

Hi there,

I am struggling a little bit with using my elasticsearch-suggest-  
plugin via a TransportClient.

I am starting an elasticsearch on host a, which starts up fine with my  
plugin.

Then I am creating a TransportClient on host b, with this:

client = new TransportClient(settings).addTransportAddress(new  
InetSocketTransportAddress(host, port));

The problem with this client is, that the actions (like my  
SuggestAction) are not registered, when the InternalTransportClient is  
created, and I cannot add them afterwards (ok, I just havent found a  
way). When I perform a suggest query now, I get a NPE in  
InternalTransportClient.execute because the action cannot be looked up  
in the actions map.

So do I need to register the actions manually somehow on my client in  
order to use them?

Any hints are appreciated... 🙂

--Alexander

P.S. Looking forward to berlin buzzwords for meeting some of you 🙂

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 23, 2012, 9:10pm UTC](https://discuss.elastic.co/t/automatically-adding-actions-to-transportclient/7784/2 "2012-05-23T21:10:55Z")

</div>

Are you registering the action correctly? Do you have the plugin available  
on the client side as well (so it will register the action)?

On Mon, May 21, 2012 at 9:54 AM, Alexander Reelsen \<  
[alexander.reelsen@googlemail.com](mailto:alexander.reelsen@googlemail.com)\> wrote:

> Hi there,
> 
> I am struggling a little bit with using my elasticsearch-suggest-  
> plugin via a TransportClient.
> 
> I am starting an elasticsearch on host a, which starts up fine with my  
> plugin.
> 
> Then I am creating a TransportClient on host b, with this:
> 
> client = new TransportClient(settings).addTransportAddress(new  
> InetSocketTransportAddress(host, port));
> 
> The problem with this client is, that the actions (like my  
> SuggestAction) are not registered, when the InternalTransportClient is  
> created, and I cannot add them afterwards (ok, I just havent found a  
> way). When I perform a suggest query now, I get a NPE in  
> InternalTransportClient.execute because the action cannot be looked up  
> in the actions map.
> 
> So do I need to register the actions manually somehow on my client in  
> order to use them?
> 
> Any hints are appreciated... 🙂
> 
> --Alexander
> 
> P.S. Looking forward to berlin buzzwords for meeting some of you 🙂

---

<div class="post-metadata">

**Author:** ![Alexander\_Reelsen](https://avatars.discourse-cdn.com/v4/letter/a/85e7bf/32.png) [@Alexander\_Reelsen](https://discuss.elastic.co/u/Alexander_Reelsen)\
**Post date:** [May 24, 2012, 11:32am UTC](https://discuss.elastic.co/t/automatically-adding-actions-to-transportclient/7784/3 "2012-05-24T11:32:51Z")

</div>

Hi Shay

On 23 Mai, 23:10, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:

> Are you registering the action correctly? Do you have the plugin available  
> on the client side as well (so it will register the action)?  
> I have changed my setup a little bit. This even fails, when client and  
> server run inside the same JVM.

I start an elasticsearch node in my JVM, it runs on port 9300 and 9200  
and has the plugin started.

I create a TransportClient in the same JVM, and it seems not support  
for my plugin. As far is as I understand it (may be utterly wrong):

First: The SuggestModule (extending AbstractModule) fires up correctly  
in the server.  
Second: The TransportClient creates its own DI environment by calling  
its constructor (TransportClient around line 140):  
public TransportClient(Settings pSettings, boolean  
loadConfigSettings)

This constructor calls its own ModulesBuilder without the  
SuggestModule being loaded, which is the reason my plugin specific  
calls are not included in the InternalTransportClient which is set in  
the constructor as well:  
internalClient =  
injector.getInstance(InternalTransportClient.class);

Your statement seems to imply though, the actions are registered. Can  
you give me some hints, so I could take a closer look? 🙂  
I looked at the 0.19.3 source, in case you wonder about strange line  
numbers.

--Alexander

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 25, 2012, 10:13pm UTC](https://discuss.elastic.co/t/automatically-adding-actions-to-transportclient/7784/4 "2012-05-25T22:13:49Z")

</div>

I see the problem now, the problem is that the TransportClient does not  
load plugins. I will add it. Some plugins though will not need to register  
modules as they do when running in a full "node" mode, a plugin can be  
injected with a Settings in the constructor, and check on node.client  
setting in this case (if its set to true, then its just a client). Here is  
the issue: [TransportClient does not load plugins · Issue #1982 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/1982).

On Thu, May 24, 2012 at 1:32 PM, Alexander Reelsen \<  
[alexander.reelsen@googlemail.com](mailto:alexander.reelsen@googlemail.com)\> wrote:

> Hi Shay
> 
> On 23 Mai, 23:10, Shay Banon [kim...@gmail.com](mailto:kim...@gmail.com) wrote:
> 
> > Are you registering the action correctly? Do you have the plugin  
> > available  
> > on the client side as well (so it will register the action)?  
> > I have changed my setup a little bit. This even fails, when client and  
> > server run inside the same JVM.
> 
> I start an elasticsearch node in my JVM, it runs on port 9300 and 9200  
> and has the plugin started.
> 
> I create a TransportClient in the same JVM, and it seems not support  
> for my plugin. As far is as I understand it (may be utterly wrong):
> 
> First: The SuggestModule (extending AbstractModule) fires up correctly  
> in the server.  
> Second: The TransportClient creates its own DI environment by calling  
> its constructor (TransportClient around line 140):  
> public TransportClient(Settings pSettings, boolean  
> loadConfigSettings)
> 
> This constructor calls its own ModulesBuilder without the  
> SuggestModule being loaded, which is the reason my plugin specific  
> calls are not included in the InternalTransportClient which is set in  
> the constructor as well:  
> internalClient =  
> injector.getInstance(InternalTransportClient.class);
> 
> Your statement seems to imply though, the actions are registered. Can  
> you give me some hints, so I could take a closer look? 🙂  
> I looked at the 0.19.3 source, in case you wonder about strange line  
> numbers.
> 
> --Alexander

---

<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, 3:26am UTC](https://discuss.elastic.co/t/automatically-adding-actions-to-transportclient/7784/5 "2017-07-06T03:26:57Z")

</div>


