Announcement Announcement Module
Collapse
No announcement yet.
Handling a lengthy operation Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Handling a lengthy operation

    Hey,
    One of our application tasks is sending bulk SMS.
    The application is built with Hibernate/Spring/Wicket
    The user chooses which groups to be sent to and then submit the form via Ajax.
    The flow is as the following:
    - Sending the SMS to each contact in the group.
    - Save the SMS to the DB.
    - Update the group status.
    - Handle the next group.
    Sending the SMS could be a lengthy operation so I'm thinking to create a multiple thread (say each thread handle 100 contact), but I'm not sure if this will has an impact on the DB transaction.
    How do you advice me to implement this functionality? do suggest any technique?
    Are threads necessary?
    Thanks.

  • #2
    To prevent executing the whole batch on the servlet thread, some threading is required.

    http://pveentjer.wordpress.com/2007/...-task-from-ui/

    There are a lot of ways to implement the sending functionality. You could use a database to persist the state and make sharing state between clusters possible, but this smells like volatile data and databases aren't well suited for that. So perhaps some kind of distributed heap would be better (Terracotta, Gigaspaces, Tangosol). Just store all messages that need to be send in the heap (that is visible on all machines) and let threads from each machine process messages in parallel.

    But more information about your requirements and constraints are needed

    Comment

    Working...
    X