Subscription policy
You can use a subscription policy to specify which clients can create, modify, or delete global-shared durable subscriptions. You can also set up the authorization for a client to receive messages from a global-shared durable subscription. Global-shared durable subscriptions require a subscription policy and a topic policy; all other types of subscriptions, including non-durable shared subscriptions, require only a topic messaging policy.
For information about authorizing the configuration and use of topic policies, see Topic policy.
A subscription policy is used to authorize global-shared durable subscriptions. In the case of global-shared durable subscriptions, the subscription policy is required in addition to the topic policy that is required for all subscription types. For more information about the different types of subscriptions, see Subscribers and Subscriptions.
- In JMS, the DurableName property specifies the name of the global-shared durable subscription.
- In the Eclipse Amlen MQTT extension for supporting shared subscriptions, the SubName part of the MQTT shared subscription topic filter specifies the name of the global-shared durable subscription. The SUBSCRIBE request in MQTT specifies the following string:
$SharedSubscription/SubName/topicFilter
where:
- $SharedSubscription
- Indicates that the target of the SUBSCRIBE request is a global-shared subscription.
- SubName
- Is the name of the global-shared subscription; in this case, it is a global-shared durable subscription.
- topicFilter
- Is a standard MQTT topic filter for any type of topic subscription. It can contain a single topic name, or it can contain a topic filter that includes wildcards. This string corresponds to the Topic parameter that is specified in the topic policy that is associated with the subscription policy.
Subscription
field. When you create a subscription policy, you authorize clients to use the global-shared durable subscription, but not the associated topic. Therefore, you must create a separate topic policy to authorize clients to use the associated topic. For more information about configuring topic policies to enable global-shared durable subscriptions to be used, see Topic filters for MQTT global-shared subscriptions.-
- Control
- Allows clients to create and delete the global-shared durable subscription that is specified in the subscription policy.
-
- Receive
- Allows clients to receive messages from the global-shared durable subscription that is specified in the subscription policy.
-
- Client IP address
- Specifies the client IP addresses that are allowed to connect to Eclipse Amlen.
-
- User ID
- Specifies the messaging user ID that is allowed to connect to Eclipse Amlen by using the specified endpoint.
-
- Group Name
- Specifies the messaging group that is allowed to connect to Eclipse Amlen by using the specified endpoint.
-
- Certificate Common Name
- Specifies the client certificate common name that must be used to connect to Eclipse Amlen by using the specified endpoint.
-
- Protocol
- Specifies which protocols are allowed to use the actions that are specified in the subscription policy on the global-shared durable subscription that is specified in the policy.
exampleSub
: - One subscription policy specifies that only clients within a group that starts
with
example
can control the shared subscription. - Another subscription policy specifies that only clients that connect from the
IP address range of
192.0.2.51-192.0.2.100
can receive messages from the shared subscription. The client must also have a user ID beginning withuser
.
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"SubscriptionPolicy": {
"exampleSubPolicy1": {
"Description": "Subscription policy that restricts based on group membership.",
"Subscription": "exampleSub*",
"GroupID": "example",
"ActionList": "Control,Receive"
}
}
}
' \
http://127.0.0.1:9089/ima/v1/configuration/
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
"SubscriptionPolicy": {
"exampleSubPolicy2": {
"Description": "Subscription policy that restricts based on IP address and user ID.",
"Subscription": "exampleSub*",
"UserID": "user*",
"ClientAddress": "192.0.2.51-192.0.2.100",
"ActionList": "Receive"
}
}
}
' \
http://127.0.0.1:9089/ima/v1/configuration/
You can use variable substitution in subscription policies to avoid configuring large numbers of messaging policies. For more information about using variable substitution, see Variable substitution in messaging policies.
For more information about configuring messaging policies, see Configuring message hubs.