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

API ServiceBusErrorSource to represent source of error #16710

Merged
merged 37 commits into from
Oct 30, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b0c8562
Designing ErrorSource options
Oct 22, 2020
b9a83ef
Merge branch 'master' into sb-t2-errorsource-api
Oct 22, 2020
aba06d0
Error source structure.
Oct 22, 2020
28fea7b
Adding error handling for Error source
Oct 26, 2020
d01190a
Adding error handling for Error source
Oct 26, 2020
1ec13b5
Adding error handling for Error source
Oct 26, 2020
bd05bfe
Removed error source from SBM context
Oct 26, 2020
3ce0cb3
Removed unwanted changes
Oct 26, 2020
36106a3
Added test case for sending and receiving the messages.
Oct 27, 2020
1d498ae
merge master into branch
Oct 27, 2020
46f7d2c
Added java doc
Oct 27, 2020
e8d7e1f
updated module info
Oct 27, 2020
cbc6f55
updated code to pass error source in updateDisposition
Oct 27, 2020
32aae8d
module info changes will be in separate PR
Oct 27, 2020
e34a23e
Updated based on review comments.
Oct 28, 2020
d9cd7c0
changes based on review comments
Oct 28, 2020
fce6f55
changes based on review comments
Oct 28, 2020
f84f896
changes based on review comments
Oct 28, 2020
2d004d8
Removed Error source from Sender as dotnet is also not doing it
Oct 28, 2020
5a52a8d
Removed Error source from Sender as dotnet is also not doing it
Oct 28, 2020
578a0dd
added error source for renew lock
Oct 28, 2020
eda86d1
added error source for renew lock
Oct 28, 2020
d24f339
added error source for renew lock
Oct 28, 2020
6e3b5d8
added docs for unit test
Oct 28, 2020
c90eb0e
Renamed Exception
Oct 29, 2020
3286f4c
Renamed Exception
Oct 29, 2020
b61551f
review comments incorporated
Oct 29, 2020
204fd28
Fixing checkstyle
Oct 29, 2020
47bfc0b
Incorporated review comments
Oct 29, 2020
e62f7f5
Review comments
Oct 29, 2020
4c11eb4
Review comments
Oct 29, 2020
59ff15f
Review comments
Oct 29, 2020
5b0d16a
Removed unwanted error source types
Oct 30, 2020
205fbfe
Fix unit test and ErrorSource only for AutoComplete on
Oct 30, 2020
62510bd
Review Comments
Oct 30, 2020
6d79df0
Fix unit test
Oct 30, 2020
0a6fea9
merge conflict resolution
Oct 30, 2020
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
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.messaging.servicebus;

/**
* Represent the scenario in which user was when the error happened.
*/
public enum ServiceBusErrorSource {
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
SEND,
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
RECEIVE,
APPEND,
COMPLETE,
DEFER,
DEAD_LETTER,
PEEK;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class ServiceBusReceivedMessageContext {
private final ServiceBusReceivedMessage message;
private final String sessionId;
private final Throwable error;
private ServiceBusErrorSource errorSource;

/**
* Creates an instance where a message was successfully received.
Expand All @@ -35,6 +36,31 @@ public class ServiceBusReceivedMessageContext {
this.message = null;
}

/**
* Creates an instance where an error occurred such as session-lock-lost.
*
* @param sessionId Session id that the error occurred in.
* @param error AMQP exception that occurred in session.
* @param errorSource the source of the error.
*/
ServiceBusReceivedMessageContext(String sessionId, Throwable error, ServiceBusErrorSource errorSource) {
this(sessionId,error);
this.errorSource = Objects.requireNonNull(errorSource, "'errorSource' cannot be null.");
}

/**
* Creates an instance where an error occurred such as session-lock-lost.
*
* @param error AMQP exception that occurred in session.
* @param errorSource the source of the error.
*/
ServiceBusReceivedMessageContext(Throwable error, ServiceBusErrorSource errorSource) {
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
this.error = Objects.requireNonNull(error, "'error' cannot be null.");
this.errorSource = Objects.requireNonNull(errorSource, "'errorSource' cannot be null.");
this.message = null;
this.sessionId = null;
}

/**
* Gets the session id of the message or that the error occurred in.
*
Expand All @@ -53,6 +79,27 @@ public Throwable getThrowable() {
return error;
}

/**
* Gets the {@link ServiceBusErrorSource} of the error where it occurred.
*
* @return The {@link ServiceBusErrorSource} of the error or message.
*/
public ServiceBusErrorSource getErrorSource() {
return errorSource;
}

/**
* Gets the {@link ServiceBusErrorSource} of the error where it occurred.
*
* @param errorSource {@link ServiceBusErrorSource} where error occurred.
*
* @return The updated {@link ServiceBusReceivedMessageContext} of the error.
*/
ServiceBusReceivedMessageContext setErrorSource(ServiceBusErrorSource errorSource) {
hemanttanwar marked this conversation as resolved.
Show resolved Hide resolved
this.errorSource = errorSource;
return this;
}

/**
* Gets the message received from Service Bus.
*
Expand Down