-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Service Bus sample:multiple-namespaces and eventhubs-integra…
…tion (#134)
- Loading branch information
1 parent
ccabc1a
commit 52b2f02
Showing
9 changed files
with
149 additions
and
102 deletions.
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
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
Oops, something went wrong.