Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
package com.azure.messaging.eventhubs;
import com.azure.core.amqp.AmqpMessageConstant;
import com.azure.core.amqp.models.AmqpAnnotatedMessage;
import com.azure.core.amqp.models.AmqpMessageProperties;
import com.azure.core.util.logging.ClientLogger;
import java.time.Instant;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Provides an abstraction over {@link AmqpAnnotatedMessage} and properties that are published by the service. This is a
* read-only view. The properties themselves can be updated via {@link AmqpAnnotatedMessage}.
*
* @see AmqpSystemProperties
*/
final class SystemProperties implements Map {
private static final ClientLogger LOGGER = new ClientLogger(SystemProperties.class);
private final Long offset;
private final String partitionKey;
private final Instant enqueuedTime;
private final Long sequenceNumber;
private final AmqpAnnotatedMessage message;
/**
* Creates an empty set of system properties. This is the case where a message was not received.
*/
SystemProperties() {
this.message = null;
this.offset = null;
this.enqueuedTime = null;
this.partitionKey = null;
this.sequenceNumber = null;
}
SystemProperties(final AmqpAnnotatedMessage message, long offset, Instant enqueuedTime, long sequenceNumber,
String partitionKey) {
this.message = Objects.requireNonNull(message, "'message' cannot be null.");
this.offset = offset;
this.enqueuedTime = enqueuedTime;
this.sequenceNumber = sequenceNumber;
this.partitionKey = partitionKey;
}
/**
* Gets the offset within the Event Hubs stream.
*
* @return The offset within the Event Hubs stream.
*/
Long getOffset() {
return offset;
}
/**
* Gets a partition key used for message partitioning. If it exists, this value was used to compute a hash to select
* a partition to send the message to.
*
* @return A partition key for this Event Data.
*/
String getPartitionKey() {
return partitionKey;
}
/**
* Gets the time this event was enqueued in the Event Hub.
*
* @return The time this was enqueued in the service.
*/
Instant getEnqueuedTime() {
return enqueuedTime;
}
/**
* Gets the sequence number in the event stream for this event. This is unique for every message received in the
* Event Hub.
*
* @return Sequence number for this event.
*
* @throws IllegalStateException if {@link SystemProperties} does not contain the sequence number in a retrieved
* event.
*/
Long getSequenceNumber() {
return sequenceNumber;
}
@Override
public int size() {
if (message == null) {
return 0;
}
return entrySet().size();
}
@Override
public Collection