...
- Request method and URI
POST [base_url]/topics/[topic]/publish
- Request body
JSON object containing payload and optionally transaction write pointer
{ "payload" : [ payload byte array ], "tx_write_ptr" : 12345L, "buffer" : true }
Fields:
i) payload - Contains the payload in the form of array of bytes
ii) tx_write_ptr (optional) - Contains a long that corresponds to a transaction write pointer. If this field is not provided, then the publishing of message is performed non-transactionally
iii) buffer (optional) - A boolean flag that indicates whether the messages can be buffered on the client side or should it the message be persisted in a Payload table. This option is not used when tx_write_ptr is not set (i.e., if the message is published non-transactionally)
- Response :
404 NOT FOUND if topic is not present
200 OK if message is persisted - Commit Transactionally published messages
POST [base_url]/topics/[topic]/commit
Request body should contain the transaction write pointer that should be committed
{ "tx_write_ptr" : 12345L }
Response :404 NOT FOUND if topic is not present
200 OK if messages are persisted
- Rollback Transactionally published messages
POST [base_url]/topics/[topic]/rollback
Request body should contain the transaction write pointer that should be rolled back
{ "tx_write_ptr" : 12345L }
Response :
404 NOT FOUND if topic is not present
200 OK if messages are rolled backTBD: When or should the client retry? If it could not be rolled back, the transaction should be invalidated.
...
TBD: How should TopicId look like? Should it extend from a NamespaceId and just have a String for the topic?
Creating Topic:
void create(TopicId topic) throws TopicAlreadyExistsException;
Deleting Topic:
void delete(TopicId topic) throws TopicNotFoundException;
Publishing Message: Consuming Message:
For publishing messages non-transactionally:
- void publish(TopicId topic, byte[] payload) throws TopicNotFoundException;
For publishing messages transactionally by providing the Transaction object and as well as a boolean variable that indicates whether the messages should be persisted in the payloadTable before the messages are
- void publish(TopicId topic, byte[] payload, Transaction transaction, boolean buffer) throws TopicNotFoundException;
Consuming Message:
For consuming messages non-transactionally:
- List<Message> poll(TopicId topic) throws TopicNotFoundException;
- List<Message> poll(TopicId topic, long timestampInMs, boolean inclusive) throws TopicNotFoundException;
- List<Message> poll(TopicId topic, MessageId messageId, boolean inclusive) throws TopicNotFoundException;
- List<Message> poll(TopicId topic, long timestampInMs, boolean inclusive, long maxMessages) throws TopicNotFoundException;
- List<Message> poll(TopicId topic, MessageId, messageId, boolean inclusive, long maxMessages) throws TopicNotFoundException;
class Message {
MessageId messageId;
byte[] payload;
}
class MessageId {
long publish_timestamp;
short seq_id;
long write_timestamp;
short p_seq_id;
}