0

I have an EJB that uses the @Schedule annotation to perform some enterprise logic in a cron like manner.

I am using JBoss 7.1 final.

The problem is that this method is consuming messages from an AWS SQS service, in that API there is a restriction to fetch up to 10 messages at a time. That causes a lot of messages beeing added to the SQS but not beeing consumed fast enough. So what I would like to ask is if there is a way to create a pool and have 2 or 3 EJBs concurently processing messages from SQS.

maxsap
  • 2,971
  • 9
  • 44
  • 70
  • Can't you just fetch multiple times 10 messages, until all your message have been consumed? Or is the real problem that sequential consumption is not engough to handle the load, and you need concurrent consumptions? – ewernli Jun 19 '12 at 11:11

1 Answers1

0

I've added a comment for some clarifications, but here is anyway an idea that might work for your case.

  1. Use a scheduled EJB to consume the message from the SQS queue sequentially. Since there is apparently a restriction on the number of messages you can fetch, you might need to call the SQS service multiple times. Do not treat the message now, just sends them in a "intermediate" JMS queue.

  2. Use regular message driven bean (MDB) to process the messages in the "intermediate" JMS queue. You can specific the pool size, etc. and let the app. server manage the load. Treatment of the JMS message will be concurrent.

This would comply with the EJB specs, and be relatively clean. There is slight added technical complexity, though. Also, it assumes the the original problem was that the processing of the SQS message sequentially is the root problem, not the mere reading of the SQS messages.

ewernli
  • 38,045
  • 5
  • 92
  • 123