I have a third-party application that puts some messages in the JMS queue. I also have an application that reads messages from this queue. Depending on the type of message, I save this message in the database or send it to a third-party service. In addition, we should not exceed the limit of fixed calls per second, so as not to overload the third-party.
There are currently two solutions being used for my use.
The first is to ask a third party to send some custom headers so that the JMS consumer can filter messages using JMS Selectors. Thus, in this case, we will be able to create two consumers, the first one will be able to read messages and save them in the database, and the second will use the throttling / polling mechanism to send messages to a third party at a certain load, But this approach will not work for me, because third parties are required to add these custom headers. Something like this in Camel:
from("jms:queue?selector=firstSelector") .bean(dbSaver); from("jms:queue?selector=secondSelector") .throttle(10) .bean(httpClient);
The second is to create two more JMS queues and a processor that will separate the messages between these queues. Then comes the same logic as in the first decision. However, this means that you need to add 2 additional JMS queues. In the Camel:
from("jms:parentQueue") .choice() .when(body().contains(...)) .to("jms:fistChildQueue") .otherwise() .to("jms:secondChildQueue") .end() from("jms:fistChildQueue") .bean(dbSaver); from("jms:secondChildQueue") .throttle(10) .bean(httpClient);
Also, I was thinking about using two in-memory queues instead of JMS queues. However, in this case, if there are a lot of messages in the JMS queue, we will easily run into memory problems.
Can anyone suggest architectural design for this use case? It would be great to see him in the style of a camel route.
source share