title: In an Azure event-hub created with 2 partition, the event-hub consumer tries to connect to 3rd and 4th partition
body: <p>I have set up an Azure event-hub with 2 partitions. I am using the Microsoft published code (<a href="https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-java-get-started-send" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/azure/event-hubs/event-hubs-java-get-started-send</a>) to consume the messages from the event-hub. The consumer tries to connect to 3rd and 4th partitions even when they don't exist. </p>
  
  <p>Error message:</p>
  
  <blockquote>
    <p>2019-06-14 09:34:34,998 [ault|host]-1-13] - ERROR PartitionPump<br>
    - host host: 3: PartitionReceiver creation failed java.util.concurrent.CompletionException:
    com.microsoft.azure.eventhubs.EventHubException: The specified
    partition is invalid for an EventHub partition sender or receiver. It
    should be between 0 and 1. Parameter name: PartitionId
    TrackingId:11c0c687fa3146ffaa97749d23abeae5_G27,
    SystemTracker:gateway5, Timestamp:2019-06-14T04:04:34,
    errorContext[NS: dev-sams-iot.servicebus.windows.net, PATH:
    test/ConsumerGroups/$Default/Partitions/3, REFERENCE_ID:
    6d2875_ae5_G27_1560485074529]     at
    java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
      at
    java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
      at
    java.util.concurrent.CompletableFuture.uniAccept(CompletableFuture.java:647)
      at
    java.util.concurrent.CompletableFuture$UniAccept.tryFire$$$capture(CompletableFuture.java:632)
      at
    java.util.concurrent.CompletableFuture$UniAccept.tryFire(CompletableFuture.java)
      at
    java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
      at
    java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
      at
    com.microsoft.azure.eventhubs.impl.ExceptionUtil.completeExceptionally(ExceptionUtil.java:104)
      at
    com.microsoft.azure.eventhubs.impl.MessageReceiver.cancelOpen(MessageReceiver.java:361)
      at
    com.microsoft.azure.eventhubs.impl.MessageReceiver.onOpenComplete(MessageReceiver.java:351)
      at
    com.microsoft.azure.eventhubs.impl.MessageReceiver.onError(MessageReceiver.java:418)
      at
    com.microsoft.azure.eventhubs.impl.MessageReceiver.onClose(MessageReceiver.java:740)
      at
    com.microsoft.azure.eventhubs.impl.BaseLinkHandler.processOnClose(BaseLinkHandler.java:74)
      at
    com.microsoft.azure.eventhubs.impl.BaseLinkHandler.handleRemoteLinkClosed(BaseLinkHandler.java:113)
      at
    com.microsoft.azure.eventhubs.impl.BaseLinkHandler.onLinkRemoteClose(BaseLinkHandler.java:48)
      at
    org.apache.qpid.proton.engine.BaseHandler.handle(BaseHandler.java:176)
      at
    org.apache.qpid.proton.engine.impl.EventImpl.dispatch(EventImpl.java:108)
      at
    org.apache.qpid.proton.reactor.impl.ReactorImpl.dispatch(ReactorImpl.java:324)
      at
    org.apache.qpid.proton.reactor.impl.ReactorImpl.process(ReactorImpl.java:291)
      at
    com.microsoft.azure.eventhubs.impl.MessagingFactory$RunReactor.run(MessagingFactory.java:507)
      at
    java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
      at java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:266)
      at java.util.concurrent.FutureTask.run(FutureTask.java)     at
    java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
      at
    java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
      at
    java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      at
    java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      at java.lang.Thread.run(Thread.java:748)</p>
  </blockquote>