Skip to content

Commit 58d26ff

Browse files
authored
Update getMessageState -> getState (Azure#27020)
* Rename to getState * Update CHANGELOG.
1 parent 1528953 commit 58d26ff

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

sdk/servicebus/azure-messaging-servicebus/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## 7.6.0-beta.1 (Unreleased)
44

55
### Features Added
6-
- Add `ServiceBusMessageState` property to received messages which indicates whether the message is active, scheduled or deferred. It is exposed it in `ServiceBusReceivedMessage.getMessageState()`. ([#25217](https://github.com/Azure/azure-sdk-for-java/issues/25217))
6+
- Add `ServiceBusMessageState` property to received messages which indicates whether the message is active, scheduled or deferred. It is exposed it in `ServiceBusReceivedMessage.getState()`. ([#25217](https://github.com/Azure/azure-sdk-for-java/issues/25217))
77

88
### Bugs Fixed
99

sdk/servicebus/azure-messaging-servicebus/src/main/java/com/azure/messaging/servicebus/ServiceBusReceivedMessage.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -323,25 +323,6 @@ public String getMessageId() {
323323
return messageId;
324324
}
325325

326-
/**
327-
* Gets the state of the message.
328-
*
329-
* The state of the message can be Active, Deferred, or Scheduled. Deferred messages have Deferred state, scheduled
330-
* messages have Scheduled state, all other messages have Active state.
331-
*
332-
* @return The state of the message.
333-
* @throws UnsupportedOperationException if the message state is an unknown value.
334-
*/
335-
public ServiceBusMessageState getMessageState() {
336-
final Object value = amqpAnnotatedMessage.getMessageAnnotations().get(SERVICE_BUS_MESSAGE_STATE_KEY);
337-
338-
if (value instanceof Integer) {
339-
return ServiceBusMessageState.fromValue((Integer) value);
340-
} else {
341-
return ServiceBusMessageState.ACTIVE;
342-
}
343-
}
344-
345326
/**
346327
* Gets the partition key for sending a message to a partitioned entity.
347328
* <p>
@@ -464,6 +445,25 @@ public String getSessionId() {
464445
return getRawAmqpMessage().getProperties().getGroupId();
465446
}
466447

448+
/**
449+
* Gets the state of the message.
450+
*
451+
* The state of the message can be Active, Deferred, or Scheduled. Deferred messages have Deferred state, scheduled
452+
* messages have Scheduled state, all other messages have Active state.
453+
*
454+
* @return The state of the message.
455+
* @throws UnsupportedOperationException if the message state is an unknown value.
456+
*/
457+
public ServiceBusMessageState getState() {
458+
final Object value = amqpAnnotatedMessage.getMessageAnnotations().get(SERVICE_BUS_MESSAGE_STATE_KEY);
459+
460+
if (value instanceof Integer) {
461+
return ServiceBusMessageState.fromValue((Integer) value);
462+
} else {
463+
return ServiceBusMessageState.ACTIVE;
464+
}
465+
}
466+
467467
/**
468468
* Gets the subject for the message.
469469
*

sdk/servicebus/azure-messaging-servicebus/src/test/java/com/azure/messaging/servicebus/ServiceBusReceivedMessageTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public void canGetMessageState(Integer value, ServiceBusMessageState expected) {
170170
message.getRawAmqpMessage().getMessageAnnotations().put(SERVICE_BUS_MESSAGE_STATE_KEY, value);
171171

172172
// Act
173-
final ServiceBusMessageState actual = message.getMessageState();
173+
final ServiceBusMessageState actual = message.getState();
174174

175175
// Assert
176176
assertEquals(expected, actual);
@@ -180,7 +180,7 @@ public void canGetMessageState(Integer value, ServiceBusMessageState expected) {
180180
public void defaultMessageState() {
181181
final ServiceBusReceivedMessage message = new ServiceBusReceivedMessage(PAYLOAD_BINARY);
182182

183-
assertEquals(ServiceBusMessageState.ACTIVE, message.getMessageState());
183+
assertEquals(ServiceBusMessageState.ACTIVE, message.getState());
184184
}
185185

186186
@Test
@@ -190,7 +190,7 @@ public void throwsOnInvalidMessageState() {
190190
message.getRawAmqpMessage().getMessageAnnotations().put(SERVICE_BUS_MESSAGE_STATE_KEY, 10);
191191

192192
// Act & Assert
193-
assertThrows(UnsupportedOperationException.class, () -> message.getMessageState());
193+
assertThrows(UnsupportedOperationException.class, () -> message.getState());
194194
}
195195

196196
public void assertNullValues(Map<String, Object> dataMap, AmqpMessageConstant... keys) {

0 commit comments

Comments
 (0)