com.amazonaws.services.mq.AmazonMQAsyncClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aws-java-sdk-mq Show documentation
Show all versions of aws-java-sdk-mq Show documentation
The AWS Java SDK for AmazonMQ module holds the client classes that are used for communicating with AmazonMQ Service
/*
* Copyright 2019-2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.amazonaws.services.mq;
import javax.annotation.Generated;
import com.amazonaws.services.mq.model.*;
import com.amazonaws.client.AwsAsyncClientParams;
import com.amazonaws.annotation.ThreadSafe;
import java.util.concurrent.ExecutorService;
/**
* Client for accessing AmazonMQ asynchronously. Each asynchronous method will return a Java Future object representing
* the asynchronous operation; overloads which accept an {@code AsyncHandler} can be used to receive notification when
* an asynchronous operation completes.
*
*
* Amazon MQ is a managed message broker service for Apache ActiveMQ and RabbitMQ that makes it easy to set up and
* operate message brokers in the cloud. A message broker allows software applications and components to communicate
* using various programming languages, operating systems, and formal messaging protocols.
*
*/
@ThreadSafe
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class AmazonMQAsyncClient extends AmazonMQClient implements AmazonMQAsync {
private static final int DEFAULT_THREAD_POOL_SIZE = 50;
private final java.util.concurrent.ExecutorService executorService;
public static AmazonMQAsyncClientBuilder asyncBuilder() {
return AmazonMQAsyncClientBuilder.standard();
}
/**
* Constructs a new asynchronous client to invoke service methods on AmazonMQ using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
*/
AmazonMQAsyncClient(AwsAsyncClientParams asyncClientParams) {
this(asyncClientParams, false);
}
/**
* Constructs a new asynchronous client to invoke service methods on AmazonMQ using the specified parameters.
*
* @param asyncClientParams
* Object providing client parameters.
* @param endpointDiscoveryEnabled
* true will enable endpoint discovery if the service supports it.
*/
AmazonMQAsyncClient(AwsAsyncClientParams asyncClientParams, boolean endpointDiscoveryEnabled) {
super(asyncClientParams, endpointDiscoveryEnabled);
this.executorService = asyncClientParams.getExecutor();
}
/**
* Returns the executor service used by this client to execute async requests.
*
* @return The executor service used by this client to execute async requests.
*/
public ExecutorService getExecutorService() {
return executorService;
}
@Override
public java.util.concurrent.Future createBrokerAsync(CreateBrokerRequest request) {
return createBrokerAsync(request, null);
}
@Override
public java.util.concurrent.Future createBrokerAsync(final CreateBrokerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateBrokerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateBrokerResult call() throws Exception {
CreateBrokerResult result = null;
try {
result = executeCreateBroker(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future createConfigurationAsync(CreateConfigurationRequest request) {
return createConfigurationAsync(request, null);
}
@Override
public java.util.concurrent.Future createConfigurationAsync(final CreateConfigurationRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateConfigurationRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateConfigurationResult call() throws Exception {
CreateConfigurationResult result = null;
try {
result = executeCreateConfiguration(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future createTagsAsync(CreateTagsRequest request) {
return createTagsAsync(request, null);
}
@Override
public java.util.concurrent.Future createTagsAsync(final CreateTagsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateTagsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateTagsResult call() throws Exception {
CreateTagsResult result = null;
try {
result = executeCreateTags(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future createUserAsync(CreateUserRequest request) {
return createUserAsync(request, null);
}
@Override
public java.util.concurrent.Future createUserAsync(final CreateUserRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final CreateUserRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public CreateUserResult call() throws Exception {
CreateUserResult result = null;
try {
result = executeCreateUser(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deleteBrokerAsync(DeleteBrokerRequest request) {
return deleteBrokerAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteBrokerAsync(final DeleteBrokerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteBrokerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteBrokerResult call() throws Exception {
DeleteBrokerResult result = null;
try {
result = executeDeleteBroker(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deleteTagsAsync(DeleteTagsRequest request) {
return deleteTagsAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteTagsAsync(final DeleteTagsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteTagsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteTagsResult call() throws Exception {
DeleteTagsResult result = null;
try {
result = executeDeleteTags(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future deleteUserAsync(DeleteUserRequest request) {
return deleteUserAsync(request, null);
}
@Override
public java.util.concurrent.Future deleteUserAsync(final DeleteUserRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DeleteUserRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DeleteUserResult call() throws Exception {
DeleteUserResult result = null;
try {
result = executeDeleteUser(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeBrokerAsync(DescribeBrokerRequest request) {
return describeBrokerAsync(request, null);
}
@Override
public java.util.concurrent.Future describeBrokerAsync(final DescribeBrokerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeBrokerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeBrokerResult call() throws Exception {
DescribeBrokerResult result = null;
try {
result = executeDescribeBroker(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeBrokerEngineTypesAsync(DescribeBrokerEngineTypesRequest request) {
return describeBrokerEngineTypesAsync(request, null);
}
@Override
public java.util.concurrent.Future describeBrokerEngineTypesAsync(final DescribeBrokerEngineTypesRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeBrokerEngineTypesRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeBrokerEngineTypesResult call() throws Exception {
DescribeBrokerEngineTypesResult result = null;
try {
result = executeDescribeBrokerEngineTypes(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeBrokerInstanceOptionsAsync(DescribeBrokerInstanceOptionsRequest request) {
return describeBrokerInstanceOptionsAsync(request, null);
}
@Override
public java.util.concurrent.Future describeBrokerInstanceOptionsAsync(
final DescribeBrokerInstanceOptionsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeBrokerInstanceOptionsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeBrokerInstanceOptionsResult call() throws Exception {
DescribeBrokerInstanceOptionsResult result = null;
try {
result = executeDescribeBrokerInstanceOptions(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeConfigurationAsync(DescribeConfigurationRequest request) {
return describeConfigurationAsync(request, null);
}
@Override
public java.util.concurrent.Future describeConfigurationAsync(final DescribeConfigurationRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeConfigurationRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeConfigurationResult call() throws Exception {
DescribeConfigurationResult result = null;
try {
result = executeDescribeConfiguration(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeConfigurationRevisionAsync(DescribeConfigurationRevisionRequest request) {
return describeConfigurationRevisionAsync(request, null);
}
@Override
public java.util.concurrent.Future describeConfigurationRevisionAsync(
final DescribeConfigurationRevisionRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeConfigurationRevisionRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeConfigurationRevisionResult call() throws Exception {
DescribeConfigurationRevisionResult result = null;
try {
result = executeDescribeConfigurationRevision(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future describeUserAsync(DescribeUserRequest request) {
return describeUserAsync(request, null);
}
@Override
public java.util.concurrent.Future describeUserAsync(final DescribeUserRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final DescribeUserRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public DescribeUserResult call() throws Exception {
DescribeUserResult result = null;
try {
result = executeDescribeUser(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listBrokersAsync(ListBrokersRequest request) {
return listBrokersAsync(request, null);
}
@Override
public java.util.concurrent.Future listBrokersAsync(final ListBrokersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListBrokersRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListBrokersResult call() throws Exception {
ListBrokersResult result = null;
try {
result = executeListBrokers(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listConfigurationRevisionsAsync(ListConfigurationRevisionsRequest request) {
return listConfigurationRevisionsAsync(request, null);
}
@Override
public java.util.concurrent.Future listConfigurationRevisionsAsync(final ListConfigurationRevisionsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListConfigurationRevisionsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListConfigurationRevisionsResult call() throws Exception {
ListConfigurationRevisionsResult result = null;
try {
result = executeListConfigurationRevisions(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listConfigurationsAsync(ListConfigurationsRequest request) {
return listConfigurationsAsync(request, null);
}
@Override
public java.util.concurrent.Future listConfigurationsAsync(final ListConfigurationsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListConfigurationsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListConfigurationsResult call() throws Exception {
ListConfigurationsResult result = null;
try {
result = executeListConfigurations(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listTagsAsync(ListTagsRequest request) {
return listTagsAsync(request, null);
}
@Override
public java.util.concurrent.Future listTagsAsync(final ListTagsRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListTagsRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListTagsResult call() throws Exception {
ListTagsResult result = null;
try {
result = executeListTags(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future listUsersAsync(ListUsersRequest request) {
return listUsersAsync(request, null);
}
@Override
public java.util.concurrent.Future listUsersAsync(final ListUsersRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final ListUsersRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public ListUsersResult call() throws Exception {
ListUsersResult result = null;
try {
result = executeListUsers(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future promoteAsync(PromoteRequest request) {
return promoteAsync(request, null);
}
@Override
public java.util.concurrent.Future promoteAsync(final PromoteRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final PromoteRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public PromoteResult call() throws Exception {
PromoteResult result = null;
try {
result = executePromote(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future rebootBrokerAsync(RebootBrokerRequest request) {
return rebootBrokerAsync(request, null);
}
@Override
public java.util.concurrent.Future rebootBrokerAsync(final RebootBrokerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final RebootBrokerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public RebootBrokerResult call() throws Exception {
RebootBrokerResult result = null;
try {
result = executeRebootBroker(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future updateBrokerAsync(UpdateBrokerRequest request) {
return updateBrokerAsync(request, null);
}
@Override
public java.util.concurrent.Future updateBrokerAsync(final UpdateBrokerRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateBrokerRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateBrokerResult call() throws Exception {
UpdateBrokerResult result = null;
try {
result = executeUpdateBroker(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future updateConfigurationAsync(UpdateConfigurationRequest request) {
return updateConfigurationAsync(request, null);
}
@Override
public java.util.concurrent.Future updateConfigurationAsync(final UpdateConfigurationRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateConfigurationRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateConfigurationResult call() throws Exception {
UpdateConfigurationResult result = null;
try {
result = executeUpdateConfiguration(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
@Override
public java.util.concurrent.Future updateUserAsync(UpdateUserRequest request) {
return updateUserAsync(request, null);
}
@Override
public java.util.concurrent.Future updateUserAsync(final UpdateUserRequest request,
final com.amazonaws.handlers.AsyncHandler asyncHandler) {
final UpdateUserRequest finalRequest = beforeClientExecution(request);
return executorService.submit(new java.util.concurrent.Callable() {
@Override
public UpdateUserResult call() throws Exception {
UpdateUserResult result = null;
try {
result = executeUpdateUser(finalRequest);
} catch (Exception ex) {
if (asyncHandler != null) {
asyncHandler.onError(ex);
}
throw ex;
}
if (asyncHandler != null) {
asyncHandler.onSuccess(finalRequest, result);
}
return result;
}
});
}
/**
* Shuts down the client, releasing all managed resources. This includes forcibly terminating all pending
* asynchronous service calls. Clients who wish to give pending asynchronous service calls time to complete should
* call {@code getExecutorService().shutdown()} followed by {@code getExecutorService().awaitTermination()} prior to
* calling this method.
*/
@Override
public void shutdown() {
super.shutdown();
executorService.shutdownNow();
}
}