0

I am attempting to build an IntegrationFlowFactory to easily build integration flows for passing events between application contexts.

Everything seems to work, and events are being published very quick.

However i cannot figure out why the consuming is so slow. Adding concurrentConsumers or changing prefetchCount does not seem to change anything.

Other posts talk about the network being slow, but as you can see in the RabbitConfig i am using localhost.

I have a repository with my spring integration example here: https://github.com/teplyuska/spring-integration-example

heuts
  • 117
  • 1
  • 12
  • If increasing the prefetch "does not seem to change anything" then it's likely a problem in the listener code; time to profile your app. Going from 10 to 100 might not make a difference but certainly going from 1 to 10 should (if the listener is lightweight). – Gary Russell Nov 02 '17 at 13:42
  • Pulling your sample locally to play a bit... – Artem Bilan Nov 02 '17 at 13:48
  • Adding more concurrentConsumers will make the total throughput higher, but it is still very low per consumer. – heuts Nov 02 '17 at 14:02
  • See my answer for the solution. – Artem Bilan Nov 02 '17 at 14:55

1 Answers1

1

Your problem is here:

Amqp.inboundGateway(getListenerContainer(queue, concurrentConsumers, prefetchCount)

Meanwhile your downstream flow is one-way and doesn't return any reply:

.handle(p -> {
                UpdateSecretEvent payload = (UpdateSecretEvent) p.getPayload();
                System.out.println("Account: " + payload.getAccountId() + " has secret: " + payload.getNewSecret());
 })
.get();

or

.handle(p -> {
                UpdateEmailEvent payload = (UpdateEmailEvent) p.getPayload();
                System.out.println("Account: " + payload.getAccountId() + " has email: " + payload.getEmail());
})
.get();

So, that AmqpInboundGateway waits for the reply in its MessagingTemplate.sendAndReceive() for the private static final long DEFAULT_TIMEOUT = 1000L;

Switching to the Amqp.inboundAdapter() there does the trick.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118