-
Notifications
You must be signed in to change notification settings - Fork 244
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
Refactor Service Bus sample:multiple-namespaces and eventhubs-integration #134
Merged
backwind1233
merged 8 commits into
Azure-Samples:spring-cloud-azure_4.0
from
backwind1233:refactor-multiple-namespaces
Jan 17, 2022
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
75bc385
1. move bean to MultipleNamespacesAzureServiceBusMessagingAutoConfigu…
backwind1233 803e684
1. rename from ***Controller to ***Service
backwind1233 fbe184d
change from @RestController to @Service
backwind1233 02c1a30
refactor eventhubs-integration
backwind1233 feb4371
add private modifier
backwind1233 7392b69
add private modifier
backwind1233 6ab24fd
add private modifier
backwind1233 e13eb05
add some java doc for samples
backwind1233 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...eventhubs-integration/src/main/java/com/azure/spring/sample/eventhubs/ReceiveService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
package com.azure.spring.sample.eventhubs; | ||
|
||
import com.azure.spring.integration.eventhubs.inbound.EventHubsInboundChannelAdapter; | ||
import com.azure.spring.messaging.AzureHeaders; | ||
import com.azure.spring.messaging.checkpoint.Checkpointer; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.integration.annotation.ServiceActivator; | ||
import org.springframework.messaging.MessageChannel; | ||
import org.springframework.messaging.handler.annotation.Header; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* @author Warren Zhu | ||
*/ | ||
@Service | ||
public class ReceiveService { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(ReceiveService.class); | ||
private static final String INPUT_CHANNEL = "input"; | ||
|
||
/** | ||
* This message receiver binding with {@link EventHubsInboundChannelAdapter} | ||
* via {@link MessageChannel} has name {@value INPUT_CHANNEL} | ||
*/ | ||
@ServiceActivator(inputChannel = INPUT_CHANNEL) | ||
public void messageReceiver(byte[] payload, @Header(AzureHeaders.CHECKPOINTER) Checkpointer checkpointer) { | ||
String message = new String(payload); | ||
LOGGER.info("New message received: '{}'", message); | ||
checkpointer.success() | ||
.doOnSuccess(s -> LOGGER.info("Message '{}' successfully checkpointed", message)) | ||
.doOnError(e -> LOGGER.error("Error found", e)) | ||
.subscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,39 +3,31 @@ | |
|
||
package com.azure.spring.sample.servicebus; | ||
|
||
import com.azure.spring.messaging.PropertiesSupplier; | ||
import com.azure.spring.servicebus.core.properties.ProcessorProperties; | ||
import com.azure.spring.servicebus.core.properties.ProducerProperties; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.context.properties.EnableConfigurationProperties; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.integration.config.EnableIntegration; | ||
import reactor.util.function.Tuple2; | ||
import com.azure.spring.sample.servicebus.QueueSendService.QueueSendGateway; | ||
|
||
@SpringBootApplication | ||
@EnableIntegration | ||
@EnableConfigurationProperties(CustomizedServiceBusProperties.class) | ||
@Configuration(proxyBeanMethods = false) | ||
public class ServiceBusIntegrationApplication { | ||
|
||
public static void main(String[] args) { | ||
SpringApplication.run(ServiceBusIntegrationApplication.class, args); | ||
} | ||
public class ServiceBusIntegrationApplication implements CommandLineRunner { | ||
|
||
@Autowired | ||
CustomizedServiceBusProperties properties; | ||
QueueSendGateway messagingGateway; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. private |
||
|
||
@Bean | ||
public PropertiesSupplier<String, ProducerProperties> producerPropertiesSupplier() { | ||
return properties.producerPropertiesSupplier(); | ||
public static void main(String[] args) { | ||
SpringApplication.run(ServiceBusIntegrationApplication.class, args); | ||
} | ||
|
||
@Bean | ||
public PropertiesSupplier<Tuple2<String, String>, ProcessorProperties> processorPropertiesSupplier() { | ||
return properties.processorPropertiesSupplier(); | ||
@Override | ||
public void run(String... args) { | ||
this.messagingGateway.send("hello"); | ||
} | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private, or constructor injection?