0

我有一个要求,我需要 40 个线程来执行某个任务(合并),大约 20 个线程来执行另一个任务(持久性)。合并比持久化花费大约 5 倍的时间。我正在使用消息驱动的 bean 来完成这种并发性。

我使用以下配置创建了一个 MDB RecordMerger

@MessageDriven(activationConfig = { 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "testing/RecordMerger"),
    @ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "40")
})

我为坚持做了类似的事情

@MessageDriven(activationConfig = { 
    @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "destination", propertyValue = "testing/RecordPersistor"),
    @ActivationConfigProperty(propertyName = "maxSessions", propertyValue = "20")
})

我在tomee.xml中的配置如下

 <Container id="MyJmsMdbContainer" ctype="MESSAGE">
    ResourceAdapter = MyJmsResourceAdapter
    InstanceLimit = 40
</Container>

记录合并队列的生产速度非常快,因此记录合并队列中总是有新元素。记录合并队列将数据放入记录持久性队列中。

我面临的问题是,当记录合并配置为使用 40 个线程时,我的 tomee 服务器没有实例化记录持久性 MDB,这导致记录堆积在该队列中。如果我将记录合并的 maxSession 属性减少到 20,则两个 MDB 都开始实例化。

谁能指导我我需要做什么来确保两个 MDB 都在运行并且记录合并有 40 个线程。

4

1 回答 1

0

您可能还需要在资源适配器定义 (tomee.xml) 中设置 threadPoolSize=40(默认为 30)

于 2016-05-02T21:16:50.833 回答