Class AzurePublisher

java.lang.Object
org.chenile.pubsub.azure.pub.AzurePublisher
All Implemented Interfaces:
ChenilePub

public class AzurePublisher extends Object implements ChenilePub
Azure-based implementation of the ChenilePub interface. Provides methods to publish messages to Azure hub topics synchronously or asynchronously.
  • Field Details

  • Constructor Details

  • Method Details

    • publishToOperation

      public void publishToOperation(String service, String operationName, String payload, Map<String,Object> properties)
      Publishes a message to the given service's operation topic.
      Specified by:
      publishToOperation in interface ChenilePub
      Parameters:
      service - the service name
      operationName - the operation name
      payload - the message payload
      properties - additional message properties
    • asyncPublish

      public void asyncPublish(String topic, String payload, Map<String,Object> properties)
      Publishes a message asynchronously to the given Kafka topic.
      Specified by:
      asyncPublish in interface ChenilePub
      Parameters:
      topic - the Kafka topic
      payload - the message payload
      properties - additional message properties
    • sendMessage

      private void sendMessage(String topic, String payload, Map<String,Object> properties)
    • publish

      public void publish(String topic, String payload, Map<String,Object> properties)
      Publishes a message to the global Kafka topic.
      Specified by:
      publish in interface ChenilePub
      Parameters:
      topic - logical topic name (added as header, not used as Kafka topic)
      payload - the message payload
      properties - additional message properties
    • buildHeaders

      private static Map<String,Object> buildHeaders(String topic, Map<String,Object> properties)
      Builds Kafka headers from message properties and adds the Chenile topic key.
      Parameters:
      topic - the logical topic
      properties - message properties
      Returns:
      list of Kafka headers
    • substituteProperties

      private static String substituteProperties(String text, Map<String,Object> properties)
      Replaces placeholders in a string with values from the given properties map.
      Parameters:
      text - the string containing placeholders like {key}
      properties - the map of properties
      Returns:
      the resolved string
    • applyPartitionRouting

      private static void applyPartitionRouting(com.azure.messaging.eventhubs.models.CreateBatchOptions options, Map<String,Object> properties)
      Configures default, explicit-ID, Azure-keyed, or automatic Event Hubs routing.
    • getPartitionId

      private static String getPartitionId(Map<String,Object> properties)
      Extracts an explicit partition number. An absent value is handled by the default partition zero route; an invalid supplied value retains the historic fallback to partition zero.
    • getPartitionKey

      private static String getPartitionKey(Map<String,Object> properties)
    • getPartitionMode

      private static String getPartitionMode(Map<String,Object> properties)
    • applyBeforePublishInterceptors

      private PubSubMessage applyBeforePublishInterceptors(PubSubMessage message)