Download Diffusion 5.1 User Guide - Documentation

Transcript
Server handling of acknowledgments
Users of the publisher API can cause message acknowledgments to be handled automatically or
manually.
When handled automatically, whenever a message requiring acknowledgment is received from
a client, an ACK message is automatically sent back to the client. This mode involves no special
processing in the publisher application.
When handled manually, when a message requiring acknowledgment is received it is
not automatically acknowledged and it is up to the publisher to acknowledge it, possibly
after processing it. The isAckPending method on a Message indicates whether it must
be acknowledged. Such a message can be acknowledged within a publisher using the
Client.acknowledge method which sends an ACK notification back to the client.
Whether a publisher operates in automatic or manual acknowledgment mode is determined by the
auto-ack property in etc/Publishers.xml .
Publisher notification of Non-acknowledgment
A publisher receives notifications of non-acknowledgment of messages through its
messageNotAcknowledged method.
For example
public void messageNotAcknowledged(
TopicMessage message,
List<TopicClient> clients) {
LOG.warn("Message {} not acknowledged by: ",message);
for (TopicClient client:clients) {
LOG.warn("Client '{}'",client);
}
}
Client notification of Non-acknowledgment
A client that sends messages requiring acknowledgment to the server must declare a listener for
non-acknowledgment notifications. In the Java API the connection has a setAckListener method
for this purpose). Any attempt to send a message requiring acknowledgment when no listener has
been declared fails.
Message acknowledgment considerations
Use message acknowledgment sparingly and with care, taking the following into consideration:
•
•
•
•
•
A message set as requiring acknowledgment cannot be reused unless it is copied (using
duplicate). Efficiencies of message reuse (for example, using the same topic load message for
many subscriptions if the data has not changed) are lost.
A message set as requiring acknowledgment by a publisher is always sent with high priority and
the normal client queuing mechanisms are by-passed. Queuing of expedited messages is less
efficient than normal queuing as such messages have to be inserted at the head of the queue
rather than being added at the end of it.
Acknowledged messages cannot be conflated.
Acknowledged messages cannot be fragmented.
The handling of acknowledged messages involves extra processing at both the client and at the
server. This has performance implications.
Diagnostic considerations
Messages requiring acknowledgment are actually a different message type (see protocol) from
normal topic messages so from a diagnostic point of view, bear in mind that the message type
number is different and there is an additional (Ack ID) header.
Diffusion | 212