ChannelMetadata Entity
Since version 9.0.0, the Java SDK supports entities, which are SDK objects that provide operations on endpoints associated with their type. They are designed as first-class citizens to facilitate working with various PubNub APIs.
Certain PubNub API functionality is already exposed via entities, while other may still be available using the pubnub
object.
Create channel metadata
This method returns one local ChannelMetadata
entity.
pubnub.channelMetadata(String id)
* required
Parameter | Description |
---|---|
id *Type: String | The String identifier for a single channel metadata object to create a subscription of. |
Basic usage
Reference code
This example is a self-contained code snippet ready to be run. It includes necessary imports and executes methods with console logging. Use it as a reference when working with other examples in this document.
import com.pubnub.api.PubNubException;
import com.pubnub.api.java.PubNub;
import com.pubnub.api.java.v2.PNConfiguration;
import com.pubnub.api.UserId;
import com.pubnub.api.enums.PNLogVerbosity;
import com.pubnub.api.java.v2.entities.ChannelMetadata;
public class ChannelMetadataApp {
public static void main(String[] args) throws PubNubException {
// Configure PubNub instance
PNConfiguration.Builder configBuilder = PNConfiguration.builder(new UserId("demoUserId"), "demo");
configBuilder.publishKey("demo");
configBuilder.logVerbosity(PNLogVerbosity.BODY);
configBuilder.secure(true);
show all 23 linesAvailable operations
The ChannelMetadata
entity provides operations performed on PubNub App Context's channel metadata.
Operation (click for more information) | Description |
---|---|
subscription(subscriptionOptions) | Returns a local channel metadata subscription object with optional parameters to which you can subscribe and start receiving real-time updates for that channel metadata. |