@@ -0,0 +1,3664 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.%0A// Licensed under the MIT License.%0A%0Apackage com.azure.messaging.eventhubs.checkpointstore.blob;%0A%0Aimport com.azure.core.http.HttpHeaders;%0Aimport com.azure.core.http.policy.AddHeadersPolicy;%0Aimport com.azure.messaging.eventhubs.EventProcessorClient;%0Aimport com.azure.messaging.eventhubs.EventProcessorClientBuilder;%0Aimport com.azure.storage.blob.BlobContainerAsyncClient;%0Aimport com.azure.storage.blob.BlobContainerClientBuilder;%0Aimport java.util.concurrent.CountDownLatch;%0A%0A/**%0A * This sample shows how to setup an Event Processor that uses an older version of blob storage service as%0A * checkpoint store.%0A */%0Apublic class EventProcessorWithOlderStorageVersion %7B%0A%0A    private static final String STORAGE_CONNECTION_STRING = %22%22;%0A    private static final String SAS_TOKEN = %22%22;%0A    private static final String CONTAINER_NAME = %22%22;%0A%0A    private static final String EH_CONNECTION_STRING = %22%22;%0A    private static final String CONSUMER_GROUP = %22%22;%0A    private static final String EVENT_HUB_NAME = %22%22;%0A%0A    /**%0A     * The main method to run this sample.%0A     *%0A     * @param args Ignored input arguments.%0A     * @throws InterruptedException If the program is interrupted while running the processor.%0A     */%0A    public static void main(String%5B%5D args) throws InterruptedException %7B%0A%0A        // Setup the container client by adding a header policy to specify older version of storage%0A        BlobContainerAsyncClient blobContainerAsyncClient = new BlobContainerClientBuilder()%0A            .connectionString(STORAGE_CONNECTION_STRING)%0A            .containerName(CONTAINER_NAME)%0A            .sasToken(SAS_TOKEN)%0A            .addPolicy(new AddHeadersPolicy(new HttpHeaders().put(%22x-ms-version%22, %222017-11-09%22)))%0A            .buildAsyncClient();%0A%0A        BlobCheckpointStore blobCheckpointStore = new BlobCheckpointStore(blobContainerAsyncClient);%0A        CountDownLatch countDownLatch = new CountDownLatch(3);%0A%0A        // Create the event processor instance%0A        EventProcessorClient processor = new EventProcessorClientBuilder()%0A            .checkpointStore(blobCheckpointStore)%0A            .connectionString(EH_CONNECTION_STRING, EVENT_HUB_NAME)%0A            .consumerGroup(CONSUMER_GROUP)%0A            .processEvent(eventContext -%3E %7B%0A                if (eventContext.getEventData().getSequenceNumber() %25 100 == 0) %7B%0A                    System.out.println(%0A                        String.format(%22Event = %25s, partition = %25s, seq num = %25d, offset = %25d%22,%0A                            eventContext.getEventData().getBodyAsString(),%0A                            eventContext.getPartitionContext().getPartitionId(),%0A                            eventContext.getEventData().getSequenceNumber(),%0A                            eventContext.getEventData().getOffset()));%0A                    eventContext.updateCheckpoint();%0A                %7D%0A            %7D)%0A            .processError(errorContext -%3E %7B%0A                if (!isNumeric(errorContext.getPartitionContext().getPartitionId())) %7B%0A                    countDownLatch.countDown();%0A                %7D%0A                System.out.println(%0A                    %22Error %22 + errorContext.getPartitionContext().getPartitionId() + %22 %22 + errorContext.getThrowable()%0A                        .getMessage());%0A            %7D)%0A            .buildEventProcessorClient();%0A%0A        processor.start();%0A        countDownLatch.await();%0A        processor.stop();%0A    %7D%0A%0A    private static boolean isNumeric(String partitionId) %7B%0A        try %7B%0A            Integer.parseInt(partitionId);%0A            return true;%0A        %7D catch (NumberFormatException ex) %7B%0A            return false;%0A        %7D%0A    %7D%0A%7D%0A

Add event processor sample for Azure Stack usecase (#9057)