PartitionContext(HostContext hostContext, String partitionId) { this.hostContext = hostContext; this.partitionId = partitionId; this.runtimeInformation = new ReceiverRuntimeInformation(partitionId); }
@Override public Iterable<EventData> apply(Collection<Message> amqpMessages) { PassByRef<MessageWrapper> lastMessageRef = null; if (PartitionReceiverImpl.this.receiverOptions != null && PartitionReceiverImpl.this.receiverOptions.getReceiverRuntimeMetricEnabled()) lastMessageRef = new PassByRef<>(); final Iterable<EventData> events = EventDataUtil.toEventDataCollection(amqpMessages, lastMessageRef); if (lastMessageRef != null && lastMessageRef.get() != null) { final DeliveryAnnotations deliveryAnnotations = lastMessageRef.get().getMessage().getDeliveryAnnotations(); if (deliveryAnnotations != null && deliveryAnnotations.getValue() != null) { final Map<Symbol, Object> deliveryAnnotationsMap = deliveryAnnotations.getValue(); PartitionReceiverImpl.this.runtimeInformation.setRuntimeInformation( (long) deliveryAnnotationsMap.get(ClientConstants.LAST_ENQUEUED_SEQUENCE_NUMBER), ((Date) deliveryAnnotationsMap.get(ClientConstants.LAST_ENQUEUED_TIME_UTC)).toInstant(), (String) deliveryAnnotationsMap.get(ClientConstants.LAST_ENQUEUED_OFFSET)); } PartitionReceiverImpl.this.currentEventPosition = lastMessageRef.get().getEventPosition(); } return events; } }, this.executor);
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(); }