14
14
* See the License for the specific language governing permissions and
15
15
* limitations under the License.
16
16
*/
17
+ use std:: any:: Any ;
17
18
18
19
use rocketmq_remoting:: net:: channel:: Channel ;
19
20
use rocketmq_remoting:: protocol:: header:: pull_message_request_header:: PullMessageRequestHeader ;
@@ -25,7 +26,37 @@ use rocketmq_remoting::runtime::server::ConnectionHandlerContext;
25
26
use rocketmq_store:: base:: get_message_result:: GetMessageResult ;
26
27
use rocketmq_store:: filter:: MessageFilter ;
27
28
28
- pub trait PullMessageResultHandler : Sync + Send + ' static {
29
+ /// Trait defining the behavior for handling the result of a pull message request.
30
+ ///
31
+ /// This trait is designed to be implemented by types that handle the result of a pull message
32
+ /// request in a RocketMQ broker. It provides a method for processing the result of a message
33
+ /// retrieval operation, along with various parameters related to the request and the broker's
34
+ /// state.
35
+ pub trait PullMessageResultHandler : Sync + Send + Any + ' static {
36
+ /// Handles the result of a pull message request.
37
+ ///
38
+ /// This method processes the result of a message retrieval operation (`get_message_result`),
39
+ /// using the provided request information, channel, context, subscription data, and other
40
+ /// parameters to generate an appropriate response.
41
+ ///
42
+ /// # Parameters
43
+ /// - `get_message_result`: The result of the message retrieval operation.
44
+ /// - `request`: The original remoting command representing the pull message request.
45
+ /// - `request_header`: The header of the pull message request, containing request-specific
46
+ /// information.
47
+ /// - `channel`: The channel through which the request was received.
48
+ /// - `ctx`: The connection handler context associated with the request.
49
+ /// - `subscription_data`: Subscription data for the consumer making the request.
50
+ /// - `subscription_group_config`: Configuration for the subscription group of the consumer.
51
+ /// - `broker_allow_suspend`: Flag indicating whether the broker allows suspending the request.
52
+ /// - `message_filter`: The message filter to apply to the retrieved messages.
53
+ /// - `response`: The initial response remoting command to be potentially modified and returned.
54
+ /// - `mapping_context`: Context for topic-queue mapping.
55
+ /// - `begin_time_mills`: The timestamp (in milliseconds) when the request began processing.
56
+ ///
57
+ /// # Returns
58
+ /// An optional `RemotingCommand` representing the response to the pull message request.
59
+ /// If `None`, it indicates that no response should be sent back to the client.
29
60
fn handle (
30
61
& self ,
31
62
get_message_result : GetMessageResult ,
@@ -41,4 +72,14 @@ pub trait PullMessageResultHandler: Sync + Send + 'static {
41
72
mapping_context : TopicQueueMappingContext ,
42
73
begin_time_mills : u64 ,
43
74
) -> Option < RemotingCommand > ;
75
+
76
+ /// Returns a mutable reference to `self` as a trait object of type `Any`.
77
+ ///
78
+ /// This method is useful for downcasting the trait object to its concrete type.
79
+ fn as_any_mut ( & mut self ) -> & mut dyn Any ;
80
+
81
+ /// Returns a reference to `self` as a trait object of type `Any`.
82
+ ///
83
+ /// This method is useful for downcasting the trait object to its concrete type.
84
+ fn as_any ( & self ) -> & dyn Any ;
44
85
}
0 commit comments