Skip to content

Commit 2bf7163

Browse files
authored
Amqp Message Update - API Change (Azure#17464)
1. New Type AmqpMessageId ( Based on discussion from Clemens, dotnet had) 2. New Type AmqpAddress ( Based on discussion from Clemens, dotnet had) 3. Return type change in AmqpMessageProperties for above two new types. 3. Following changes are to keep consistency with dotnet and common prefix -> AmqpMessage A. Renamed AmqpDataBody to AmqpMessageBody (to be same name as in dotnet) B. Renamed AmqpBodyType to AmqpMessageBodyType (Same name in dotnet) 4. Added AmqpMessageBody .getFirstData () Based on team review 5. Returning IterableStream in AmqpMessageBody .getData () Based on team review 6. Removed Copy constructor AmqpAnnotatedMessage (matching with dotnet) and because it is servicebus specific . So moving this logic into servicebus
1 parent b31839d commit 2bf7163

File tree

24 files changed

+846
-381
lines changed

24 files changed

+846
-381
lines changed

eng/code-quality-reports/src/main/resources/revapi/revapi.json

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,92 @@
269269
"code": "java.annotation.added",
270270
"new": "class com.azure.storage.blob.models.PageList",
271271
"justification": "Annotation required to resolve deserialization bug."
272+
},{
273+
"code": "java.method.returnTypeChanged",
274+
"old": "method com.azure.core.util.IterableStream<byte[]> com.azure.core.amqp.models.AmqpDataBody::getData()",
275+
"new": "method java.util.List<byte[]> com.azure.core.amqp.models.AmqpDataBody::getData()",
276+
"justification": "Updated "
277+
},
278+
{
279+
"code": "java.class.removed",
280+
"old": "class com.azure.core.amqp.models.AmqpDataBody",
281+
"justification": "Renamed as AmqpMessageBody."
282+
},
283+
{
284+
"code": "java.class.kindChanged",
285+
"old": "interface com.azure.core.amqp.models.AmqpMessageBody",
286+
"new": "class com.azure.core.amqp.models.AmqpMessageBody",
287+
"justification": "AmqpMessageBody is class representing all the new AMQP data types."
288+
},
289+
{
290+
"code": "java.class.nowFinal",
291+
"old": "interface com.azure.core.amqp.models.AmqpMessageBody",
292+
"new": "class com.azure.core.amqp.models.AmqpMessageBody",
293+
"justification": "Made it final."
294+
},
295+
{
296+
"code": "java.class.removed",
297+
"old": "enum com.azure.core.amqp.models.AmqpBodyType",
298+
"justification": "Because It is renamed to AmqpMessageBodyType"
299+
},
300+
{
301+
"code": "java.method.returnTypeChanged",
302+
"old": "method com.azure.core.amqp.models.AmqpBodyType com.azure.core.amqp.models.AmqpMessageBody::getBodyType()",
303+
"new": "method com.azure.core.amqp.models.AmqpMessageBodyType com.azure.core.amqp.models.AmqpMessageBody::getBodyType()",
304+
"justification": "Renamed to match AmqpMessage prefix."
305+
},
306+
{
307+
"code": "java.method.returnTypeChanged",
308+
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getCorrelationId()",
309+
"new": "method com.azure.core.amqp.models.AmqpMessageId com.azure.core.amqp.models.AmqpMessageProperties::getCorrelationId()",
310+
"justification": "New return type AmqpMessageId."
311+
},
312+
{
313+
"code": "java.method.returnTypeChanged",
314+
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getMessageId()",
315+
"new": "method com.azure.core.amqp.models.AmqpMessageId com.azure.core.amqp.models.AmqpMessageProperties::getMessageId()",
316+
"justification": "New return type."
317+
},
318+
{
319+
"code": "java.method.returnTypeChanged",
320+
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getReplyTo()",
321+
"new": "method com.azure.core.amqp.models.AmqpAddress com.azure.core.amqp.models.AmqpMessageProperties::getReplyTo()",
322+
"justification": "New return type."
323+
},
324+
{
325+
"code": "java.method.returnTypeChanged",
326+
"old": "method java.lang.String com.azure.core.amqp.models.AmqpMessageProperties::getTo()",
327+
"new": "method com.azure.core.amqp.models.AmqpAddress com.azure.core.amqp.models.AmqpMessageProperties::getTo()",
328+
"justification": "New return type."
329+
},
330+
{
331+
"code": "java.method.parameterTypeChanged",
332+
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setCorrelationId(===java.lang.String===)",
333+
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setCorrelationId(===com.azure.core.amqp.models.AmqpMessageId===)",
334+
"justification": "Introduced new type AmqpMessageId."
335+
},
336+
{
337+
"code": "java.method.parameterTypeChanged",
338+
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setMessageId(===java.lang.String===)",
339+
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setMessageId(===com.azure.core.amqp.models.AmqpMessageId===)",
340+
"justification":"Introduced new type AmqpMessageId."
341+
},
342+
{
343+
"code": "java.method.parameterTypeChanged",
344+
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setReplyTo(===java.lang.String===)",
345+
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setReplyTo(===com.azure.core.amqp.models.AmqpAddress===)",
346+
"justification": "Introduced new type AmqpAddress."
347+
},
348+
{
349+
"code": "java.method.parameterTypeChanged",
350+
"old": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setTo(===java.lang.String===)",
351+
"new": "parameter com.azure.core.amqp.models.AmqpMessageProperties com.azure.core.amqp.models.AmqpMessageProperties::setTo(===com.azure.core.amqp.models.AmqpAddress===)",
352+
"justification": "Introduced new type AmqpAddress."
353+
},
354+
{
355+
"code": "java.method.removed",
356+
"old": "method void com.azure.core.amqp.models.AmqpAnnotatedMessage::<init>(com.azure.core.amqp.models.AmqpAnnotatedMessage)",
357+
"justification": "Removed copy constructor, It is not required for Service bus message."
272358
}
273359
]
274360
}

eng/code-quality-reports/src/main/resources/spotbugs/spotbugs-exclude.xml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2297,7 +2297,7 @@
22972297
<Field name="authenticationRecord"/>
22982298
<Bug pattern="SE_TRANSIENT_FIELD_NOT_RESTORED"/>
22992299
</Match>
2300-
2300+
23012301
<!-- These fields are designed to be not written. They are for deserializing. -->
23022302
<Match>
23032303
<Class name="com.azure.identity.implementation.LinuxKeyRingAccessor$GError"/>
@@ -2430,4 +2430,12 @@
24302430
</Or>
24312431
<Bug pattern="NM_CONFUSING" />
24322432
</Match>
2433+
<!-- Returning a new copy of the object is not necessary for queuing system use cases.
2434+
Client do not change content of message once message is created. Array copy would degrade the performance.
2435+
https://github.com/Azure/azure-sdk-for-java/blob/master/sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpMessageBody.java#L115 -->
2436+
<Match>
2437+
<Class name="com.azure.core.amqp.models.AmqpMessageBody"/>
2438+
<Field name="data"/>
2439+
<Bug pattern="EI_EXPOSE_REP"/>
2440+
</Match>
24332441
</FindBugsFilter>

eng/versioning/version_client.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ com.microsoft:microsoft-opentelemetry-exporter-azuremonitor;1.0.0-beta.1;1.0.0-b
177177
# unreleased_<groupId>:<artifactId>;dependency-version
178178
# note: The unreleased dependencies will not be manipulated with the automatic PR creation code.
179179
unreleased_com.azure:azure-core-experimental;1.0.0-beta.9
180+
unreleased_com.azure:azure-core-amqp;1.7.0-beta.3
180181
unreleased_com.azure:azure-messaging-servicebus;7.0.0-beta.7
181182

182183
# Released Beta dependencies: Copy the entry from above, prepend "beta_", remove the current
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
2+
// Licensed under the MIT License.
3+
4+
package com.azure.core.amqp.models;
5+
6+
import java.util.Objects;
7+
8+
/**
9+
* This represents amqp address information. This will be used in populating information like 'To', 'ReplyTo' etc.
10+
*
11+
* <p><strong>Create and retrieve address</strong></p>
12+
* {@codesnippet com.azure.core.amqp.models.AmqpAddress.createAndGet}
13+
*
14+
* @see <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-address-string">
15+
* Address type Format.</a>
16+
*/
17+
public final class AmqpAddress {
18+
19+
private final String address;
20+
21+
/**
22+
* Creates the {@link AmqpAddress} with given {@code address}.
23+
*
24+
* @param address The address to set for this instance.
25+
* @throws NullPointerException if {@code address} is null.
26+
*/
27+
public AmqpAddress(String address) {
28+
this.address = Objects.requireNonNull(address, "'address' cannot be null.");
29+
}
30+
31+
/**
32+
* {@inheritDoc}
33+
*/
34+
@Override
35+
public int hashCode() {
36+
return address.hashCode();
37+
}
38+
39+
/**
40+
* {@inheritDoc}
41+
*/
42+
@Override
43+
public boolean equals(Object other) {
44+
if (other == null) {
45+
return false;
46+
}
47+
48+
if (this.getClass() != other.getClass()) {
49+
return false;
50+
}
51+
52+
if (this == other) {
53+
return true;
54+
}
55+
56+
return Objects.equals(address, other.toString());
57+
}
58+
59+
/**
60+
* {@inheritDoc}
61+
*/
62+
@Override
63+
public String toString() {
64+
return this.address;
65+
}
66+
}

sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpAnnotatedMessage.java

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
/**
1111
* The representation of message as defined by AMQP protocol.
1212
*
13-
* @see <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format">
14-
* Amqp Message Format.</a>
13+
* @see <a href="http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#section-message-format" target="_blank">
14+
* Amqp Message Format</a>
15+
* @see AmqpMessageBody
1516
*/
1617
public final class AmqpAnnotatedMessage {
1718
private final AmqpMessageBody amqpMessageBody;
@@ -31,7 +32,6 @@ public final class AmqpAnnotatedMessage {
3132
*/
3233
public AmqpAnnotatedMessage(AmqpMessageBody body) {
3334
amqpMessageBody = Objects.requireNonNull(body, "'body' cannot be null.");
34-
3535
applicationProperties = new HashMap<>();
3636
deliveryAnnotations = new HashMap<>();
3737
messageAnnotations = new HashMap<>();
@@ -40,24 +40,6 @@ public AmqpAnnotatedMessage(AmqpMessageBody body) {
4040
properties = new AmqpMessageProperties();
4141
}
4242

43-
/**
44-
* Creates instance of {@link AmqpAnnotatedMessage} with given {@link AmqpAnnotatedMessage} instance.
45-
*
46-
* @param message used to create another instance of {@link AmqpAnnotatedMessage}.
47-
*
48-
* @throws NullPointerException if {@code message} or {@link AmqpAnnotatedMessage#getBody() body} is null.
49-
*/
50-
public AmqpAnnotatedMessage(AmqpAnnotatedMessage message) {
51-
Objects.requireNonNull(message, "'message' cannot be null.");
52-
amqpMessageBody = Objects.requireNonNull(message.getBody(), "'message.body' cannot be null.");
53-
applicationProperties = new HashMap<>(message.getApplicationProperties());
54-
deliveryAnnotations = new HashMap<>(message.getDeliveryAnnotations());
55-
messageAnnotations = new HashMap<>(message.getMessageAnnotations());
56-
footer = new HashMap<>(message.getFooter());
57-
header = new AmqpMessageHeader(message.getHeader());
58-
properties = new AmqpMessageProperties(message.getProperties());
59-
}
60-
6143
/**
6244
* Gets the {@link Map} of application properties.
6345
*
@@ -71,6 +53,7 @@ public Map<String, Object> getApplicationProperties() {
7153
* Gets the {@link AmqpMessageBody} of an amqp message.
7254
*
7355
* @return the {@link AmqpMessageBody} object.
56+
* @see AmqpMessageBody
7457
*/
7558
public AmqpMessageBody getBody() {
7659
return amqpMessageBody;

sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpBodyType.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/models/AmqpDataBody.java

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)