This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Everything seem to be working perfectly, no error and the expected message is arriving to my last toString transformer and is sent to the final response channel. The weird thing is that the gateway sometimes doesn't return the message, I get a 200 OK but nothing in the payload despite I can see in log file and debugging that I'm sending to the final response channel the right information.
This only happens sometimes (always in the first call when I start the server), the rest of the times everything works fine.

The problem seems to be in the task executor, because if I remove it, everything run ok, but I would like to call to the two services activator at the same time, not sequentially, so I need the task executor (or is there other possibility???).

Comment

Both services returns the same kind of object, it's just a DTO. After aggregation I have a transformer which select just one of these object (the one returned by service1 or the one returned by service2)

Anyway I'm getting the same problem regardless of which of the object wins so I tend to think that the problem is not related to the services.

Can you remove the reply-channel from the HTTP Inbound gateway (reply-channel="responseChannel"). You don't need it.
And also in your chain, remove output-channel="responseChannel". You don't need that as well.

Just as an FYI, the reply will go via default replyChannel which is auto-created by the gateway and injected into the message as header.

This will simplify the configuration and hopefully allow us to determine what the problem is.

1. Remove header enricher
2. Add apply-sequence="true" to the pub-sub channel (this will do pretty much what your header enricher did)
3. Remove correlation-strategy-expression="headers.get('ad_correlation_id')" from the aggregator (it will rely on the default correlation ID which will be injected in the pub-sub channel based on apply-sequence="true")

Let's try to simplify it as much as we can without loosing functionality first.

Comment

I was using a custom correlation because in my first approach to the current solution I was using a recipient-router-list instead of a pub-subscriber. With the router I was sending the same message to both services and I needed an ID to be able to identify the response of each service in the aggregator.

After I changed from router to pub-subcriber because I wanted to call to the services at the same time, not sequentially (perfomance issues)

Comment

I think that it could be related to threading and http.... maybe I'm wrong but let me explain:

Subscriber is using a couple of threads to call to the both services. Probably is reusing a existing one thread to call to service1 and creating a new one to call to service2 (no idea, just a guess). What about if http is expecting the response in the thread1 but the response is arriving in the thread2???? when response arrives in thread 1, works! when response arrives in thread 2.... fails!

Well, the reply would go to the replyChannel defined in the Message headers so since you have aggregator downstream the reply won't be received until you get the aggregated response. In other words the HTTP thread that sent a Message is going to be executing a receive call (blocking call) on the reply channel, so it doesn't matter how many threads are in action downstream.