update properties
This commit is contained in:
Родитель
3ced59c5e6
Коммит
f807de2e30
|
@ -555,32 +555,32 @@ Legacy code:
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
public EventHubInboundChannelAdapter messageChannelAdapter(
|
public EventHubInboundChannelAdapter messageChannelAdapter(
|
||||||
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel, EventHubOperation eventhubOperation) {
|
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel, EventHubOperation eventhubOperation) {
|
||||||
eventhubOperation.setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build());
|
eventhubOperation.setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build());
|
||||||
EventHubInboundChannelAdapter adapter = new EventHubInboundChannelAdapter(EVENTHUB_NAME,
|
EventHubInboundChannelAdapter adapter = new EventHubInboundChannelAdapter(EVENTHUB_NAME,
|
||||||
eventhubOperation, CONSUMER_GROUP);
|
eventhubOperation, CONSUMER_GROUP);
|
||||||
adapter.setOutputChannel(inputChannel);
|
adapter.setOutputChannel(inputChannel);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
Modern code:
|
Modern code:
|
||||||
|
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
public EventHubsInboundChannelAdapter messageChannelAdapter(
|
public EventHubsInboundChannelAdapter messageChannelAdapter(
|
||||||
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel,
|
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel,
|
||||||
EventHubsProcessorContainer processorContainer) {
|
EventHubsProcessorContainer processorContainer) {
|
||||||
CheckpointConfig config = new CheckpointConfig(CheckpointMode.MANUAL);
|
CheckpointConfig config = new CheckpointConfig(CheckpointMode.MANUAL);
|
||||||
|
|
||||||
EventHubsInboundChannelAdapter adapter =
|
EventHubsInboundChannelAdapter adapter =
|
||||||
new EventHubsInboundChannelAdapter(processorContainer, EVENTHUB_NAME,
|
new EventHubsInboundChannelAdapter(processorContainer, EVENTHUB_NAME,
|
||||||
CONSUMER_GROUP, config);
|
CONSUMER_GROUP, config);
|
||||||
adapter.setOutputChannel(inputChannel);
|
adapter.setOutputChannel(inputChannel);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
2.DefaultMessageHandler sample code:
|
2.DefaultMessageHandler sample code:
|
||||||
|
@ -589,24 +589,23 @@ Legacy code:
|
||||||
|
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
||||||
public MessageHandler messageSender(EventHubOperation queueOperation) {
|
public MessageHandler messageSender(EventHubOperation queueOperation) {
|
||||||
DefaultMessageHandler handler = new DefaultMessageHandler(EVENTHUB_NAME, queueOperation);
|
DefaultMessageHandler handler = new DefaultMessageHandler(EVENTHUB_NAME, queueOperation);
|
||||||
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
LOGGER.info("Message was sent successfully.");
|
LOGGER.info("Message was sent successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
LOGGER.error("There was an error sending the message.", ex);
|
LOGGER.error("There was an error sending the message.", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
return handler;
|
||||||
return handler;
|
}
|
||||||
}
|
|
||||||
----
|
----
|
||||||
|
|
||||||
Modern code:
|
Modern code:
|
||||||
|
@ -614,23 +613,23 @@ Modern code:
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
||||||
public MessageHandler messageSender(EventHubsTemplate queueOperation) {
|
public MessageHandler messageSender(EventHubsTemplate queueOperation) {
|
||||||
DefaultMessageHandler handler = new DefaultMessageHandler(EVENTHUB_NAME, queueOperation);
|
DefaultMessageHandler handler = new DefaultMessageHandler(EVENTHUB_NAME, queueOperation);
|
||||||
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
LOGGER.info("Message was sent successfully.");
|
LOGGER.info("Message was sent successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
LOGGER.error("There was an error sending the message.", ex);
|
LOGGER.error("There was an error sending the message.", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
===== Package path changes
|
===== Package path changes
|
||||||
|
@ -672,77 +671,78 @@ Legacy code:
|
||||||
|
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
public ServiceBusQueueInboundChannelAdapter queueMessageChannelAdapter(
|
public ServiceBusQueueInboundChannelAdapter queueMessageChannelAdapter(
|
||||||
@Qualifier("INPUT_CHANNEL_NAME") MessageChannel inputChannel, ServiceBusQueueOperation queueOperation) {
|
@Qualifier("INPUT_CHANNEL_NAME") MessageChannel inputChannel, ServiceBusQueueOperation queueOperation) {
|
||||||
queueOperation.setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build());
|
queueOperation.setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build());
|
||||||
ServiceBusQueueInboundChannelAdapter adapter = new ServiceBusQueueInboundChannelAdapter("QUEUE_NAME",
|
ServiceBusQueueInboundChannelAdapter adapter = new ServiceBusQueueInboundChannelAdapter("QUEUE_NAME",
|
||||||
queueOperation);
|
queueOperation);
|
||||||
adapter.setOutputChannel(inputChannel);
|
adapter.setOutputChannel(inputChannel);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ServiceBusTopicInboundChannelAdapter topicMessageChannelAdapter(
|
public ServiceBusTopicInboundChannelAdapter topicMessageChannelAdapter(
|
||||||
@Qualifier("INPUT_CHANNEL_NAME") MessageChannel inputChannel, ServiceBusTopicOperation topicOperation) {
|
@Qualifier("INPUT_CHANNEL_NAME") MessageChannel inputChannel, ServiceBusTopicOperation topicOperation) {
|
||||||
topicOperation.setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build());
|
topicOperation.setCheckpointConfig(CheckpointConfig.builder().checkpointMode(CheckpointMode.MANUAL).build());
|
||||||
ServiceBusTopicInboundChannelAdapter adapter = new ServiceBusTopicInboundChannelAdapter("TOPIC_NAME",
|
ServiceBusTopicInboundChannelAdapter adapter = new ServiceBusTopicInboundChannelAdapter("TOPIC_NAME",
|
||||||
topicOperation, "SUBSCRIPTION_NAME");
|
topicOperation, "SUBSCRIPTION_NAME");
|
||||||
adapter.setOutputChannel(inputChannel);
|
adapter.setOutputChannel(inputChannel);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ServiceActivator(inputChannel = "OUTPUT_CHANNEL_NAME")
|
@ServiceActivator(inputChannel = "OUTPUT_CHANNEL_NAME")
|
||||||
public MessageHandler queueMessageSender(ServiceBusQueueOperation queueOperation) {
|
public MessageHandler queueMessageSender(ServiceBusQueueOperation queueOperation) {
|
||||||
DefaultMessageHandler handler = new DefaultMessageHandler("QUEUE_NAME", queueOperation);
|
DefaultMessageHandler handler = new DefaultMessageHandler("QUEUE_NAME", queueOperation);
|
||||||
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
LOGGER.info("Message was sent successfully.");
|
LOGGER.info("Message was sent successfully.");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
LOGGER.info("There was an error sending the message.");
|
LOGGER.info("There was an error sending the message.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
* Modern code:
|
* Modern code:
|
||||||
|
|
||||||
|
====
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
public ServiceBusInboundChannelAdapter queueMessageChannelAdapter(
|
public ServiceBusInboundChannelAdapter queueMessageChannelAdapter(
|
||||||
@Qualifier("INPUT_CHANNEL_NAME") MessageChannel inputChannel, ServiceBusProcessorContainer processorContainer) {
|
@Qualifier("INPUT_CHANNEL_NAME") MessageChannel inputChannel, ServiceBusProcessorContainer processorContainer) {
|
||||||
ServiceBusInboundChannelAdapter adapter = new ServiceBusInboundChannelAdapter(processorContainer, "QUEUE_NAME",
|
ServiceBusInboundChannelAdapter adapter = new ServiceBusInboundChannelAdapter(processorContainer, "QUEUE_NAME",
|
||||||
new CheckpointConfig(CheckpointMode.MANUAL));
|
new CheckpointConfig(CheckpointMode.MANUAL));
|
||||||
adapter.setOutputChannel(inputChannel);
|
adapter.setOutputChannel(inputChannel);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ServiceActivator(inputChannel = "OUTPUT_CHANNEL_NAME")
|
@ServiceActivator(inputChannel = "OUTPUT_CHANNEL_NAME")
|
||||||
public MessageHandler queueMessageSender(ServiceBusTemplate serviceBusTemplate) {
|
public MessageHandler queueMessageSender(ServiceBusTemplate serviceBusTemplate) {
|
||||||
serviceBusTemplate.setDefaultEntityType(ServiceBusEntityType.QUEUE);
|
serviceBusTemplate.setDefaultEntityType(ServiceBusEntityType.QUEUE);
|
||||||
DefaultMessageHandler handler = new DefaultMessageHandler("QUEUE_NAME", serviceBusTemplate);
|
DefaultMessageHandler handler = new DefaultMessageHandler("QUEUE_NAME", serviceBusTemplate);
|
||||||
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
LOGGER.info("Message was sent successfully for {}.", "QUEUE_NAME");
|
LOGGER.info("Message was sent successfully for {}.", "QUEUE_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
LOGGER.info("There was an error sending the message.");
|
LOGGER.info("There was an error sending the message.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return handler;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return handler;
|
||||||
|
}
|
||||||
----
|
----
|
||||||
|
====
|
||||||
|
|
||||||
==== spring-cloud-azure-starter-integration-storage-queue
|
==== spring-cloud-azure-starter-integration-storage-queue
|
||||||
|
|
||||||
|
|
|
@ -28,14 +28,20 @@ If you want to retrieve the connection string using Azure Resource Manager, plea
|
||||||
=== Configuration
|
=== Configuration
|
||||||
|
|
||||||
Below properties could be configured when using Kafka support:
|
Below properties could be configured when using Kafka support:
|
||||||
|
[cols="2*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Properties |Description
|
|Properties
|
||||||
|*spring.cloud.azure.eventhubs*.kafka.enabled |Whether to enable the Azure Event Hubs Kafka support, defult to true.
|
|Description
|
||||||
|*spring.cloud.azure.eventhubs*.connection-string |Azure Event Hubs connection string. Should be provided when want to provide the connection string directly.
|
|*spring.cloud.azure.eventhubs*.kafka.enabled
|
||||||
|*spring.cloud.azure.eventhubs*.namespace |Azure Event Hubs namespace. Should be provided when want to retrieve the connection information through Azure Resource Manager.
|
|Whether to enable the Azure Event Hubs Kafka support, defult to true.
|
||||||
|*spring.cloud.azure.eventhubs*.resource.resource-group |The resource group of Azure Event Hubs namespace. Should be provided when want to retrieve the connection information through Azure Resource Manager.
|
|*spring.cloud.azure.eventhubs*.connection-string
|
||||||
|*spring.cloud.azure*.profile.subscription-id| The subscription id. Should be provided when want to retrieve the connection information through Azure Resource Manager.|
|
|Azure Event Hubs connection string. Should be provided when want to provide the connection string directly.
|
||||||
|
|*spring.cloud.azure.eventhubs*.namespace
|
||||||
|
|Azure Event Hubs namespace. Should be provided when want to retrieve the connection information through Azure Resource Manager.
|
||||||
|
|*spring.cloud.azure.eventhubs*.resource.resource-group
|
||||||
|
|The resource group of Azure Event Hubs namespace. Should be provided when want to retrieve the connection information through Azure Resource Manager.
|
||||||
|
|*spring.cloud.azure*.profile.subscription-id
|
||||||
|
| The subscription id. Should be provided when want to retrieve the connection information through Azure Resource Manager.
|
||||||
|===
|
|===
|
||||||
|
|
||||||
NOTE: Authentication information is also required for authenticating for Azure Resource Manager. The credential related configurations of Resource Manager should be configured under prefix `spring.cloud.azure`. Please refer to link:index.html#authentication[Authentication] for more details.
|
NOTE: Authentication information is also required for authenticating for Azure Resource Manager. The credential related configurations of Resource Manager should be configured under prefix `spring.cloud.azure`. Please refer to link:index.html#authentication[Authentication] for more details.
|
||||||
|
|
|
@ -21,7 +21,7 @@ Adding below dependencies if you want to use the Spring Cloud Azure Redis suppor
|
||||||
=== Configuration
|
=== Configuration
|
||||||
|
|
||||||
Below properties could be configured when using Redis support:
|
Below properties could be configured when using Redis support:
|
||||||
|
[cols="4*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Properties |Description |Default Value | Required
|
|Properties |Description |Default Value | Required
|
||||||
|*spring.cloud.azure.redis*.enabled |Azure Cache for Redis instance name.|true | No
|
|*spring.cloud.azure.redis*.enabled |Azure Cache for Redis instance name.|true | No
|
||||||
|
|
|
@ -28,7 +28,7 @@ Connect to Azure Storage using Spring Resource abstraction and Azure Storage lib
|
||||||
=== Configuration
|
=== Configuration
|
||||||
|
|
||||||
This `spring-cloud-azure-starter-storage-blob` provides the following properties:
|
This `spring-cloud-azure-starter-storage-blob` provides the following properties:
|
||||||
|
[cols="3*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Name | Default | Description
|
|Name | Default | Description
|
||||||
|spring.cloud.azure.storage.blob.enabled | `true` | Whether an Azure Blob Storage Service is enabled
|
|spring.cloud.azure.storage.blob.enabled | `true` | Whether an Azure Blob Storage Service is enabled
|
||||||
|
@ -38,7 +38,7 @@ This `spring-cloud-azure-starter-storage-blob` provides the following properties
|
||||||
|===
|
|===
|
||||||
|
|
||||||
This `spring-cloud-azure-starter-storage-file-share` provides the following properties:
|
This `spring-cloud-azure-starter-storage-file-share` provides the following properties:
|
||||||
|
[cols="3*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Name | Default | Description
|
|Name | Default | Description
|
||||||
|spring.cloud.azure.storage.fileshare.enabled | `true` | Whether Azure File Storage Service is enabled
|
|spring.cloud.azure.storage.fileshare.enabled | `true` | Whether Azure File Storage Service is enabled
|
||||||
|
@ -59,13 +59,13 @@ spring:
|
||||||
azure:
|
azure:
|
||||||
storage:
|
storage:
|
||||||
blob:
|
blob:
|
||||||
account-name: ${STORAGE-ACCOUNT-NAME}
|
account-name: ${STORAGE_ACCOUNT_NAME}
|
||||||
account-key: ${STORAGE-ACCOUNT-PRIVATE-KEY}
|
account-key: ${STORAGE_ACCOUNT_PRIVATE_KEY}
|
||||||
endpoint: ${STORAGE-BLOB-ENDPOINT}
|
endpoint: ${STORAGE_BLOB_ENDPOINT}
|
||||||
fileshare:
|
fileshare:
|
||||||
account-name: ${STORAGE-ACCOUNT-NAME}
|
account-name: ${STORAGE_ACCOUNT_NAME}
|
||||||
account-key: ${STORAGE-ACCOUNT-PRIVATE-KEY}
|
account-key: ${STORAGE_ACCOUNT_PRIVATE_KEY}
|
||||||
endpoint: ${STORAGE-FILESHARE-ENDPOINT}
|
endpoint: ${STORAGE_FILESHARE_ENDPOINT}
|
||||||
----
|
----
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,9 @@ Construct `TokenCredential` by using various credential information, and then co
|
||||||
=== Configuration
|
=== Configuration
|
||||||
|
|
||||||
This Spring Cloud Azure Resource Manager provides the following properties:
|
This Spring Cloud Azure Resource Manager provides the following properties:
|
||||||
|
[cols="2*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Properties |Description
|
|Properties |Description
|
||||||
|
|
||||||
|*spring.cloud.azure.resource-manager*.enabled |Whether the Resource Manager is enabled. Default is true.
|
|*spring.cloud.azure.resource-manager*.enabled |Whether the Resource Manager is enabled. Default is true.
|
||||||
|*spring.cloud.azure.credential*.client-certificate-password |Password of the certificate file.
|
|*spring.cloud.azure.credential*.client-certificate-password |Password of the certificate file.
|
||||||
|*spring.cloud.azure.credential*.client-certificate-path |Path of a PEM certificate file to use when performing service principal authentication with Azure.
|
|*spring.cloud.azure.credential*.client-certificate-path |Path of a PEM certificate file to use when performing service principal authentication with Azure.
|
||||||
|
|
|
@ -17,7 +17,7 @@ spring-cloud-azure-starter-keyvault-secrets adds Azure Key Vault as one of the S
|
||||||
=== Configuration
|
=== Configuration
|
||||||
|
|
||||||
Configurable items
|
Configurable items
|
||||||
|
[cols="2*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Properties |Description
|
|Properties |Description
|
||||||
| spring.cloud.azure.keyvault.secret.endpoint | Key Vault uri
|
| spring.cloud.azure.keyvault.secret.endpoint | Key Vault uri
|
||||||
|
@ -30,7 +30,6 @@ Configurable items
|
||||||
| spring.cloud.azure.keyvault.secret.property-sources[].case-sensitive | Whether the secret name is case-sensitive
|
| spring.cloud.azure.keyvault.secret.property-sources[].case-sensitive | Whether the secret name is case-sensitive
|
||||||
| spring.cloud.azure.keyvault.secret.property-sources[].secret-keys | The supported secret names. If not configured, it will retrieve all secret names.
|
| spring.cloud.azure.keyvault.secret.property-sources[].secret-keys | The supported secret names. If not configured, it will retrieve all secret names.
|
||||||
| spring.cloud.azure.keyvault.secret.property-sources[].refresh-interval | Refresh interval
|
| spring.cloud.azure.keyvault.secret.property-sources[].refresh-interval | Refresh interval
|
||||||
|
|
|
||||||
|===
|
|===
|
||||||
|
|
||||||
=== Basic Usage
|
=== Basic Usage
|
||||||
|
@ -52,7 +51,7 @@ spring:
|
||||||
keyvault:
|
keyvault:
|
||||||
secret:
|
secret:
|
||||||
property-source-enabled: true
|
property-source-enabled: true
|
||||||
endpoint: ${KEY_VAULT_ENDPOINT}
|
endpoint: ${AZURE_KEYVAULT_ENDPOINT}
|
||||||
----
|
----
|
||||||
|
|
||||||
===== Java code
|
===== Java code
|
||||||
|
|
|
@ -182,12 +182,12 @@ To see the list of all Spring Cloud Azure related configuration properties pleas
|
||||||
this channel is open by default, you can handle the error message in this way:
|
this channel is open by default, you can handle the error message in this way:
|
||||||
|
|
||||||
----
|
----
|
||||||
// Replace destination with spring.cloud.stream.bindings.input.destination
|
// Replace destination with spring.cloud.stream.bindings.input.destination
|
||||||
// Replace group with spring.cloud.stream.bindings.input.group
|
// Replace group with spring.cloud.stream.bindings.input.group
|
||||||
@ServiceActivator(inputChannel == "{destination}.{group}.errors")
|
@ServiceActivator(inputChannel == "{destination}.{group}.errors")
|
||||||
public void consumerError(Message<?> message) {
|
public void consumerError(Message<?> message) {
|
||||||
LOGGER.error("Handling customer ERROR: " + message);
|
LOGGER.error("Handling customer ERROR: " + message);
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
*_producer error channel_*
|
*_producer error channel_*
|
||||||
|
@ -201,11 +201,11 @@ spring.cloud.stream.default.producer.errorChannelEnabled=true
|
||||||
you can handle the error message in this way:
|
you can handle the error message in this way:
|
||||||
|
|
||||||
----
|
----
|
||||||
// Replace destination with spring.cloud.stream.bindings.output.destination
|
// Replace destination with spring.cloud.stream.bindings.output.destination
|
||||||
@ServiceActivator(inputChannel == "{destination}.errors")
|
@ServiceActivator(inputChannel == "{destination}.errors")
|
||||||
public void producerError(Message<?> message) {
|
public void producerError(Message<?> message) {
|
||||||
LOGGER.error("Handling Producer ERROR: " + message);
|
LOGGER.error("Handling Producer ERROR: " + message);
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
===== Batch Consumer Sample
|
===== Batch Consumer Sample
|
||||||
|
@ -221,8 +221,8 @@ spring:
|
||||||
stream:
|
stream:
|
||||||
bindings:
|
bindings:
|
||||||
consume-in-0:
|
consume-in-0:
|
||||||
destination: {event-hub-name}
|
destination: ${AZURE_EVENTHUB_NAME}
|
||||||
group: [consumer-group-name]
|
group: ${AZURE_EVENTHUB_CONSUMER_GROUP}
|
||||||
consumer:
|
consumer:
|
||||||
batch-mode: true
|
batch-mode: true
|
||||||
eventhubs:
|
eventhubs:
|
||||||
|
@ -242,49 +242,49 @@ For checkpointing mode as BATCH, you can use below code to send messages and con
|
||||||
|
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
public Consumer<List<String>> consume() {
|
public Consumer<List<String>> consume() {
|
||||||
return list -> list.forEach(event -> LOGGER.info("New event received: '{}'",event));
|
return list -> list.forEach(event -> LOGGER.info("New event received: '{}'",event));
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean
|
||||||
public Supplier<Message<String>> supply() {
|
public Supplier<Message<String>> supply() {
|
||||||
return () -> {
|
return () -> {
|
||||||
LOGGER.info("Sending message, sequence " + i);
|
LOGGER.info("Sending message, sequence " + i);
|
||||||
return MessageBuilder.withPayload("\"test"+ i++ +"\"").build();
|
return MessageBuilder.withPayload("\"test"+ i++ +"\"").build();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
For checkpointing mode as MANUAL, you can use below code to send messages and consume/checkpoint in batches.
|
For checkpointing mode as MANUAL, you can use below code to send messages and consume/checkpoint in batches.
|
||||||
|
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
public Consumer<Message<List<String>>> consume() {
|
public Consumer<Message<List<String>>> consume() {
|
||||||
return message -> {
|
return message -> {
|
||||||
for (int i == 0; i < message.getPayload().size(); i++) {
|
for (int i == 0; i < message.getPayload().size(); i++) {
|
||||||
LOGGER.info("New message received: '{}', partition key: {}, sequence number: {}, offset: {}, enqueued time: {}",
|
LOGGER.info("New message received: '{}', partition key: {}, sequence number: {}, offset: {}, enqueued time: {}",
|
||||||
message.getPayload().get(i),
|
message.getPayload().get(i),
|
||||||
((List<Object>) message.getHeaders().get(EventHubsHeaders.PARTITION_KEY)).get(i),
|
((List<Object>) message.getHeaders().get(EventHubsHeaders.PARTITION_KEY)).get(i),
|
||||||
((List<Object>) message.getHeaders().get(EventHubsHeaders.SEQUENCE_NUMBER)).get(i),
|
((List<Object>) message.getHeaders().get(EventHubsHeaders.SEQUENCE_NUMBER)).get(i),
|
||||||
((List<Object>) message.getHeaders().get(EventHubsHeaders.OFFSET)).get(i),
|
((List<Object>) message.getHeaders().get(EventHubsHeaders.OFFSET)).get(i),
|
||||||
((List<Object>) message.getHeaders().get(EventHubsHeaders.ENQUEUED_TIME)).get(i));
|
((List<Object>) message.getHeaders().get(EventHubsHeaders.ENQUEUED_TIME)).get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
Checkpointer checkpointer == (Checkpointer) message.getHeaders().get(CHECKPOINTER);
|
Checkpointer checkpointer == (Checkpointer) message.getHeaders().get(CHECKPOINTER);
|
||||||
checkpointer.success()
|
checkpointer.success()
|
||||||
.doOnSuccess(success -> LOGGER.info("Message '{}' successfully checkpointed", message.getPayload()))
|
.doOnSuccess(success -> LOGGER.info("Message '{}' successfully checkpointed", message.getPayload()))
|
||||||
.doOnError(error -> LOGGER.error("Exception found", error))
|
.doOnError(error -> LOGGER.error("Exception found", error))
|
||||||
.subscribe();
|
.subscribe();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@Bean
|
@Bean
|
||||||
public Supplier<Message<String>> supply() {
|
public Supplier<Message<String>> supply() {
|
||||||
return () -> {
|
return () -> {
|
||||||
LOGGER.info("Sending message, sequence " + i);
|
LOGGER.info("Sending message, sequence " + i);
|
||||||
return MessageBuilder.withPayload("\"test"+ i++ +"\"").build();
|
return MessageBuilder.withPayload("\"test"+ i++ +"\"").build();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Spring Cloud Stream Binder for Azure Service Bus
|
=== Spring Cloud Stream Binder for Azure Service Bus
|
||||||
|
|
|
@ -20,7 +20,7 @@ Connect to Cosmos DB using Spring Data and CosmosDB libraries.
|
||||||
=== Configuration
|
=== Configuration
|
||||||
|
|
||||||
Below are some properties you can configure when using Spring Data CosmosDB Support:
|
Below are some properties you can configure when using Spring Data CosmosDB Support:
|
||||||
|
[cols="3*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Name | Description | Default
|
|Name | Description | Default
|
||||||
|spring.cloud.azure.cosmos.enabled | Whether Azure Cosmos Service is enabled. | `true`
|
|spring.cloud.azure.cosmos.enabled | Whether Azure Cosmos Service is enabled. | `true`
|
||||||
|
@ -49,9 +49,9 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
cosmos:
|
cosmos:
|
||||||
key: ${YOUR_COSMOS_KEY}
|
key: ${AZURE_COSMOS_KEY}
|
||||||
endpoint: ${YOUR_COSMOS_ENDPOINT}
|
endpoint: ${AZURE_COSMOS_ENDPOINT}
|
||||||
database: ${YOUR_COSMOS_DATABASE}
|
database: ${AZURE_COSMOS_DATABASE}
|
||||||
----
|
----
|
||||||
|
|
||||||
=== Samples
|
=== Samples
|
||||||
|
|
|
@ -26,7 +26,13 @@ Provide Spring Integration support for these Azure services: Event Hubs, Service
|
||||||
This starter provides the following 2 parts of configuration options:
|
This starter provides the following 2 parts of configuration options:
|
||||||
|
|
||||||
===== Azure Common Configuration Options
|
===== Azure Common Configuration Options
|
||||||
|
<<<<<<< HEAD
|
||||||
Below properties can also be configured with the default Spring Cloud Azure unified properties by changing the prefix from *spring.cloud.azure.eventhubs.* to *spring.cloud.azure.*.
|
Below properties can also be configured with the default Spring Cloud Azure unified properties by changing the prefix from *spring.cloud.azure.eventhubs.* to *spring.cloud.azure.*.
|
||||||
|
=======
|
||||||
|
Below properties can also be configured with the default Spring Cloud Azure unified properties,
|
||||||
|
of which the prefix is changed from *spring.cloud.azure.eventhubs.* to *spring.cloud.azure.*.
|
||||||
|
[cols="3*", options="header"]
|
||||||
|
>>>>>>> 1ffefa6e (update properties)
|
||||||
|===
|
|===
|
||||||
|Properties | Type |Description
|
|Properties | Type |Description
|
||||||
|
|
||||||
|
@ -68,6 +74,7 @@ Below properties can also be configured with the default Spring Cloud Azure unif
|
||||||
===== Azure Event Hubs Client Configuration Options
|
===== Azure Event Hubs Client Configuration Options
|
||||||
Below options are used to configure Azure Event Hubs SDK Client.
|
Below options are used to configure Azure Event Hubs SDK Client.
|
||||||
|
|
||||||
|
[cols="3*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Properties | Type |Description
|
|Properties | Type |Description
|
||||||
|
|
||||||
|
@ -97,7 +104,7 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
eventhubs:
|
eventhubs:
|
||||||
connection-string: [servicebus-connection-string]
|
connection-string: ${AZURE_SERVICE_BUS_CONNECTION_STRING}
|
||||||
----
|
----
|
||||||
|
|
||||||
* For credentials as MSI, configure below properties in `application.yml`:
|
* For credentials as MSI, configure below properties in `application.yml`:
|
||||||
|
@ -107,17 +114,17 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
credential:
|
credential:
|
||||||
managed-identity-client-id: [managed-identity-client-id]
|
managed-identity-client-id: ${AZURE_CLIENT_ID}
|
||||||
profile:
|
profile:
|
||||||
tenant-id: [tenant-id]
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
# Uncomment below configurations if you want to enable auto creating resources.
|
# Uncomment below configurations if you want to enable auto creating resources.
|
||||||
# subscription-id: [subscription-id]
|
# subscription-id: ${AZURE_SUBSCRIPTION_ID}
|
||||||
# cloud: Azure
|
# cloud: Azure
|
||||||
# resource:
|
# resource:
|
||||||
# region: [region]
|
# region: [region]
|
||||||
|
|
||||||
eventhubs:
|
eventhubs:
|
||||||
namespace: [servicebus-namespace]
|
namespace: ${AZURE_SERVICE_BUS_NAMESPACE}
|
||||||
----
|
----
|
||||||
|
|
||||||
* For credentials as service principal, configure below properties in application.yml:
|
* For credentials as service principal, configure below properties in application.yml:
|
||||||
|
@ -127,59 +134,59 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
credential:
|
credential:
|
||||||
client-id: [client-id]
|
client-id: ${AZURE_CLIENT_ID}
|
||||||
client-secret: [client-secret]
|
client-secret: ${AZURE_CLIENT_SECRET}
|
||||||
profile:
|
profile:
|
||||||
tenant-id: [tenant-id]
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
# Uncomment below configurations if you want to enable auto creating resources.
|
# Uncomment below configurations if you want to enable auto creating resources.
|
||||||
# subscription-id: [subscription-id]
|
# subscription-id: ${AZURE_SUBSCRIPTION_ID}
|
||||||
# cloud: Azure
|
# cloud: Azure
|
||||||
# resource:
|
# resource:
|
||||||
# region: [region]
|
# region: [region]
|
||||||
|
|
||||||
eventhubs:
|
eventhubs:
|
||||||
namespace: [namespace]
|
namespace: ${AZURE_SERVICE_BUS_NAMESPACE}
|
||||||
----
|
----
|
||||||
|
|
||||||
- Step 2. Create `DefaultMessageHandler` with the bean of `EventHubsTemplate` to send messages to Event Hubs.
|
- Step 2. Create `DefaultMessageHandler` with the bean of `EventHubsTemplate` to send messages to Event Hubs.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String OUTPUT_CHANNEL = "output";
|
private static final String OUTPUT_CHANNEL = "output";
|
||||||
private static final String EVENTHUB_NAME = "eh1";
|
private static final String EVENTHUB_NAME = "eh1";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
||||||
public MessageHandler messageSender(EventHubsTemplate queueOperation) {
|
public MessageHandler messageSender(EventHubsTemplate queueOperation) {
|
||||||
DefaultMessageHandler handler = new DefaultMessageHandler(EVENTHUB_NAME, queueOperation);
|
DefaultMessageHandler handler = new DefaultMessageHandler(EVENTHUB_NAME, queueOperation);
|
||||||
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
LOGGER.info("Message was sent successfully.");
|
LOGGER.info("Message was sent successfully.");
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
LOGGER.error("There was an error sending the message.", ex);
|
LOGGER.error("There was an error sending the message.", ex);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
- Step 3. Create a Message gateway binding with the message handler created in the last step via a message channel
|
- Step 3. Create a Message gateway binding with the message handler created in the last step via a message channel
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Autowired
|
@Autowired
|
||||||
EventHubOutboundGateway messagingGateway;
|
EventHubOutboundGateway messagingGateway;
|
||||||
|
|
||||||
@MessagingGateway(defaultRequestChannel = OUTPUT_CHANNEL)
|
@MessagingGateway(defaultRequestChannel = OUTPUT_CHANNEL)
|
||||||
public interface EventHubOutboundGateway {
|
public interface EventHubOutboundGateway {
|
||||||
void send(String text);
|
void send(String text);
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
- Step 4. Send messages using the gateway
|
- Step 4. Send messages using the gateway
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
this.messagingGateway.send(message);
|
this.messagingGateway.send(message);
|
||||||
----
|
----
|
||||||
|
|
||||||
===== Receive messages from Azure Event Hubs
|
===== Receive messages from Azure Event Hubs
|
||||||
|
@ -187,43 +194,43 @@ spring:
|
||||||
- Step 2. Create a bean of message channel as the input channel.
|
- Step 2. Create a bean of message channel as the input channel.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String INPUT_CHANNEL = "input";
|
private static final String INPUT_CHANNEL = "input";
|
||||||
private static final String EVENTHUB_NAME = "eh1";
|
private static final String EVENTHUB_NAME = "eh1";
|
||||||
private static final String CONSUMER_GROUP = "$Default";
|
private static final String CONSUMER_GROUP = "$Default";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MessageChannel input() {
|
public MessageChannel input() {
|
||||||
return new DirectChannel();
|
return new DirectChannel();
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
- Step 3. Create `EventHubsInboundChannelAdapter` with the bean of `EventHubsProcessorContainer` to receive messages to Event Hubs.
|
- Step 3. Create `EventHubsInboundChannelAdapter` with the bean of `EventHubsProcessorContainer` to receive messages to Event Hubs.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Bean
|
@Bean
|
||||||
public EventHubsInboundChannelAdapter messageChannelAdapter(
|
public EventHubsInboundChannelAdapter messageChannelAdapter(
|
||||||
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel,
|
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel,
|
||||||
EventHubsProcessorContainer processorContainer) {
|
EventHubsProcessorContainer processorContainer) {
|
||||||
CheckpointConfig config = new CheckpointConfig(CheckpointMode.MANUAL);
|
CheckpointConfig config = new CheckpointConfig(CheckpointMode.MANUAL);
|
||||||
|
|
||||||
EventHubsInboundChannelAdapter adapter =
|
EventHubsInboundChannelAdapter adapter =
|
||||||
new EventHubsInboundChannelAdapter(processorContainer, EVENTHUB_NAME,
|
new EventHubsInboundChannelAdapter(processorContainer, EVENTHUB_NAME,
|
||||||
CONSUMER_GROUP, config);
|
CONSUMER_GROUP, config);
|
||||||
adapter.setOutputChannel(inputChannel);
|
adapter.setOutputChannel(inputChannel);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
- Step 4. Create a message receiver binding with EventHubsInboundChannelAdapter created in the last step via the message channel we created before.
|
- Step 4. Create a message receiver binding with EventHubsInboundChannelAdapter created in the last step via the message channel we created before.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@ServiceActivator(inputChannel = INPUT_CHANNEL)
|
@ServiceActivator(inputChannel = INPUT_CHANNEL)
|
||||||
public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
|
public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
|
||||||
String message = new String(payload);
|
String message = new String(payload);
|
||||||
LOGGER.info("New message received: '{}'", message);
|
LOGGER.info("New message received: '{}'", message);
|
||||||
checkpointer.success()
|
checkpointer.success()
|
||||||
.doOnSuccess(s -> LOGGER.info("Message '{}' successfully checkpointed", message))
|
.doOnSuccess(s -> LOGGER.info("Message '{}' successfully checkpointed", message))
|
||||||
.doOnError(e -> LOGGER.error("Error found", e))
|
.doOnError(e -> LOGGER.error("Error found", e))
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
==== Samples
|
==== Samples
|
||||||
|
@ -310,7 +317,7 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
servicebus:
|
servicebus:
|
||||||
connection-string: [servicebus-connection-string]
|
connection-string: ${AZURE_SERVICE_BUS_CONNECTION_STRING}
|
||||||
----
|
----
|
||||||
|
|
||||||
- For credentials as MSI, configure below properties in application.yml:
|
- For credentials as MSI, configure below properties in application.yml:
|
||||||
|
@ -320,17 +327,17 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
credential:
|
credential:
|
||||||
managed-identity-client-id: [managed-identity-client-id]
|
managed-identity-client-id: ${AZURE_CLIENT_ID}
|
||||||
profile:
|
profile:
|
||||||
tenant-id: [tenant-id]
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
# Uncomment below configurations if you want to enable auto creating resources.
|
# Uncomment below configurations if you want to enable auto creating resources.
|
||||||
# subscription-id: [subscription-id]
|
# subscription-id: ${AZURE_SUBSCRIPTION_ID}
|
||||||
# cloud: Azure
|
# cloud: Azure
|
||||||
# resource:
|
# resource:
|
||||||
# region: [region]
|
# region: [region]
|
||||||
|
|
||||||
servicebus:
|
servicebus:
|
||||||
namespace: [servicebus-namespace]
|
namespace: ${AZURE_SERVICE_BUS_NAMESPACE}
|
||||||
----
|
----
|
||||||
|
|
||||||
- For credentials as service principal, configure below properties in application.yml:
|
- For credentials as service principal, configure below properties in application.yml:
|
||||||
|
@ -340,64 +347,63 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
credential:
|
credential:
|
||||||
client-id: [client-id]
|
client-id: ${AZURE_CLIENT_ID}
|
||||||
client-secret: [client-secret]
|
client-secret: ${AZURE_CLIENT_SECRET}
|
||||||
profile:
|
profile:
|
||||||
tenant-id: [tenant-id]
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
# Uncomment below configurations if you want to enable auto creating resources.
|
# Uncomment below configurations if you want to enable auto creating resources.
|
||||||
# subscription-id: [subscription-id]
|
# subscription-id: ${AZURE_SUBSCRIPTION_ID}
|
||||||
# cloud: Azure
|
# cloud: Azure
|
||||||
# resource:
|
# resource:
|
||||||
# region: [region]
|
# region: [region]
|
||||||
|
|
||||||
servicebus:
|
servicebus:
|
||||||
namespace: [namespace]
|
namespace: ${AZURE_SERVICE_BUS_NAMESPACE}
|
||||||
----
|
----
|
||||||
|
|
||||||
* Step 2. Create `DefaultMessageHandler` with the bean of `ServiceBusTemplate` to send messages to Service Bus,
|
* Step 2. Create `DefaultMessageHandler` with the bean of `ServiceBusTemplate` to send messages to Service Bus,
|
||||||
set the entity type for the ServiceBusTemplate.
|
set the entity type for the ServiceBusTemplate.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String OUTPUT_CHANNEL = "queue.output";
|
private static final String OUTPUT_CHANNEL = "queue.output";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
||||||
public MessageHandler queueMessageSender(ServiceBusTemplate serviceBusTemplate) {
|
public MessageHandler queueMessageSender(ServiceBusTemplate serviceBusTemplate) {
|
||||||
serviceBusTemplate.setDefaultEntityType(ServiceBusEntityType.QUEUE);
|
serviceBusTemplate.setDefaultEntityType(ServiceBusEntityType.QUEUE);
|
||||||
DefaultMessageHandler handler = new DefaultMessageHandler(QUEUE_NAME, serviceBusTemplate);
|
DefaultMessageHandler handler = new DefaultMessageHandler(QUEUE_NAME, serviceBusTemplate);
|
||||||
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
LOGGER.info("Message was sent successfully.");
|
LOGGER.info("Message was sent successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
LOGGER.info("There was an error sending the message.");
|
LOGGER.info("There was an error sending the message.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
* Step 3. Create a Message gateway binding with the message handler created in the last stop via a message channel
|
* Step 3. Create a Message gateway binding with the message handler created in the last stop via a message channel
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Autowired
|
@Autowired
|
||||||
QueueOutboundGateway messagingGateway;
|
QueueOutboundGateway messagingGateway;
|
||||||
|
|
||||||
@MessagingGateway(defaultRequestChannel = OUTPUT_CHANNEL)
|
|
||||||
public interface QueueOutboundGateway {
|
|
||||||
void send(String text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@MessagingGateway(defaultRequestChannel = OUTPUT_CHANNEL)
|
||||||
|
public interface QueueOutboundGateway {
|
||||||
|
void send(String text);
|
||||||
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
* Step 4. Send messages using the gateway
|
* Step 4. Send messages using the gateway
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
this.messagingGateway.send(message);
|
this.messagingGateway.send(message);
|
||||||
----
|
----
|
||||||
|
|
||||||
===== Receive messages from Azure Service Bus
|
===== Receive messages from Azure Service Bus
|
||||||
|
@ -405,39 +411,39 @@ set the entity type for the ServiceBusTemplate.
|
||||||
* Step 2. Create a bean of message channel as the input channel.
|
* Step 2. Create a bean of message channel as the input channel.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String INPUT_CHANNEL = "input";
|
private static final String INPUT_CHANNEL = "input";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MessageChannel input() {
|
public MessageChannel input() {
|
||||||
return new DirectChannel();
|
return new DirectChannel();
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
* Step 3. Create `ServiceBusInboundChannelAdapter` with the bean of `ServiceBusProcessorContainer` to receive messages to Service Bus.
|
* Step 3. Create `ServiceBusInboundChannelAdapter` with the bean of `ServiceBusProcessorContainer` to receive messages to Service Bus.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String QUEUE_NAME = "queue1";
|
private static final String QUEUE_NAME = "queue1";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ServiceBusInboundChannelAdapter queueMessageChannelAdapter(
|
public ServiceBusInboundChannelAdapter queueMessageChannelAdapter(
|
||||||
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel, ServiceBusProcessorContainer processorContainer) {
|
@Qualifier(INPUT_CHANNEL) MessageChannel inputChannel, ServiceBusProcessorContainer processorContainer) {
|
||||||
ServiceBusInboundChannelAdapter adapter = new ServiceBusInboundChannelAdapter(processorContainer, QUEUE_NAME,
|
ServiceBusInboundChannelAdapter adapter = new ServiceBusInboundChannelAdapter(processorContainer, QUEUE_NAME,
|
||||||
new CheckpointConfig(CheckpointMode.MANUAL));
|
new CheckpointConfig(CheckpointMode.MANUAL));
|
||||||
adapter.setOutputChannel(inputChannel);
|
adapter.setOutputChannel(inputChannel);
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
* Step 4. Create a message receiver binding with ServiceBusInboundChannelAdapter created in the last step via the message channel we created before.
|
* Step 4. Create a message receiver binding with ServiceBusInboundChannelAdapter created in the last step via the message channel we created before.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@ServiceActivator(inputChannel = INPUT_CHANNEL)
|
@ServiceActivator(inputChannel = INPUT_CHANNEL)
|
||||||
public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
|
public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
|
||||||
String message = new String(payload);
|
String message = new String(payload);
|
||||||
LOGGER.info("New message received: '{}'", message);
|
LOGGER.info("New message received: '{}'", message);
|
||||||
checkpointer.success()
|
checkpointer.success()
|
||||||
.doOnSuccess(s -> LOGGER.info("Message '{}' successfully checkpointed", message))
|
.doOnSuccess(s -> LOGGER.info("Message '{}' successfully checkpointed", message))
|
||||||
.doOnError(e -> LOGGER.error("Error found", e))
|
.doOnError(e -> LOGGER.error("Error found", e))
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
==== Samples
|
==== Samples
|
||||||
|
@ -590,7 +596,7 @@ spring:
|
||||||
azure:
|
azure:
|
||||||
storage:
|
storage:
|
||||||
queue:
|
queue:
|
||||||
connection-string: [servicebus-connection-string]
|
connection-string: ${AZURE_SERVICE_BUS_CONNECTION_STRING}
|
||||||
----
|
----
|
||||||
|
|
||||||
- For credentials as MSI, configure below properties in application.yml:
|
- For credentials as MSI, configure below properties in application.yml:
|
||||||
|
@ -600,18 +606,18 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
credential:
|
credential:
|
||||||
managed-identity-client-id: [managed-identity-client-id]
|
managed-identity-client-id: ${AZURE_CLIENT_ID}
|
||||||
profile:
|
profile:
|
||||||
tenant-id: [tenant-id]
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
# Uncomment below configurations if you want to enable auto creating resources.
|
# Uncomment below configurations if you want to enable auto creating resources.
|
||||||
# subscription-id: [subscription-id]
|
# subscription-id: ${AZURE_SUBSCRIPTION_ID}
|
||||||
# cloud: Azure
|
# cloud: Azure
|
||||||
# resource:
|
# resource:
|
||||||
# region: [region]
|
# region: [region]
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
queue:
|
queue:
|
||||||
namespace: [servicebus-namespace]
|
namespace: ${AZURE_SERVICE_BUS_NAMESPACE}
|
||||||
----
|
----
|
||||||
|
|
||||||
- For credentials as service principal, configure below properties in application.yml:
|
- For credentials as service principal, configure below properties in application.yml:
|
||||||
|
@ -621,63 +627,62 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
credential:
|
credential:
|
||||||
client-id: [client-id]
|
client-id: ${AZURE_CLIENT_ID}
|
||||||
client-secret: [client-secret]
|
client-secret: ${AZURE_CLIENT_SECRET}
|
||||||
profile:
|
profile:
|
||||||
tenant-id: [tenant-id]
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
# Uncomment below configurations if you want to enable auto creating resources.
|
# Uncomment below configurations if you want to enable auto creating resources.
|
||||||
# subscription-id: [subscription-id]
|
# subscription-id: ${AZURE_SUBSCRIPTION_ID}
|
||||||
# cloud: Azure
|
# cloud: Azure
|
||||||
# resource:
|
# resource:
|
||||||
# region: [region]
|
# region: [region]
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
queue:
|
queue:
|
||||||
namespace: [servicebus-namespace]
|
namespace: ${AZURE_SERVICE_BUS_NAMESPACE}
|
||||||
----
|
----
|
||||||
|
|
||||||
* Step 2. Create `DefaultMessageHandler` with the bean of `StorageQueueOperation` to send messages to Storage Queue.
|
* Step 2. Create `DefaultMessageHandler` with the bean of `StorageQueueOperation` to send messages to Storage Queue.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String STORAGE_QUEUE_NAME = "example";
|
private static final String STORAGE_QUEUE_NAME = "example";
|
||||||
private static final String OUTPUT_CHANNEL = "output";
|
private static final String OUTPUT_CHANNEL = "output";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
|
||||||
public MessageHandler messageSender(StorageQueueOperation storageQueueOperation) {
|
public MessageHandler messageSender(StorageQueueOperation storageQueueOperation) {
|
||||||
DefaultMessageHandler handler = new DefaultMessageHandler(STORAGE_QUEUE_NAME, storageQueueOperation);
|
DefaultMessageHandler handler = new DefaultMessageHandler(STORAGE_QUEUE_NAME, storageQueueOperation);
|
||||||
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
handler.setSendCallback(new ListenableFutureCallback<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Void result) {
|
public void onSuccess(Void result) {
|
||||||
LOGGER.info("Message was sent successfully.");
|
LOGGER.info("Message was sent successfully.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable ex) {
|
public void onFailure(Throwable ex) {
|
||||||
LOGGER.info("There was an error sending the message.");
|
LOGGER.info("There was an error sending the message.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
* Step 3. Create a Message gateway binding with the message handler created in the last stop via a message channel
|
* Step 3. Create a Message gateway binding with the message handler created in the last stop via a message channel
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@Autowired
|
@Autowired
|
||||||
StorageQueueOutboundGateway storageQueueOutboundGateway;
|
StorageQueueOutboundGateway storageQueueOutboundGateway;
|
||||||
|
|
||||||
@MessagingGateway(defaultRequestChannel = OUTPUT_CHANNEL)
|
|
||||||
public interface StorageQueueOutboundGateway {
|
|
||||||
void send(String text);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@MessagingGateway(defaultRequestChannel = OUTPUT_CHANNEL)
|
||||||
|
public interface StorageQueueOutboundGateway {
|
||||||
|
void send(String text);
|
||||||
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
* Step 4. Send messages using the gateway
|
* Step 4. Send messages using the gateway
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
this.storageQueueOutboundGateway.send(message);
|
this.storageQueueOutboundGateway.send(message);
|
||||||
----
|
----
|
||||||
|
|
||||||
===== Receive messages from Azure Storage Queue
|
===== Receive messages from Azure Storage Queue
|
||||||
|
@ -685,39 +690,39 @@ spring:
|
||||||
* Step 2. Create a bean of message channel as the input channel.
|
* Step 2. Create a bean of message channel as the input channel.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String INPUT_CHANNEL = "input";
|
private static final String INPUT_CHANNEL = "input";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public MessageChannel input() {
|
public MessageChannel input() {
|
||||||
return new DirectChannel();
|
return new DirectChannel();
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
* Step 3. Create `StorageQueueMessageSource` with the bean of `StorageQueueOperation` to receive messages to Storage Queue.
|
* Step 3. Create `StorageQueueMessageSource` with the bean of `StorageQueueOperation` to receive messages to Storage Queue.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
private static final String STORAGE_QUEUE_NAME = "example";
|
private static final String STORAGE_QUEUE_NAME = "example";
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@InboundChannelAdapter(channel = INPUT_CHANNEL, poller = @Poller(fixedDelay = "1000"))
|
@InboundChannelAdapter(channel = INPUT_CHANNEL, poller = @Poller(fixedDelay = "1000"))
|
||||||
public StorageQueueMessageSource storageQueueMessageSource(StorageQueueOperation storageQueueOperation) {
|
public StorageQueueMessageSource storageQueueMessageSource(StorageQueueOperation storageQueueOperation) {
|
||||||
storageQueueOperation.setCheckpointMode(CheckpointMode.MANUAL);
|
storageQueueOperation.setCheckpointMode(CheckpointMode.MANUAL);
|
||||||
storageQueueOperation.setVisibilityTimeoutInSeconds(10);
|
storageQueueOperation.setVisibilityTimeoutInSeconds(10);
|
||||||
|
|
||||||
return new StorageQueueMessageSource(STORAGE_QUEUE_NAME, storageQueueOperation);
|
return new StorageQueueMessageSource(STORAGE_QUEUE_NAME, storageQueueOperation);
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
* Step 4. Create a message receiver binding with StorageQueueMessageSource created in the last step via the message channel we created before.
|
* Step 4. Create a message receiver binding with StorageQueueMessageSource created in the last step via the message channel we created before.
|
||||||
[source,java]
|
[source,java]
|
||||||
----
|
----
|
||||||
@ServiceActivator(inputChannel = INPUT_CHANNEL)
|
@ServiceActivator(inputChannel = INPUT_CHANNEL)
|
||||||
public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
|
public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) {
|
||||||
String message = new String(payload);
|
String message = new String(payload);
|
||||||
LOGGER.info("New message received: '{}'", message);
|
LOGGER.info("New message received: '{}'", message);
|
||||||
checkpointer.success()
|
checkpointer.success()
|
||||||
.doOnError(Throwable::printStackTrace)
|
.doOnError(Throwable::printStackTrace)
|
||||||
.doOnSuccess(t -> LOGGER.info("Message '{}' successfully checkpointed", message))
|
.doOnSuccess(t -> LOGGER.info("Message '{}' successfully checkpointed", message))
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
----
|
----
|
||||||
|
|
||||||
==== Samples
|
==== Samples
|
||||||
|
|
|
@ -15,10 +15,9 @@
|
||||||
==== Configuration
|
==== Configuration
|
||||||
|
|
||||||
This starter provides the following properties:
|
This starter provides the following properties:
|
||||||
|
[cols="2*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Properties |Description
|
|Properties |Description
|
||||||
|
|
||||||
|*spring.cloud.azure.active-directory*.app-id-uri |It used in resource server, used to validate the audience in access_token. access_token is valid only when the audience in access_token equal to client-id or app-id-uri
|
|*spring.cloud.azure.active-directory*.app-id-uri |It used in resource server, used to validate the audience in access_token. access_token is valid only when the audience in access_token equal to client-id or app-id-uri
|
||||||
|*spring.cloud.azure.active-directory*.authorization-clients |A map configure the resource APIs the application is going to visit. Each item corresponding to one resource API the application is going to visit. In Spring code, each item corresponding to one OAuth2AuthorizedClient object
|
|*spring.cloud.azure.active-directory*.authorization-clients |A map configure the resource APIs the application is going to visit. Each item corresponding to one resource API the application is going to visit. In Spring code, each item corresponding to one OAuth2AuthorizedClient object
|
||||||
|*spring.cloud.azure.active-directory*.authorization-clients.${AZURE_CLIENT_NAME}.scopes |API permissions of a resource server that the application is going to acquire.
|
|*spring.cloud.azure.active-directory*.authorization-clients.${AZURE_CLIENT_NAME}.scopes |API permissions of a resource server that the application is going to acquire.
|
||||||
|
@ -44,10 +43,9 @@ Here are some examples about how to use these properties:
|
||||||
===== Property example 1: Application type
|
===== Property example 1: Application type
|
||||||
|
|
||||||
This property(`spring.cloud.azure.active-directory.application-type`) is optional, its value can be inferred by dependencies, only `web_application_and_resource_server` must be configured manually: `spring.cloud.azure.active-directory.application-type=web_application_and_resource_server`.
|
This property(`spring.cloud.azure.active-directory.application-type`) is optional, its value can be inferred by dependencies, only `web_application_and_resource_server` must be configured manually: `spring.cloud.azure.active-directory.application-type=web_application_and_resource_server`.
|
||||||
|
[cols="4*", options="header"]
|
||||||
|===
|
|===
|
||||||
|Has dependency: spring-security-oauth2-client |Has dependency: spring-security-oauth2-resource-server |Valid values of application type |Default value
|
|Has dependency: spring-security-oauth2-client |Has dependency: spring-security-oauth2-resource-server |Valid values of application type |Default value
|
||||||
|
|
||||||
|Yes |No |`web_application` |`web_application`
|
|Yes |No |`web_application` |`web_application`
|
||||||
|No |Yes |`resource_server` |`resource_server`
|
|No |Yes |`resource_server` |`resource_server`
|
||||||
|Yes |Yes |`web_application`,`resource_server`,`resource_server_with_obo`, `web_application_and_resource_server` |`resource_server_with_obo`
|
|Yes |Yes |`web_application`,`resource_server`,`resource_server_with_obo`, `web_application_and_resource_server` |`resource_server_with_obo`
|
||||||
|
@ -354,10 +352,10 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
active-directory:
|
active-directory:
|
||||||
tenant-id: <Tenant-id-registered-by-application>
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
client-id: <Web-API-A-client-id>
|
client-id: ${AZURE_CLIENT_ID}
|
||||||
client-secret: <Web-API-A-client-secret>
|
client-secret: ${AZURE_CLIENT_SECRET}
|
||||||
app-id-uri: <Web-API-A-app-id-url>
|
app-id-uri: ${WEB_API_ID_URI}
|
||||||
authorization-clients:
|
authorization-clients:
|
||||||
graph:
|
graph:
|
||||||
scopes:
|
scopes:
|
||||||
|
@ -414,10 +412,10 @@ spring:
|
||||||
cloud:
|
cloud:
|
||||||
azure:
|
azure:
|
||||||
active-directory:
|
active-directory:
|
||||||
tenant-id: <Tenant-id-registered-by-application>
|
tenant-id: ${AZURE_TENANT_ID}
|
||||||
client-id: <Web-API-C-client-id>
|
client-id: ${AZURE_CLIENT_ID}
|
||||||
client-secret: <Web-API-C-client-secret>
|
client-secret: ${AZURE_CLIENT_SECRET}
|
||||||
app-id-uri: <Web-API-C-app-id-url>
|
app-id-uri: ${WEB_API_ID_URI}
|
||||||
application-type: web_application_and_resource_server # This is required.
|
application-type: web_application_and_resource_server # This is required.
|
||||||
authorization-clients:
|
authorization-clients:
|
||||||
graph:
|
graph:
|
||||||
|
|
Загрузка…
Ссылка в новой задаче