Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Service Bus] Remove viaPartitionKey #17501

Merged
merged 2 commits into from
Nov 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import static com.azure.core.amqp.AmqpMessageConstant.PARTITION_KEY_ANNOTATION_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.SCHEDULED_ENQUEUE_UTC_TIME_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.SEQUENCE_NUMBER_ANNOTATION_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.VIA_PARTITION_KEY_ANNOTATION_NAME;

/**
* The data structure encapsulating the message being sent-to Service Bus.
Expand Down Expand Up @@ -459,34 +458,6 @@ public ServiceBusMessage setReplyToSessionId(String replyToSessionId) {
return this;
}

/**
* Gets the partition key for sending a message to a entity via another partitioned transfer entity.
*
* If a message is sent via a transfer queue in the scope of a transaction, this value selects the transfer queue
* partition: This is functionally equivalent to {@link #getPartitionKey()} and ensures that messages are kept
* together and in order as they are transferred.
*
* @return partition key on the via queue.
* @see <a href="https://docs.microsoft.com/azure/service-bus-messaging/service-bus-transactions#transfers-and-send-via">Transfers
* and Send Via</a>
*/
public String getViaPartitionKey() {
return (String) amqpAnnotatedMessage.getMessageAnnotations().get(VIA_PARTITION_KEY_ANNOTATION_NAME.getValue());
}

/**
* Sets a via-partition key for sending a message to a destination entity via another partitioned entity
*
* @param viaPartitionKey via-partition key of this message
*
* @return The updated {@link ServiceBusMessage}.
* @see #getViaPartitionKey()
*/
public ServiceBusMessage setViaPartitionKey(String viaPartitionKey) {
amqpAnnotatedMessage.getMessageAnnotations().put(VIA_PARTITION_KEY_ANNOTATION_NAME.getValue(), viaPartitionKey);
return this;
}

/**
* Gets the session id of the message.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

import static com.azure.core.amqp.AmqpMessageConstant.SCHEDULED_ENQUEUE_UTC_TIME_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.PARTITION_KEY_ANNOTATION_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.VIA_PARTITION_KEY_ANNOTATION_NAME;
import com.azure.core.amqp.exception.AmqpResponseCode;
import com.azure.core.amqp.implementation.MessageSerializer;
import com.azure.core.amqp.implementation.RequestResponseUtils;
Expand Down Expand Up @@ -197,11 +196,6 @@ public <T> Message serialize(T object) {
brokeredMessage.getPartitionKey());
}

final String viaPartitionKey = brokeredMessage.getViaPartitionKey();
if (viaPartitionKey != null && !viaPartitionKey.isEmpty()) {
messageAnnotationsMap.put(Symbol.valueOf(VIA_PARTITION_KEY_ANNOTATION_NAME.getValue()), viaPartitionKey);
}

amqpMessage.setMessageAnnotations(new MessageAnnotations(messageAnnotationsMap));

// Set Delivery Annotations.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import static com.azure.core.amqp.AmqpMessageConstant.PARTITION_KEY_ANNOTATION_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.SCHEDULED_ENQUEUE_UTC_TIME_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.SEQUENCE_NUMBER_ANNOTATION_NAME;
import static com.azure.core.amqp.AmqpMessageConstant.VIA_PARTITION_KEY_ANNOTATION_NAME;

/**
* This class represents a received message from Service Bus.
Expand Down Expand Up @@ -417,22 +416,6 @@ public String getTo() {
return amqpAnnotatedMessage.getProperties().getTo();
}

/**
* Gets the partition key for sending a message to a entity via another partitioned transfer entity.
*
* If a message is sent via a transfer queue in the scope of a transaction, this value selects the
* transfer queue partition: This is functionally equivalent to {@link #getPartitionKey()} and ensures that
* messages are kept together and in order as they are transferred.
*
* @return partition key on the via queue.
*
* @see <a href="https://docs.microsoft.com/azure/service-bus-messaging/service-bus-transactions#transfers-and-send-via">Transfers and Send Via</a>
*/
public String getViaPartitionKey() {
return getStringValue(amqpAnnotatedMessage.getMessageAnnotations(),
VIA_PARTITION_KEY_ANNOTATION_NAME.getValue());
}

/**
* Gets whether the message has been settled.
*
Expand Down Expand Up @@ -651,17 +634,6 @@ void setTo(String to) {
amqpAnnotatedMessage.getProperties().setTo(to);
}

/**
* Sets a via-partition key for sending a message to a destination entity via another partitioned entity
*
* @param viaPartitionKey via-partition key of this message
*
* @see #getViaPartitionKey()
*/
void setViaPartitionKey(String viaPartitionKey) {
amqpAnnotatedMessage.getMessageAnnotations().put(VIA_PARTITION_KEY_ANNOTATION_NAME.getValue(), viaPartitionKey);
}

/*
* Gets String value from given map and null if key does not exists.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,6 @@ public Flux<Long> schedule(List<ServiceBusMessage> messages, OffsetDateTime sche
messageEntry.put(ManagementConstants.PARTITION_KEY, partitionKey);
}

final String viaPartitionKey = message.getViaPartitionKey();
if (!CoreUtils.isNullOrEmpty(viaPartitionKey)) {
messageEntry.put(ManagementConstants.VIA_PARTITION_KEY, viaPartitionKey);
}

messageList.add(messageEntry);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public void toServiceBusMessageTest() {
originalMessage.setContentType("type");
originalMessage.setCorrelationId("cid");
originalMessage.setReplyTo("rto");
originalMessage.setViaPartitionKey("something");
originalMessage.setTimeToLive(Duration.ofSeconds(10));
originalMessage.setReplyToSessionId("rsessionid");
originalMessage.setSubject("subject");
Expand Down Expand Up @@ -132,7 +131,6 @@ public void toServiceBusMessageTest() {
assertEquals(originalMessage.getContentType(), actual.getContentType());
assertEquals(originalMessage.getCorrelationId(), actual.getCorrelationId());
assertEquals(originalMessage.getReplyTo(), actual.getReplyTo());
assertEquals(originalMessage.getViaPartitionKey(), actual.getViaPartitionKey());
assertEquals(originalMessage.getTimeToLive().toMillis(), actual.getTimeToLive().toMillis());
assertEquals(originalMessage.getLabel(), actual.getSubject());
assertEquals(originalMessage.getReplyToSessionId(), actual.getReplyToSessionId());
Expand Down