@Override public EventPosition apply(String t) { return EventPosition.fromStartOfStream(); } }
private PartitionReceiverImpl(MessagingFactory factory, final String eventHubName, final String consumerGroupName, final String partitionId, final EventPositionImpl eventPosition, final Long epoch, final boolean isEpochReceiver, final ReceiverOptions receiverOptions, final ScheduledExecutorService executor) { super("PartitionReceiverImpl".concat(StringUtil.getRandomString()), null, executor); this.underlyingFactory = factory; this.eventHubName = eventHubName; this.consumerGroupName = consumerGroupName; this.partitionId = partitionId; this.eventPosition = eventPosition; this.epoch = epoch; this.isEpochReceiver = isEpochReceiver; this.receiveHandlerLock = new Object(); this.receiverOptions = receiverOptions; this.runtimeInformation = (this.receiverOptions != null && this.receiverOptions.getReceiverRuntimeMetricEnabled()) ? new ReceiverRuntimeInformation(partitionId) : null; this.currentEventPosition = EventPosition.fromStartOfStream(); }
private static EventProcessorOptions buildEventProcessorOptions(StartPosition startPosition) { EventProcessorOptions options = EventProcessorOptions.getDefaultOptions(); if (startPosition == StartPosition.EARLIEST) { options.setInitialPositionProvider((s) -> EventPosition.fromStartOfStream()); } else /* StartPosition.LATEST */ { options.setInitialPositionProvider((s) -> EventPosition.fromEndOfStream()); } return options; }
private static EventProcessorOptions buildEventProcessorOptions(StartPosition startPosition) { EventProcessorOptions options = EventProcessorOptions.getDefaultOptions(); if (startPosition == StartPosition.EARLIEST) { options.setInitialPositionProvider((s) -> EventPosition.fromStartOfStream()); } else /* StartPosition.LATEST */ { options.setInitialPositionProvider((s) -> EventPosition.fromEndOfStream()); } return options; }
@Test public void testReceive() throws EventHubException { EventHubClientManagerFactory clientFactory = new EventHubClientManagerFactory(); EventHubClientManager wrapper = clientFactory .getEventHubClientManager(SYSTEM_NAME, STREAM_NAME1, new EventHubConfig(createEventHubConfig())); wrapper.init(); EventHubClient client = wrapper.getEventHubClient(); PartitionReceiver receiver = client.createReceiverSync(EventHubClient.DEFAULT_CONSUMER_GROUP_NAME, "0", EventPosition.fromStartOfStream()); receiveMessages(receiver, 300); }