How can I tell if my program is not entitled to publish to a topic?


Most AMPS applications are designed for maximum throughput, which includes carefully testing entitlements for publishers and subscribers before deployment and minimizing the amount of work that clients do when publishing a message. However, this also means that it's rare for publishes to fail, and a failure in publication usually represents a critical error.

Managing Acknowledgements 

When the topic being published to uses a transaction log, AMPS optimizes the acknowledgement messages by conflating the acknowledgements. This means that, rather than acknowledging every message when publishes succeed, AMPS acknowledges multiple publishes at a time.

When the topic being published to does not use a transaction log, requesting acknowledgements for a publish means that AMPS returns an acknowledgement message for each publish, which consumes both network and processing resources. 60East recommends carefully planning which messages require acknowledgement.

Consider whether failure acknowledgements are required for your application, and whether each message requires an acknowledgement, or whether your application can request acknowledgement on the first message to a topic, or request a message at a set interval (for example, every 1000 messages).

Client versions 5.0 and later

In current versions of the AMPS Client, you can register a FailedWriteHandler to receive information about messages that could not be published, including entitlement failures. This is the most convenient way to be notified of errors, and is the recommended approach.

Older client versions

For older versions of the AMPS Client, you can use the technique described below.

There are two steps required to detecting entitlement errors.

  1. Register a LastChanceMessageHandler to process error acknowledgements as they are returned.

  2. Request an acknowledgement on the publish command that will report entitlement errors.

    By default, the AMPS clients do not request acknowledgements to verify that a publish succeeded. The HA Client requests persisted acknowledgements, which it uses to determine when it is safe to remove messages from the publish store. The simple Client does not request acknowledgements on a publish.


With these two steps, your application will receive notification from AMPS when a publish fails.

The sample below shows a simple way to register for and receive not entitled notifications using the Python client.

import AMPS
import time
def handleUnexpected(message):
  print message.get_status(),message.get_reason()
  # logging or recovery logic here
c = AMPS.Client("pub-ack-test")
# Request completed ack for a publish message
m = c.allocate_message()





 Keywords: entitlement failure, message acknowledgements, ack, failure ack, handling publish failure, publish notifications, failed publish

Have more questions? Submit a request


  • Avatar
    Alexander Cerna
    Hello Dirk, Is the "completed" ack request the only way to accomplish this for now in AMPS 4.x? The reason I ask is, won't the "persisted" ack request (for journaled topics, that is) imply a check on entitlement as well? After all, it won't be published, much more persisted, if the entitlement wasn't granted. So, for example, if I do a "persisted" ack request (because I know that the topic is journaled by the server), then there is no need for me to stack on a "completed" ack request if my intention is to additionally check for entitlement, am I correct? Much thanks in advance. Sincerely, Alexander
  • Avatar
    Dirk Myers
    Hi Alexander: yes, AMPS returns a persisted ack that will fail if the connection isn't entitled to publish to that topic. In earlier versions of the AMPS client, the client would not provide this ack to application code (since the ack is used for publish store housekeeping, the client made the assumption that the application code would not use the ack). In current versions of the AMPS client, we return any acknowledgement the client requests, even if it's also used for internal housekeeping. We also provide a FailedWriteHandler in more current versions of the client. I've added this to the information above.
Powered by Zendesk