Skip to content

Stream Native Cloud

Chris Bono edited this page Nov 15, 2022 · 7 revisions

Follow these steps to use a Pulsar service hosted in the StreamNative Cloud.

Pre-requisites

Follow the Stream Native Quickstart to create a cloud instance.

Steps

Obtain the required configuration property values


Navigate to "Pulsar Clusters" in the Stream Native UI.

  • <service-url> - copy "Broker Service URL (TLS)" (eg. pulsar+ssl://foo.streamnative.g.snio.cloud:6651)

  • <admin service-url> - copy "HTTP Service URL (TLS)" (eg. https://foo.streamnative.g.snio.cloud)


Navigate to "Service Accounts" in the Stream Native UI and find the row of the account you will use to connect to the cluster with. Click the "Key File" icon to download the private-key file.

  • <private-key> - fully qualified path to the downloaded file prefixed w/ "file://" (eg. file:///Users/foo/Downloads/o-q1234-abc-user1.json)


Navigate to "Clients" in the Stream Native UI and then select the "Clients" tab in the navbar.

  • <issuer-url> - get from the code snippet for "Java Client By Oauth2" (eg. https://auth.streamnative.cloud/)

  • <audience> - the code snippet for "Java Client By Oauth2" (eg. urn:sn:pulsar:foo-org:foo-instance)

Use the required configuration property values

Add the following to your application.yml (or other property source):

spring:
  pulsar:
    client:
      auth-plugin-class-name: org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2
      authentication:
        issuer-url: <issuer-url>
        private-key: <private-key>
        audience: <audience>
      service-url: <service-url>

    administration:
      auth-plugin-class-name: org.apache.pulsar.client.impl.auth.oauth2.AuthenticationOAuth2
      authentication:
        issuer-url: <issuer-url>
        private-key: <private-key>
        audience: <audience>
      service-url: <admin service-url>

Run your application

Launch your application and you should be on your way to Happy Streaming!

Tip
If you encounter errors on application startup with status 401 it is likely the account you are connecting with does not have access to the tenant/namespace your topic is in. Try fully-qualifying your topic names such as persistent://my-tenant/my-namespace/my-topic and be sure your account has access to the topic(s).
Clone this wiki locally