Skip to content

Commit

Permalink
Adding a minor validation in Message to ensure partition key is same …
Browse files Browse the repository at this point in the history
…as sessionid. (#10612)

If sessionid is set on a message, then partition key should be same as sessionid. For some customers using sessions, partition key was not at all in the broker and some operations started failing as service bus service assumes partition key will be same as session key. It validates partition key now.
  • Loading branch information
yvgopal authored May 1, 2020
1 parent 305dbd8 commit f21c56a
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ public String getSessionId() {
@Override
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
this.partitionKey = sessionId;
}

@Override
Expand Down Expand Up @@ -321,6 +322,11 @@ public String getPartitionKey() {

@Override
public void setPartitionKey(String partitionKey) {
if (this.sessionId != null && !this.sessionId.equals(partitionKey))
{
// SessionId is set. Then partition key must be same as session id.
throw new IllegalArgumentException("PartitionKey:" + partitionKey +" is not same as SessionId:" + this.sessionId);
}
this.partitionKey = partitionKey;
}

Expand Down

0 comments on commit f21c56a

Please sign in to comment.