简体   繁体   中英

One JMS message is processed twice by a Message driven bean

Problem:

More than once instance of Java 'Message Driven Bean' is processing just one message (put in the JMS queue) at exactly same time.

How can I ensure that one message is processed only once by a 'Message Driven Bean'.

I have deployed a Java Message Driven Bean as below in Weblogic 12c.

MDB

    @MessageDriven(activationConfig = { @ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
            @ActivationConfigProperty(propertyName = "connectionFactoryJndiName", propertyValue = "jms/notConnectionFactory"),
            @ActivationConfigProperty(propertyName = "destinationJndiName", propertyValue = "jms/notScannerQueue")
    })
    public class AttachmentMDB implements MessageListener {

If we stay in the Message Driven realm, it depends on the acknowledge mode: AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE .

If you use DUPS_OK_ACKNOWLEDGE , the acknowledgement is sent to the client at a later stage. In this case the message may be processed twice.

With AUTO_ACKNOWLEDGE , to simplify the client (message producer) is being put on hold until the broker (message consumer) has confirmed that it has received the message. This has the obvious effect that the message is processed only once.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM