com.microsoft.azure.servicebus.stream.binder.ServiceBusTopicMessageChannelBinder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-cloud-azure-servicebus-topic-stream-binder Show documentation
Show all versions of spring-cloud-azure-servicebus-topic-stream-binder Show documentation
Azure Service Bus binder for Spring Cloud Stream
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See LICENSE in the project root for
* license information.
*/
package com.microsoft.azure.servicebus.stream.binder;
import com.microsoft.azure.servicebus.stream.binder.properties.ServiceBusConsumerProperties;
import com.microsoft.azure.servicebus.stream.binder.properties.ServiceBusTopicExtendedBindingProperties;
import com.microsoft.azure.servicebus.stream.binder.provisioning.ServiceBusChannelProvisioner;
import com.microsoft.azure.spring.integration.core.api.CheckpointConfig;
import com.microsoft.azure.spring.integration.core.api.SendOperation;
import com.microsoft.azure.spring.integration.servicebus.inbound.ServiceBusTopicInboundChannelAdapter;
import com.microsoft.azure.spring.integration.servicebus.topic.ServiceBusTopicOperation;
import org.springframework.cloud.stream.binder.ExtendedConsumerProperties;
import org.springframework.cloud.stream.provisioning.ConsumerDestination;
import org.springframework.integration.core.MessageProducer;
import org.springframework.lang.NonNull;
import org.springframework.util.StringUtils;
import java.util.UUID;
/**
* @author Warren Zhu
*/
public class ServiceBusTopicMessageChannelBinder extends
ServiceBusMessageChannelBinder {
private final ServiceBusTopicOperation serviceBusTopicOperation;
public ServiceBusTopicMessageChannelBinder(String[] headersToEmbed,
@NonNull ServiceBusChannelProvisioner provisioningProvider,
@NonNull ServiceBusTopicOperation serviceBusTopicOperation) {
super(headersToEmbed, provisioningProvider);
this.serviceBusTopicOperation = serviceBusTopicOperation;
this.bindingProperties = new ServiceBusTopicExtendedBindingProperties();
}
@Override
protected MessageProducer createConsumerEndpoint(ConsumerDestination destination, String group,
ExtendedConsumerProperties properties) {
this.serviceBusTopicOperation.setCheckpointConfig(buildCheckpointConfig(properties));
this.serviceBusTopicOperation.setClientConfig(buildClientConfig(properties));
boolean anonymous = !StringUtils.hasText(group);
if (anonymous) {
group = "anonymous." + UUID.randomUUID().toString();
}
ServiceBusTopicInboundChannelAdapter inboundAdapter =
new ServiceBusTopicInboundChannelAdapter(destination.getName(), this.serviceBusTopicOperation, group);
inboundAdapter.setBeanFactory(getBeanFactory());
return inboundAdapter;
}
@Override
SendOperation getSendOperation() {
return this.serviceBusTopicOperation;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy