Class Headers
A collection of Kafka message headers.
Inheritance
Inherited Members
Namespace: Confluent.Kafka
Assembly: cs.temp.dll.dll
Syntax
public class Headers : IEnumerable<IHeader>, IEnumerable
Remarks
Message headers are supported by v0.11 brokers and above.
Properties
BackingList
Gets the underlying list of headers
Declaration
public IReadOnlyList<IHeader> BackingList { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IReadOnlyList<IHeader> |
Count
The number of headers in the collection.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Item[Int32]
Gets the header at the specified index
Declaration
public IHeader this[int index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index |
Property Value
Type | Description |
---|---|
IHeader |
Methods
Add(Header)
Append a new header to the collection.
Declaration
public void Add(Header header)
Parameters
Type | Name | Description |
---|---|---|
Header | header | The header to add to the collection. |
Add(String, Byte[])
Append a new header to the collection.
Declaration
public void Add(string key, byte[] val)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The header key. |
System.Byte[] | val | The header value (possibly null). Note: A null header value is distinct from an empty header value (array of length 0). |
GetEnumerator()
Returns an enumerator that iterates through the headers collection.
Declaration
public IEnumerator<IHeader> GetEnumerator()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerator<IHeader> | An enumerator object that can be used to iterate through the headers collection. |
GetLastBytes(String)
Get the value of the latest header with the specified key.
Declaration
public byte[] GetLastBytes(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to get the associated value of. |
Returns
Type | Description |
---|---|
System.Byte[] | The value of the latest element in the collection with the specified key. |
Exceptions
Type | Condition |
---|---|
System.Collections.Generic.KeyNotFoundException | The key |
Remove(String)
Removes all headers for the given key.
Declaration
public void Remove(string key)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to remove all headers for |
TryGetLastBytes(String, out Byte[])
Try to get the value of the latest header with the specified key.
Declaration
public bool TryGetLastBytes(string key, out byte[] lastHeader)
Parameters
Type | Name | Description |
---|---|---|
System.String | key | The key to get the associated value of. |
System.Byte[] | lastHeader | The value of the latest element in the collection with the specified key, if a header with that key was present in the collection. |
Returns
Type | Description |
---|---|
System.Boolean | true if the a value with the specified key was present in the collection, false otherwise. |