001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.messaging.simp.broker; 018 019import org.springframework.messaging.Message; 020import org.springframework.util.MultiValueMap; 021 022/** 023 * A registry of subscription by session that allows looking up subscriptions. 024 * 025 * @author Rossen Stoyanchev 026 * @since 4.0 027 */ 028public interface SubscriptionRegistry { 029 030 /** 031 * Register a subscription represented by the given message. 032 * @param subscribeMessage the subscription request 033 */ 034 void registerSubscription(Message<?> subscribeMessage); 035 036 /** 037 * Unregister a subscription. 038 * @param unsubscribeMessage the request to unsubscribe 039 */ 040 void unregisterSubscription(Message<?> unsubscribeMessage); 041 042 /** 043 * Remove all subscriptions associated with the given sessionId. 044 */ 045 void unregisterAllSubscriptions(String sessionId); 046 047 /** 048 * Find all subscriptions that should receive the given message. 049 * The map returned is safe to iterate and will never be modified. 050 * @param message the message 051 * @return a {@code MultiValueMap} with sessionId-subscriptionId pairs 052 * (possibly empty) 053 */ 054 MultiValueMap<String, String> findSubscriptions(Message<?> message); 055 056}