EventGridPublisherClientBuilder Class
- java.
lang. Object - com.
azure. messaging. eventgrid. EventGridPublisherClientBuilder
- com.
Implements
public final class EventGridPublisherClientBuilder
implements TokenCredentialTrait<EventGridPublisherClientBuilder>, AzureKeyCredentialTrait<EventGridPublisherClientBuilder>, AzureSasCredentialTrait<EventGridPublisherClientBuilder>, HttpTrait<EventGridPublisherClientBuilder>, ConfigurationTrait<EventGridPublisherClientBuilder>, EndpointTrait<EventGridPublisherClientBuilder>
A Builder class to create service clients that can publish events to EventGrid. This builder will construct publishers for CloudEvent, EventGridEvent, and custom events. It will do for both sync and async clients.
Sample: Create a EventGridEvent asynchronous publisher client.
// Create a client to send events of EventGridEvent schema
EventGridPublisherAsyncClient<EventGridEvent> eventGridEventPublisherClient = new EventGridPublisherClientBuilder()
.endpoint(System.getenv("AZURE_EVENTGRID_EVENT_ENDPOINT")) // make sure it accepts EventGridEvent
.credential(new AzureKeyCredential(System.getenv("AZURE_EVENTGRID_EVENT_KEY")))
.buildEventGridEventPublisherAsyncClient();
Sample: Create a CloudEvent synchronous client
// Create a client to send events of CloudEvent schema (com.azure.core.models.CloudEvent)
EventGridPublisherClient<CloudEvent> cloudEventPublisherClient = new EventGridPublisherClientBuilder()
.endpoint(System.getenv("AZURE_EVENTGRID_CLOUDEVENT_ENDPOINT")) // make sure it accepts CloudEvent
.credential(new AzureKeyCredential(System.getenv("AZURE_EVENTGRID_CLOUDEVENT_KEY")))
.buildCloudEventPublisherClient();
Sample: Create a custom event asynchronous client
// Create a client to send events of custom event
EventGridPublisherAsyncClient<BinaryData> customEventPublisherClient = new EventGridPublisherClientBuilder()
.endpoint(System.getenv("AZURE_CUSTOM_EVENT_ENDPOINT")) // make sure it accepts custom events
.credential(new AzureKeyCredential(System.getenv("AZURE_CUSTOM_EVENT_KEY")))
.buildCustomEventPublisherAsyncClient();
Constructor Summary
| Constructor | Description |
|---|---|
| EventGridPublisherClientBuilder() |
Construct a new instance with default building settings. |
Method Summary
Methods inherited from java.lang.Object
Constructor Details
EventGridPublisherClientBuilder
public EventGridPublisherClientBuilder()
Construct a new instance with default building settings. The endpoint and one credential method must be set in order for the client to be built.
Method Details
addPolicy
public EventGridPublisherClientBuilder addPolicy(HttpPipelinePolicy httpPipelinePolicy)
Parameters:
buildCloudEventPublisherAsyncClient
public EventGridPublisherAsyncClient<CloudEvent> buildCloudEventPublisherAsyncClient()
Build a CloudEvent publisher client with asynchronous publishing methods and the current settings. An endpoint must be set, and either a pipeline with correct authentication must be set, or a credential must be set in the form of an AzureSasCredential or a AzureKeyCredential at the respective methods. All other settings have defaults and are optional.
Returns:
buildCloudEventPublisherClient
public EventGridPublisherClient<CloudEvent> buildCloudEventPublisherClient()
Build a CloudEvent publisher client with synchronous publishing methods and the current settings. Endpoint and a credential must be set (either keyCredential or sharedAccessSignatureCredential), all other settings have defaults and/or are optional.
Returns:
buildCustomEventPublisherAsyncClient
public EventGridPublisherAsyncClient<BinaryData> buildCustomEventPublisherAsyncClient()
Build a custom event publisher client with asynchronous publishing methods and the current settings. An endpoint must be set, and either a pipeline with correct authentication must be set, or a credential must be set in the form of an AzureSasCredential or a AzureKeyCredential at the respective methods. All other settings have defaults and are optional.
Returns:
buildCustomEventPublisherClient
public EventGridPublisherClient<BinaryData> buildCustomEventPublisherClient()
Build a custom event publisher client with synchronous publishing methods and the current settings. Endpoint and a credential must be set (either keyCredential or sharedAccessSignatureCredential), all other settings have defaults and/or are optional.
Returns:
buildEventGridEventPublisherAsyncClient
public EventGridPublisherAsyncClient<EventGridEvent> buildEventGridEventPublisherAsyncClient()
Build an EventGridEvent publisher client with asynchronous publishing methods and the current settings. An endpoint must be set, and either a pipeline with correct authentication must be set, or a credential must be set in the form of an AzureSasCredential or a AzureKeyCredential at the respective methods. All other settings have defaults and are optional.
Returns:
buildEventGridEventPublisherClient
public EventGridPublisherClient<EventGridEvent> buildEventGridEventPublisherClient()
Build an EventGridEvent publisher client with synchronous publishing methods and the current settings. Endpoint and a credential must be set (either keyCredential or sharedAccessSignatureCredential), all other settings have defaults and/or are optional.
Returns:
clientOptions
public EventGridPublisherClientBuilder clientOptions(ClientOptions clientOptions)
Parameters:
configuration
public EventGridPublisherClientBuilder configuration(Configuration configuration)
Parameters:
credential
public EventGridPublisherClientBuilder credential(AzureKeyCredential credential)
Parameters:
credential
public EventGridPublisherClientBuilder credential(AzureSasCredential credential)
Parameters:
credential
public EventGridPublisherClientBuilder credential(TokenCredential credential)
Parameters:
endpoint
public EventGridPublisherClientBuilder endpoint(String endpoint)
Set the domain or topic endpoint. This is the address to publish events to. It must be the full url of the endpoint instead of just the hostname.
Parameters:
Returns:
httpClient
public EventGridPublisherClientBuilder httpClient(HttpClient httpClient)
Parameters:
httpLogOptions
public EventGridPublisherClientBuilder httpLogOptions(HttpLogOptions httpLogOptions)
Parameters:
pipeline
public EventGridPublisherClientBuilder pipeline(HttpPipeline httpPipeline)
Parameters:
retryOptions
public EventGridPublisherClientBuilder retryOptions(RetryOptions retryOptions)
Parameters:
retryPolicy
public EventGridPublisherClientBuilder retryPolicy(RetryPolicy retryPolicy)
Add a custom retry policy to the pipeline. The default is RetryPolicy#RetryPolicy(). Setting this is mutually exclusive with using retryOptions(RetryOptions retryOptions).
Parameters:
Returns:
serviceVersion
public EventGridPublisherClientBuilder serviceVersion(EventGridServiceVersion serviceVersion)
Set the service version to use for requests to the event grid service. See EventGridServiceVersion for more information about possible service versions.
Parameters:
Returns: