Tutorial about Using multi-threading in jdbc

前端 未结 7 817
别跟我提以往
别跟我提以往 2020-12-24 00:54

Our company has a Batch Application which runs every day, It does some database related jobs mostly, import data into database table from file for example.

There are

相关标签:
7条回答
  • 2020-12-24 01:23

    If Multi threading would complicate your work, you could go with Async messaging. I'm not fully aware of what your needs are, so, the following is from what I am seeing currently.

    1. Create a file reader java whose purpose is to read the biz file and put messages into the JMS queue on the server. This could be plain Java with static void main()
    2. Consume the JMS messages in the Message driven beans(You can set the limit on the number of beans to be created in the pool, 50 or 100 depending on the need) if you have mutliple servers, well and good, your job is now split into multiple servers.
      1. Each row of data is asynchronously split between 2 servers and 50 beans on each server.

    You do not have to deal with threads in the whole process, JMS is ideal because your data is within a transaction, if something fails before you send an ack to the server, the message will be resent to the consumer, the load will be split between the servers without you doing anything special like multi threading.

    Also, spring is providing spring-batch which can help you. http://docs.spring.io/spring-batch/reference/html/spring-batch-intro.html#springBatchUsageScenarios

    0 讨论(0)
提交回复
热议问题