-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathEnvironment.java
114 lines (104 loc) · 3.4 KB
/
Environment.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright (c) 2020-2023 VMware, Inc. or its affiliates. All rights reserved.
//
// This software, the RabbitMQ Stream Java client library, is dual-licensed under the
// Mozilla Public License 2.0 ("MPL"), and the Apache License version 2 ("ASL").
// For the MPL, please see LICENSE-MPL-RabbitMQ. For the ASL,
// please see LICENSE-APACHE2.
//
// This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
// either express or implied. See the LICENSE file for specific language governing
// rights and limitations of this software.
//
// If you have any questions regarding licensing, please contact us at
package com.rabbitmq.stream;
/**
* The {@link Environment} is the main entry point to a node or a cluster of nodes. {@link Producer}
* and {@link Consumer} instances are created from an {@link Environment} instance. An {@link
* Environment} can also create and delete streams.
*
* <p>Applications are supposed to use a single {@link Environment} instance to interact with a
* cluster.
*
* <p>Use {@link Environment#builder()} to configure and create an {@link Environment} instance.
*
* <p>{@link Environment} instances are expected to be thread-safe.
*
* @see EnvironmentBuilder
*/
public interface Environment extends AutoCloseable {
/**
* Create a builder to configure and create an {@link Environment}
*
* @return the environment builder
* @see EnvironmentBuilder
*/
static EnvironmentBuilder builder() {
try {
return (EnvironmentBuilder)
Class.forName("com.rabbitmq.stream.impl.StreamEnvironmentBuilder")
.getConstructor()
.newInstance();
} catch (Exception e) {
throw new StreamException("Error while creating stream environment builder", e);
}
}
/**
* Return a {@link StreamCreator} to configure and create a stream.
*
* @return the stream creator
* @see StreamCreator
*/
StreamCreator streamCreator();
/**
* Delete a stream
*
* @param stream the stream to delete
* @since 0.15.0
*/
void deleteStream(String stream);
/**
* Delete a super stream.
*
* <p>Requires RabbitMQ 3.13.0 or more.
*
* @param superStream the super stream to delete
*/
void deleteSuperStream(String superStream);
/**
* Query statistics on a stream.
*
* <p>Requires RabbitMQ 3.11 or more.
*
* @param stream the stream to get statistics from
* @return statistics on the stream
* @throws UnsupportedOperationException if the broker does not support this command
*/
StreamStats queryStreamStats(String stream);
/**
* Return whether a stream exists or not.
*
* @param stream the stream to check the existence
* @return true if stream exists, false if it does not exist
* @throws StreamException if response code is different from {@link Constants#RESPONSE_CODE_OK}
* or {@link Constants#RESPONSE_CODE_STREAM_DOES_NOT_EXIST}
*/
boolean streamExists(String stream);
/**
* Create a {@link ProducerBuilder} to configure and create a {@link Producer}.
*
* @return the producer builder
* @see ProducerBuilder
*/
ProducerBuilder producerBuilder();
/**
* Create a {@link ConsumerBuilder} to configure and create a {@link Consumer}
*
* @return the consumer builder
* @see ConsumerBuilder
*/
ConsumerBuilder consumerBuilder();
/** Close the environment and its resources. */
@Override
void close();
}