如何配置EJB3消息处理并发数[Message Driven Bean]

 环境:

Jboss4.3

EJB3

JDK1.6

 

 默认情况下,每个消息Bean的并发处理为15,这里我们可以通过修改maxSession的值来调整并发数.代码参考如下:

@MessageDriven(activationConfig = {@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
        @ActivationConfigProperty(propertyName = "destination", propertyValue = "queue/aaa/biz2/rds/jms/GeneratorQueue"),
        @ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
        @ActivationConfigProperty(propertyName = "maxSession", propertyValue = "5")})

 设置完成后,我们可以发现此时的消息Bean并发数变成了5.这里只是指当前的Bean在所在的服务器的并发,不是指集群里的总并发数.

 

下面是摘自Jboss的官方文档:

The following is the list of standard Activation Config Properties available from the JCA 1.5 specification. Also listed are the respective types and default values where defined.

Name Type Remarks Mandatory? Default value
destination java.lang.String The jndi name of the Queue or Topic Yes  
destinationType java.lang.String The type of destination valid values are javax.jms.Queue or javax.jms.Topic No  
messageSelector java.lang.String The message selector of the subscription No  
acknowledgeMode int The type of acknowledgement when not using transacted jms - valid values AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE No AUTO_ACKNOWLEDGE
clientID java.lang.String The client id of the connection No  
subscriptionDurability String Whether topic subscriptions are durable. Valid values are Durable or NonDurable No NonDurable
subscriptionName String The subsription name of the topic subscription No  

The following is the list of Activation Config Properties available as JBoss extensions.

Name Type Remarks Mandatory? Default value
isTopic boolean Sets the destinationType No false
providerAdapterJNDI java.lang.String The jndi name of the jms provider No java:/DefaultJMSProvider
user java.lang.String The user id used to connect to the jms server No  
pass java.lang.String The password of the user No  
maxMessages int Read this number of messages before delivering messages to the mdb. Each message is delivered individually on the same thread in an attempt to avoid context excessive context switching No 1
minSession int The minimum number of jms sessions that are available to concurrently deliver messages to this mdb No 1
maxSession int The maximum number of jms sessions that are available to concurrently deliver messages to this mdb No 15
reconnectInterval long The length of time in seconds between attempts to (re-)connect to the jms provider No 10 seconds
keepAlive long The length of time in milliseconds that sessions over the minimum are kept alive No 60 seconds
sessionTransacted boolean Whether the sessions are transacted No true
useDLQ boolean Whether to use a DLQ handler No true
dLQJNDIName java.lang.String The JNDI name of the DLQ No queue/DLQ
dLQHandler java.lang.String The org.jboss.resource.adapter.jms.inflow.DLQHandler implementation class name No org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler
dLQUser java.lang.String The user id used to make the dlq connection to the jms server No  
dLQPassword java.lang.String The password of the dLQUser No  
dLQClientID java.lang.String The client id of the dlq connection No  
dLQMaxResent int The maximum number of times a message is redelivered before it is sent to the DLQ No 5
redeliverUnspecified boolean Whether to attempt to redeliver a message in an unspecified transaction context No true
transactionTimeout int Time in seconds for the transaction timeout No Default is the timeout set for the resource manager
DeliveryActive boolean Whether the MDB should make the subscription at initial deployment or wait for start() or stopDelivery() on the corresponding MBean. You can set this to false if you want to prevent messages from being delivered to the MDB (which is still starting) during server startup No true
 
 

你可能感兴趣的:(message)