-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exposing MessageState in ServiceBusReceivedMessage (#26897)
* Adding ServiceBusMessageState. * Exposing ServiceBusMessageState and returning it. * Add CHANGELOG entry * Adding tests.
- Loading branch information
Showing
4 changed files
with
134 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
...ervicebus/src/main/java/com/azure/messaging/servicebus/models/ServiceBusMessageState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.messaging.servicebus.models; | ||
|
||
import com.azure.messaging.servicebus.ServiceBusReceivedMessage; | ||
|
||
/** | ||
* Represents the message state of the {@link ServiceBusReceivedMessage}. | ||
*/ | ||
public enum ServiceBusMessageState { | ||
/** | ||
* Specifies an active message state. | ||
*/ | ||
ACTIVE(0), | ||
/** | ||
* Specifies a deferred message state. | ||
*/ | ||
DEFERRED(1), | ||
/** | ||
* Specifies a scheduled message state. | ||
*/ | ||
SCHEDULED(2); | ||
|
||
private final int value; | ||
|
||
ServiceBusMessageState(int value) { | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* Gets the value of the message state. | ||
* | ||
* @return The value of the message state. | ||
*/ | ||
public int getValue() { | ||
return value; | ||
} | ||
|
||
/** | ||
* Gets the message state from {@code value}. | ||
* | ||
* @param value Integer value of the message state. | ||
* | ||
* @return The corresponding message state. | ||
* | ||
* @throws UnsupportedOperationException if {@code value} is not a known message state. | ||
*/ | ||
public static ServiceBusMessageState fromValue(int value) { | ||
switch (value) { | ||
case 0: | ||
return ServiceBusMessageState.ACTIVE; | ||
case 1: | ||
return ServiceBusMessageState.DEFERRED; | ||
case 2: | ||
return ServiceBusMessageState.SCHEDULED; | ||
default: | ||
throw new UnsupportedOperationException( | ||
"Value is not supported. Should be 0(ACTIVE), 1(DEFERRED), or 2(SCHEDULED). Actual: " + value); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters