简体   繁体   中英

ActiveMQ/JMS - do not retry if message failed to be sent

I am using JMS with ActiveMQ. I have the ActiveMQ broker running on one server and it creates a queue and a message consumer that it uses to receive messages from other servers. If another server tries to send a message to the queue and it fails for some reason (like if the network between the servers goes down), then I do not want that server to retry sending the message. Just send it once and if it fails don't retry. Is this possible with ActiveMQ/JMS? The javax.jms.Session class has 3 acknowledgment modes (AUTO_ACKNOWLEDGE, CLIENT_ACKNOWLEDGE, DUPS_OK_ACKNOWLEDGE), all of which suggest that the JMS message producer will retry on a failure.

If your client is not using the failover transport then a failure of the connection while attempting to send means that the client won't attempt to reconnect and thereby not try to resend the message once the connection is back up.

If you use the failover transport and the client experiences a network failure while sending the transport will attempt to reconnect and the client will block on the send until a connection is re-established and the message will be sent to the broker again.

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