CorrelationRuleFilter Class
- java.
lang. Object - com.
azure. messaging. servicebus. administration. models. RuleFilter - com.
azure. messaging. servicebus. administration. models. CorrelationRuleFilter
- com.
- com.
public class CorrelationRuleFilter
extends RuleFilter
Represents the correlation rule filter expression. It holds a set of conditions that are matched against one or more of an arriving message's user and system properties. A common use case is to match against the message's:
- getCorrelationId()
- getContentType()
- getSubject()
- getMessageId()
- getReplyTo()
- getReplyToSessionId()
- getSessionId()
- getTo()
- or, any getApplicationProperties()
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());
Constructor Summary
Constructor | Description |
---|---|
CorrelationRuleFilter() |
Initializes a new instance of CorrelationRuleFilter with default values. |
CorrelationRuleFilter(String correlationId) |
Initializes a new instance of CorrelationRuleFilter with default values with the specified correlation identifier. |
Method Summary
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object other)
Compares this Rule |
String |
getContentType()
Gets the content type of the message. |
String |
getCorrelationId()
Gets the correlation identifier. |
String |
getLabel()
Gets the application specific label. |
String |
getMessageId()
Gets the identifier for the message. |
Map<String,Object> |
getProperties()
Gets application specific properties of the message. |
String |
getReplyTo()
Gets the address of the queue or subscription to reply to. |
String |
getReplyToSessionId()
Gets the session identifier to reply to. |
String |
getSessionId()
Gets the session identifier. |
String |
getTo()
Gets the address to send to. |
int |
hashCode()
Returns a hash code for this Correlation |
Correlation |
setContentType(String contentType)
Sets the content type of the message. |
Correlation |
setCorrelationId(String correlationId)
Sets the correlation identifier. |
Correlation |
setLabel(String label)
Sets the application specific label. |
Correlation |
setMessageId(String messageId)
Sets the identifier for the message. |
Correlation |
setReplyTo(String replyTo)
Sets the address of the queue or subscription to reply to. |
Correlation |
setReplyToSessionId(String replyToSessionId)
Sets the session identifier to reply to. |
Correlation |
setSessionId(String sessionId)
Sets the session identifier. |
Correlation |
setTo(String to)
Sets the address to send to. |
String |
toString()
Converts the value of the current instance to its equivalent string representation. |
Methods inherited from java.lang.Object
Constructor Details
CorrelationRuleFilter
public CorrelationRuleFilter()
Initializes a new instance of CorrelationRuleFilter with default values.
CorrelationRuleFilter
public CorrelationRuleFilter(String correlationId)
Initializes a new instance of CorrelationRuleFilter with default values with the specified correlation identifier.
Parameters:
Method Details
equals
public boolean equals(Object other)
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.
Overrides:
CorrelationRuleFilter.equals(Object other)Parameters:
- the object to which the current CorrelationRuleFilter should be compared.
Returns:
getContentType
public String getContentType()
Gets the content type of the message.
Returns:
getCorrelationId
public String getCorrelationId()
Gets the correlation identifier.
Returns:
getLabel
public String getLabel()
Gets the application specific label.
Returns:
getMessageId
public String getMessageId()
Gets the identifier for the message.
Returns:
getProperties
public Map
Gets application specific properties of the message.
Returns:
getReplyTo
public String getReplyTo()
Gets the address of the queue or subscription to reply to.
Returns:
getReplyToSessionId
public String getReplyToSessionId()
Gets the session identifier to reply to.
Returns:
getSessionId
public String getSessionId()
Gets the session identifier.
Returns:
getTo
public String getTo()
Gets the address to send to.
Returns:
hashCode
public int hashCode()
Returns a hash code for this CorrelationRuleFilter.
Overrides:
CorrelationRuleFilter.hashCode()Returns:
setContentType
public CorrelationRuleFilter setContentType(String contentType)
Sets the content type of the message.
Parameters:
Returns:
setCorrelationId
public CorrelationRuleFilter setCorrelationId(String correlationId)
Sets the correlation identifier.
Parameters:
Returns:
setLabel
public CorrelationRuleFilter setLabel(String label)
Sets the application specific label.
Parameters:
Returns:
setMessageId
public CorrelationRuleFilter setMessageId(String messageId)
Sets the identifier for the message.
Parameters:
Returns:
setReplyTo
public CorrelationRuleFilter setReplyTo(String replyTo)
Sets the address of the queue or subscription to reply to.
Parameters:
Returns:
setReplyToSessionId
public CorrelationRuleFilter setReplyToSessionId(String replyToSessionId)
Sets the session identifier to reply to. Max size of replyToSessionId
is 128.
Parameters:
Returns:
setSessionId
public CorrelationRuleFilter setSessionId(String sessionId)
Sets the session identifier. Max size of sessionId
is 128 chars.
Parameters:
Returns:
setTo
public CorrelationRuleFilter setTo(String to)
Sets the address to send to.
Parameters:
Returns:
toString
public String toString()
Converts the value of the current instance to its equivalent string representation.
Overrides:
CorrelationRuleFilter.toString()Returns:
Applies to
Azure SDK for Java
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기