forked from rabbitmq/rabbitmq-stream-java-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCallbackStreamDataHandler.java
56 lines (47 loc) · 1.56 KB
/
CallbackStreamDataHandler.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.rabbitmq.stream;
/**
* Exposes callbacks to handle events from a particular Stream subscription,
* with specific names for methods and no connection-oriented parameter.
*/
public interface CallbackStreamDataHandler {
default void handleChunk(long offset, long messageCount, long dataSize) {
// No-op by default
}
default void handleMessage(long offset, long chunkTimestamp, long committedChunkId, Message message) {
// No-op by default
}
default void handleCreditNotification(short responseCode) {
// No-op by default
}
default void handleConsumerUpdate(boolean active) {
// No-op by default
}
default void handleMetadata(short code) {
// No-op by default
}
/**
* Callback for handling a stream subscription.
*
* @param offsetSpecification The offset specification for this new subscription
* @param isInitialSubscription Whether this subscription is an initial subscription
* or a recovery for an existing subscription
*/
default void handleSubscribe(
OffsetSpecification offsetSpecification,
boolean isInitialSubscription
) {
// No-op by default
}
/**
* Callback for handling a stream unsubscription.
*/
default void handleUnsubscribe() {
if(this instanceof AutoCloseable) {
try {
((AutoCloseable) this).close();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
}