-
Notifications
You must be signed in to change notification settings - Fork 2.2k
SB Track2: Expose AMQP details ServiceBus Messages for sending and receiving. #14848
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
Merged
hemanttanwar
merged 29 commits into
Azure:master
from
hemanttanwar:sb-track2-expose-amqp-message-details-14385
Sep 10, 2020
Merged
Changes from 10 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
002335f
Continue Implementation
672b166
Continue implementation
10f0647
Continue implementation
5cd4b18
Continue implementation
7dee518
Continue implementation
eea67f1
Merge branch 'master' into sb-track2-expose-amqp-message-details-14385
0e3956c
Continue initial draft implementation: moved sbrm to models
735f657
Draft implementation
a4100f0
Draft implementation
6614ebd
Removed commented code
00f7a82
Added more implementation
ec6758b
Incorporated Review comments
587d2e9
Incorporated Review comments
8fbbf9f
fixing some test
0863421
Fixing text
72c3818
Fix test and checkstyle
836e6b3
Incorporated review comments.
2d680f1
Added unit test case.
b4baee7
Added unit test case and general cleanup
b475d65
Added unit test case and general cleanup
6cf5072
Added change log.
947d146
Adding more unit test
814cd01
Adding more unit test
5f7fa17
Merge branch 'master' into sb-track2-expose-amqp-message-details-14385
72c4476
Added more comment
e019fc5
Added more check in unit test
5243462
Adding more test
3fe4224
Review comments
ea1ee38
Adding java doc
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpAnnotatedMessage.java
This file contains hidden or 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,126 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.amqp.models; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Amqp representation of the message. | ||
| */ | ||
| public final class AmqpAnnotatedMessage { | ||
| private final AmqpMessageBody amqpMessageBody; | ||
| private Map<String, Object> applicationProperties; | ||
| private Map<String, Object> deliveryAnnotations; | ||
| private Map<String, Object> messageAnnotations; | ||
| private Map<String, Object> footer; | ||
| private AmqpMessageHeader header; | ||
| private AmqpMessageProperties properties; | ||
|
|
||
| /** | ||
| * Creates instance of {@link AmqpAnnotatedMessage} with given {@link AmqpMessageBody}. | ||
| * | ||
| * @param body to be set on amqp message. | ||
| */ | ||
| public AmqpAnnotatedMessage(AmqpMessageBody body) { | ||
| this.amqpMessageBody = Objects.requireNonNull(body, "'body' cannot be null."); | ||
| } | ||
|
|
||
| /** | ||
| * Creates instance of {@link AmqpAnnotatedMessage} with given {@link AmqpAnnotatedMessage}. | ||
| * | ||
| * @param message used to create another instance of {@link AmqpAnnotatedMessage}. | ||
| */ | ||
| public AmqpAnnotatedMessage(AmqpAnnotatedMessage message) { | ||
| Objects.requireNonNull(message, "'message' cannot be null."); | ||
| this.amqpMessageBody = Objects.requireNonNull(message.getBody(), "'message.body' cannot be null."); | ||
| this.applicationProperties = message.getApplicationProperties(); | ||
| this.deliveryAnnotations = message.getDeliveryAnnotations(); | ||
| this.messageAnnotations = message.getMessageAnnotations(); | ||
| this.header = message.getHeader(); | ||
| this.properties = message.getProperties(); | ||
| } | ||
|
|
||
| /** | ||
| * Gets the {@link Map} of application properties. | ||
| * @return The application properties. | ||
| */ | ||
| public Map<String, Object> getApplicationProperties() { | ||
| if (this.applicationProperties == null) { | ||
| this.applicationProperties = new HashMap<>(); | ||
| } | ||
| return applicationProperties; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the {@link AmqpMessageBody}. | ||
| * | ||
| * @return the {@link AmqpMessageBody} object. | ||
| */ | ||
| public AmqpMessageBody getBody() { | ||
| return amqpMessageBody; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the {@link Map} representation of delivery annotations. | ||
| * | ||
| * @return the {@link Map} representation of delivery annotations. | ||
| */ | ||
| public Map<String, Object> getDeliveryAnnotations() { | ||
| if (deliveryAnnotations == null) { | ||
| this.deliveryAnnotations = new HashMap<>(); | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| return deliveryAnnotations; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the {@link Map} representation of footer. | ||
| * | ||
| * @return the {@link Map} representation of footer. | ||
| */ | ||
| public Map<String, Object> getFooter() { | ||
| if (this.footer == null) { | ||
| this.footer = new HashMap<>(); | ||
| } | ||
| return footer; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the {@link AmqpMessageHeader}. | ||
| * | ||
| * @return the {@link AmqpMessageHeader} object. | ||
| */ | ||
| public AmqpMessageHeader getHeader() { | ||
| if (this.header == null) { | ||
| this.header = new AmqpMessageHeader(); | ||
| } | ||
| return header; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the {@link Map} representation of message annotations. | ||
| * | ||
| * @return the {@link Map} representation of message annotations. | ||
| */ | ||
| public Map<String, Object> getMessageAnnotations() { | ||
| if (messageAnnotations == null) { | ||
| this.messageAnnotations = new HashMap<>(); | ||
| } | ||
| return messageAnnotations; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the {@link AmqpMessageProperties}. | ||
| * | ||
| * @return the {@link AmqpMessageProperties} object. | ||
| */ | ||
| public AmqpMessageProperties getProperties() { | ||
| if (properties == null) { | ||
| this.properties = new AmqpMessageProperties(); | ||
| } | ||
| return properties; | ||
| } | ||
| } | ||
54 changes: 54 additions & 0 deletions
54
sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpBodyType.java
This file contains hidden or 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,54 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.amqp.models; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| /** | ||
| * All AmqpBodyType available for AMQP Message. | ||
| */ | ||
| public enum AmqpBodyType { | ||
| /** | ||
| * Represent Amqp Data type | ||
| */ | ||
| DATA("Data"), | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| /** | ||
| * Represent Amqp Value type | ||
| */ | ||
| VALUE("Value"), | ||
| /** | ||
| * Represent Amqp Sequence type | ||
| */ | ||
| SEQUENCE("Sequence"); | ||
|
|
||
| private final String value; | ||
|
|
||
| AmqpBodyType(final String value) { | ||
| this.value = value; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritDoc} | ||
| */ | ||
| @Override | ||
| public String toString() { | ||
| return this.value; | ||
| } | ||
| /** | ||
| * Creates an AmqpBodyType from its display value. | ||
| * | ||
| * @param value The string value of the AmqpBodyType. | ||
| * @return The AmqpBodyType represented by the value. | ||
| * @throws IllegalArgumentException If a AmqpBodyType cannot be parsed from the string value. | ||
| */ | ||
| public static AmqpBodyType fromString(final String value) { | ||
| for (AmqpBodyType bodyType : values()) { | ||
| if (bodyType.value.equalsIgnoreCase(value)) { | ||
| return bodyType; | ||
| } | ||
| } | ||
|
|
||
| throw new IllegalArgumentException(String.format(Locale.US, "Could not convert %s to a AmqpBodyType", value)); | ||
| } | ||
| } | ||
37 changes: 37 additions & 0 deletions
37
sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpDataBody.java
This file contains hidden or 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,37 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.amqp.models; | ||
|
|
||
| import com.azure.core.util.IterableStream; | ||
|
|
||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| */ | ||
| public final class AmqpDataBody implements AmqpMessageBody { | ||
|
hemanttanwar marked this conversation as resolved.
|
||
| private final AmqpBodyType bodyType; | ||
| private final IterableStream<BinaryData> data; | ||
|
|
||
| /** | ||
| * @param data to be set. | ||
| */ | ||
| public AmqpDataBody(Iterable<BinaryData> data) { | ||
| Objects.requireNonNull(data, "'data' cannot be null."); | ||
| this.data = new IterableStream<>(data); | ||
| this.bodyType = AmqpBodyType.DATA; | ||
| } | ||
|
|
||
| @Override | ||
| public AmqpBodyType getBodyType() { | ||
| return bodyType; | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| /** | ||
| * @return data. | ||
| */ | ||
| public IterableStream<BinaryData> getData() { | ||
| return data; | ||
| } | ||
| } | ||
15 changes: 15 additions & 0 deletions
15
sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpMessageBody.java
This file contains hidden or 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,15 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.amqp.models; | ||
|
|
||
| /** | ||
| * Interface representing Amqp Message Body. | ||
| */ | ||
| public interface AmqpMessageBody { | ||
| /** | ||
| * | ||
| * @return The {@link AmqpBodyType}. | ||
| */ | ||
| AmqpBodyType getBodyType(); | ||
| } |
123 changes: 123 additions & 0 deletions
123
sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpMessageHeader.java
This file contains hidden or 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,123 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.core.amqp.models; | ||
|
|
||
| import com.azure.core.annotation.Fluent; | ||
|
|
||
| import java.time.Duration; | ||
|
|
||
| /** | ||
| * Represents Header from Amqp message. | ||
| */ | ||
| @Fluent | ||
| public class AmqpMessageHeader { | ||
|
|
||
| private Long deliveryCount; | ||
| private Boolean durable; | ||
| private Boolean firstAcquirer; | ||
| private Short priority; | ||
| private Duration timeToLive; | ||
|
|
||
| AmqpMessageHeader() { | ||
| // This class does not have any public constructors, and is not able to be instantiated using 'new'. | ||
| } | ||
|
|
||
| /** | ||
| * Gets delivery count. | ||
| * | ||
| * @return delivery count. | ||
| */ | ||
| public Long getDeliveryCount() { | ||
| return deliveryCount; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the given {@code deliveryCount} value on {@link AmqpMessageHeader} object. | ||
| * | ||
| * @param deliveryCount to be set. | ||
| * @return updated {@link AmqpMessageHeader} object. | ||
| */ | ||
| public AmqpMessageHeader setDeliveryCount(Long deliveryCount) { | ||
| this.deliveryCount = deliveryCount; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets durable boolean flag. | ||
| * | ||
| * @return The durable. | ||
| */ | ||
| public Boolean getDurable() { | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| return this.durable; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the given {@code durable} value on {@link AmqpMessageHeader} object. | ||
| * | ||
| * @param durable to set on {@link AmqpMessageHeader}. | ||
| * @return updated {@link AmqpMessageHeader} object. | ||
| */ | ||
| public AmqpMessageHeader setDurable(Boolean durable) { | ||
| this.durable = durable; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets boolean flag for {@code firstAcquirer} | ||
| * | ||
| * @return The {@code firstAcquirer}. | ||
| */ | ||
| public Boolean getFirstAcquirer() { | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| return this.firstAcquirer; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the given {@code firstAcquirer} value on {@link AmqpMessageHeader} object. | ||
| * | ||
| * @param firstAcquirer to set on {@link AmqpMessageHeader}. | ||
| * @return updated {@link AmqpMessageHeader} object. | ||
| */ | ||
| public AmqpMessageHeader setFirstAcquirer(Boolean firstAcquirer) { | ||
| this.firstAcquirer = firstAcquirer; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the priority on {@code amqpMessage}. | ||
| * @return the priority. | ||
| */ | ||
| public Short getPriority() { | ||
| return this.priority; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the given {@code priority} value on {@link AmqpMessageHeader} object. | ||
| * | ||
| * @param priority to set on {@link AmqpMessageHeader}. | ||
| * @return updated {@link AmqpMessageHeader} object. | ||
| */ | ||
| public AmqpMessageHeader setPriority(short priority) { | ||
|
hemanttanwar marked this conversation as resolved.
Outdated
|
||
| this.priority = priority; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Gets {@code timeToLive}. | ||
| * @return {@code timeToLive}. | ||
| */ | ||
| public Duration getTimeToLive() { | ||
| return this.timeToLive; | ||
| } | ||
|
|
||
| /** | ||
| * Sets the given {@code timeToLive} value on {@link AmqpMessageHeader} object. | ||
| * | ||
| * @param timeToLive to set on {@link AmqpMessageHeader}. | ||
| * @return updated {@link AmqpMessageHeader} object. | ||
| */ | ||
| public AmqpMessageHeader setTimeToLive(Duration timeToLive) { | ||
| this.timeToLive = timeToLive; | ||
| return this; | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.