Class CorrelationRuleFilter
correlation idcontent typesubjectmessage idreply-toreply-to session idsession idto- or, any
user-defined properties
A match exists when an arriving message's value for a property is equal to the value specified in the correlation
filter. For string expressions, the comparison is case-sensitive. When specifying multiple match properties, the
filter combines them as a logical AND condition, meaning all conditions must match for the filter to
match.
This provides an efficient shortcut for declarations of filters that deal only with correlation
equality. In this case the cost of the lexicographical analysis of the expression can be avoided. Not only will
correlation filters be optimized at declaration time, but they will also be optimized at runtime. Correlation filter
matching can be reduced to a hashtable lookup, which aggregates the complexity of the set of defined correlation
filters to O(1).
Sample: Create a topic, subscription, and rule
The following code sample demonstrates the creation of a Service Bus topic and subscription. The subscription
filters for messages with a correlation id "emails" and has a "importance" property set
to "high". Consequently, all high importance messages will be delivered to the
"high-importance-subscription" subscription. See
Topic filters for additional
information.
String topicName = "my-new-topic";
TopicProperties topic = client.createTopic(topicName);
String subscriptionName = "high-importance-subscription";
String ruleName = "important-emails-filter";
CreateSubscriptionOptions subscriptionOptions = new CreateSubscriptionOptions()
.setMaxDeliveryCount(15)
.setLockDuration(Duration.ofMinutes(2));
CorrelationRuleFilter ruleFilter = new CorrelationRuleFilter()
.setCorrelationId("emails");
ruleFilter.getProperties().put("importance", "high");
CreateRuleOptions createRuleOptions = new CreateRuleOptions()
.setFilter(ruleFilter);
SubscriptionProperties subscription = client.createSubscription(topicName, subscriptionName, ruleName,
subscriptionOptions, createRuleOptions);
System.out.printf("Subscription created. Name: %s. Topic name: %s. Lock Duration: %s.%n",
subscription.getSubscriptionName(), subscription.getTopicName(), subscription.getLockDuration());
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionInitializes a new instance ofCorrelationRuleFilterwith default values.CorrelationRuleFilter(String correlationId) Initializes a new instance ofCorrelationRuleFilterwith default values with the specified correlation identifier. -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this RuleFilter to the specified object.Gets the content type of the message.Gets the correlation identifier.getLabel()Gets the application specific label.Gets the identifier for the message.Gets application specific properties of the message.Gets the address of the queue or subscription to reply to.Gets the session identifier to reply to.Gets the session identifier.getTo()Gets the address to send to.inthashCode()Returns a hash code for this CorrelationRuleFilter.setContentType(String contentType) Sets the content type of the message.setCorrelationId(String correlationId) Sets the correlation identifier.Sets the application specific label.setMessageId(String messageId) Sets the identifier for the message.setReplyTo(String replyTo) Sets the address of the queue or subscription to reply to.setReplyToSessionId(String replyToSessionId) Sets the session identifier to reply to.setSessionId(String sessionId) Sets the session identifier.Sets the address to send to.toString()Converts the value of the current instance to its equivalent string representation.
-
Constructor Details
-
CorrelationRuleFilter
public CorrelationRuleFilter()Initializes a new instance ofCorrelationRuleFilterwith default values. -
CorrelationRuleFilter
Initializes a new instance ofCorrelationRuleFilterwith default values with the specified correlation identifier.- Parameters:
correlationId- The identifier for the correlation.- Throws:
IllegalArgumentException- IfcorrelationIdis an empty string.NullPointerException- IfcorrelationIdis null.
-
-
Method Details
-
getContentType
Gets the content type of the message.- Returns:
- The content type of the message.
-
setContentType
Sets the content type of the message.- Parameters:
contentType- The content type of the message.- Returns:
- The updated
CorrelationRuleFilteritself.
-
getCorrelationId
Gets the correlation identifier.- Returns:
- The correlation identifier.
-
setCorrelationId
Sets the correlation identifier.- Parameters:
correlationId- The correlation identifier.- Returns:
- The updated
CorrelationRuleFilteritself.
-
getLabel
Gets the application specific label.- Returns:
- The application specific label.
-
setLabel
Sets the application specific label.- Parameters:
label- The application specific label.- Returns:
- The updated
CorrelationRuleFilteritself.
-
getMessageId
Gets the identifier for the message.- Returns:
- The identifier for the message.
-
setMessageId
Sets the identifier for the message.- Parameters:
messageId- The identifier for the message.- Returns:
- The updated
CorrelationRuleFilteritself.
-
getProperties
Gets application specific properties of the message.- Returns:
- The application specific properties of the message.
-
getReplyTo
Gets the address of the queue or subscription to reply to.- Returns:
- The address of the queue or subscription to reply to.
-
setReplyTo
Sets the address of the queue or subscription to reply to.- Parameters:
replyTo- The address of the queue or subscription to reply to.- Returns:
- The updated
CorrelationRuleFilteritself.
-
getReplyToSessionId
Gets the session identifier to reply to.- Returns:
- The session identifier to reply to.
-
setReplyToSessionId
Sets the session identifier to reply to. Max size ofreplyToSessionIdis 128.- Parameters:
replyToSessionId- The session identifier to reply to.- Returns:
- The updated
CorrelationRuleFilteritself.
-
getSessionId
Gets the session identifier.- Returns:
- The session identifier.
-
setSessionId
Sets the session identifier. Max size ofsessionIdis 128 chars.- Parameters:
sessionId- The session identifier.- Returns:
- The updated
CorrelationRuleFilteritself.
-
getTo
Gets the address to send to.- Returns:
- The address to send to.
-
setTo
Sets the address to send to.- Parameters:
to- The address to send to.- Returns:
- The updated
CorrelationRuleFilteritself.
-
toString
Converts the value of the current instance to its equivalent string representation. -
equals
Compares this RuleFilter to the specified object. The result is true if and only if the argument is not null and is a CorrelationRuleFilter object that with the same parameters as this object. -
hashCode
public int hashCode()Returns a hash code for this CorrelationRuleFilter.
-