Skip to content
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

Update storage queue beta4 #164

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import com.azure.spring.integration.storage.queue.inbound.StorageQueueMessageSource;
import com.azure.spring.messaging.AzureHeaders;
import com.azure.spring.messaging.checkpoint.CheckpointMode;
import com.azure.spring.messaging.checkpoint.Checkpointer;
import com.azure.spring.storage.queue.core.StorageQueueOperation;
import com.azure.spring.storage.queue.core.StorageQueueTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
Expand All @@ -31,10 +30,9 @@ public class ReceiveController {

@Bean
@InboundChannelAdapter(channel = INPUT_CHANNEL, poller = @Poller(fixedDelay = "1000"))
public StorageQueueMessageSource storageQueueMessageSource(StorageQueueOperation storageQueueOperation) {
storageQueueOperation.setCheckpointMode(CheckpointMode.MANUAL);
public StorageQueueMessageSource storageQueueMessageSource(StorageQueueTemplate storageQueueTemplate) {

return new StorageQueueMessageSource(STORAGE_QUEUE_NAME, storageQueueOperation);
return new StorageQueueMessageSource(STORAGE_QUEUE_NAME, storageQueueTemplate);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package com.azure.spring.sample.storage.queue;

import com.azure.spring.integration.handler.DefaultMessageHandler;
import com.azure.spring.storage.queue.core.StorageQueueOperation;
import com.azure.spring.storage.queue.core.StorageQueueTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -43,8 +43,8 @@ public String send(@RequestParam("message") String message) {

@Bean
@ServiceActivator(inputChannel = OUTPUT_CHANNEL)
public MessageHandler messageSender(StorageQueueOperation storageQueueOperation) {
DefaultMessageHandler handler = new DefaultMessageHandler(STORAGE_QUEUE_NAME, storageQueueOperation);
public MessageHandler messageSender(StorageQueueTemplate storageQueueTemplate) {
DefaultMessageHandler handler = new DefaultMessageHandler(STORAGE_QUEUE_NAME, storageQueueTemplate);
handler.setSendCallback(new ListenableFutureCallback<Void>() {
@Override
public void onSuccess(Void result) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

package com.azure.spring.sample.storage.queue.operation;

import com.azure.spring.storage.queue.core.StorageQueueOperation;
import com.azure.spring.storage.queue.core.StorageQueueTemplate;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* {@link StorageQueueOperation} code sample.
* {@link StorageQueueTemplate} code sample.
*
* @author Miao Cao
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
package com.azure.spring.sample.storage.queue.operation;

import com.azure.spring.messaging.AzureHeaders;
import com.azure.spring.messaging.checkpoint.CheckpointMode;
import com.azure.spring.messaging.checkpoint.Checkpointer;
import com.azure.spring.storage.queue.core.StorageQueueOperation;
import com.azure.spring.storage.queue.core.StorageQueueTemplate;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -17,6 +16,8 @@
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.Duration;

/**
* @author Miao Cao
*/
Expand All @@ -26,7 +27,7 @@ public class WebController {
private static final String STORAGE_QUEUE_NAME = "example";

@Autowired
StorageQueueOperation storageQueueOperation;
StorageQueueTemplate storageQueueOperation;

@PostMapping("/messages")
public String send(@RequestParam("message") String message) {
Expand All @@ -40,8 +41,7 @@ public String send(@RequestParam("message") String message) {
@GetMapping("/messages")
public String receive() {
this.storageQueueOperation.setMessagePayloadType(String.class);
this.storageQueueOperation.setCheckpointMode(CheckpointMode.MANUAL);
Message<?> message = this.storageQueueOperation.receiveAsync(STORAGE_QUEUE_NAME).block();
Message<?> message = this.storageQueueOperation.receiveAsync(STORAGE_QUEUE_NAME, Duration.ofSeconds(30)).block();
if (message == null) {
LOGGER.info("You have no new messages.");
return null;
Expand Down