1 package com.atlassian.messagequeue;
2
3 import com.atlassian.annotations.PublicApi;
4
5 /**
6 * A service that provides sufficient information to enable clients to perform their own delivery of {@link Message}s to a
7 * queue. Once delivered, atlassian-messagequeue will retrieve from the queue and then dispatch to the
8 * appropriate {@link com.atlassian.messagequeue.registry.MessageRunner}.
9 *
10 * <p>Normally {@link MessageRunnerService#addMessage(Message)}} would do all this for you, but sometimes you want an
11 * external system (say a scheduling service) to take over the delivery aspect to a queue.
12 *
13 * <p>It is assumed that clients that compose messages from the information provided by this service have sufficient
14 * privileges to deliver to the queue locatable via {@link #getQueueUrl(MessageRunnerKey)})} (since this service does
15 * not provide any credentials).
16 *
17 * @since 1.0
18 */
19 @PublicApi
20 public interface MessageInformationService {
21 /**
22 * Returns the queue URL that atlassian-messagequeue is consuming from and producing to for the specified message
23 * runner key.
24 *
25 * @param messageRunnerKey the message runner key
26 * @return the queue URL that atlassian-messagequeue is consuming from and producing to.
27 */
28 String getQueueUrl(MessageRunnerKey messageRunnerKey);
29
30 /**
31 * Serializes the specified message into an atlassian-messagequeue formatted payload.
32 *
33 * @param message the message
34 * @return the atlassian-messagequeue formatted payload
35 * @throws MessageSerializationException if there is an error serializing the specified message
36 */
37 String toPayload(Message message);
38
39 /**
40 * Deserializes a {@link Message} from the specified atlassian-messagequeue formatted payload.
41 *
42 * @param payload the atlassian-messagequeue formatted payload (cannot be null or empty)
43 *
44 * @return the message
45 * @throws MessageSerializationException if there is an error deserializing the specified payload
46 */
47 Message fromPayload(String payload);
48 }