External Task Client - Subscribe to mutiple topics

Hello,

i’m currently using the camunda-external-task-client-java for my worker projects.

My goal would be to subscribe to multiple topics, using only one long-polling http request-
Sadly
taskClient.subscribe(“topic1,topic2”) does not work for me.
A single topic works fine.
Any Ideas to subscribe to multiple topics without using mutiple http connections?

@Niall
Maybe you can take a look into it?:slight_smile:

Greetings,

Moritz

Moritz

You need to create multiple subscriptions to the same client object something like this

client.subscribe("TheFirstTopic");
	    subscribtionBuilder
	      .handler((externalTask, externalTaskService) -> {

	    	  
	    		  externalTaskService.complete(externalTask);

	    	  
	      }).open();
client.subscribe("SomeOtherTopic");
	    subscribtionBuilder
	      .handler((externalTask, externalTaskService) -> {

	    	  
	    		  externalTaskService.complete(externalTask);

	     }).open();

1 Like

Sounds good, that is exactly the way we do it.

But i would assume that it will open one http request per open()?
So for two topics i have to use two long-polling http requests ?

To clearify: when using fetch-and-lock thru the REST API directly, i was able to subscribe to multiple topics just with one http-requests.

1 Like

Is that the solution you where looking for or do you have any other issues?

I would prefer to use the camunda-external-task-client-java, instead of using the REST API directly.

Can you confirm, that if we do so, it will result one long polling http connection for every topic?

Edit: After diving into the implementation of the camunda-external-task-client-java i noticed that my assumption (1 subscription = 1 connection) was wrong.

The TopicSubscriptionManager.class seem to handle all that perfectly, so exactly the solution i am looking for!

Thanks,
Moritz

2 Likes