Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion modules/ROOT/examples/curl_deflate.sh

This file was deleted.

1 change: 0 additions & 1 deletion modules/ROOT/examples/curl_gzip.sh

This file was deleted.

20 changes: 0 additions & 20 deletions modules/ROOT/examples/result/create_tenant.result

This file was deleted.

2 changes: 0 additions & 2 deletions modules/ROOT/examples/result/delete_tenant_hard.result

This file was deleted.

2 changes: 0 additions & 2 deletions modules/ROOT/examples/result/delete_tenant_soft.result

This file was deleted.

1 change: 0 additions & 1 deletion modules/ROOT/examples/result/get_providers.result

This file was deleted.

2 changes: 1 addition & 1 deletion modules/ROOT/examples/result/get_tenant_limits.result
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"namespace_limit":2,"topic_per_namespace_limit":5,"usage":[{"namespace":"tester/default","topics":["persistent://tester/default/example-topic"]}]}
{"namespace_limit":2,"topic_per_namespace_limit":5,"usage":[{"namespace":"tester/default","topics":["persistent://tester/default/example-topic"]}]}
39 changes: 0 additions & 39 deletions modules/ROOT/examples/result/get_tenants.result

This file was deleted.

Binary file removed modules/ROOT/images/astream-astradb-schema-map.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed modules/ROOT/images/astream-create-tenant.png
Binary file not shown.
Binary file removed modules/ROOT/images/astream-name-sink1.png
Binary file not shown.
Binary file removed modules/ROOT/images/astream-name-sink2-ce.png
Binary file not shown.
Binary file removed modules/ROOT/images/astream-name-sink2-es.png
Binary file not shown.
Binary file removed modules/ROOT/images/astream-new-astradb-sink.png
Binary file not shown.
Binary file removed modules/ROOT/images/astream-new-sink.png
Binary file not shown.
Binary file removed modules/ROOT/images/astream-roles.png
Binary file not shown.
13 changes: 4 additions & 9 deletions modules/apis/pages/api-operations.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,9 @@ The output includes the "pulsarToken" which is the JWT for this {pulsar-short} i
curl --location --request DELETE 'https://api.astra.datastax.com/v2/streaming/tenants/{tenant}/clusters/{cluster}' --header 'Content-Type: application/json' --header "Authorization: Bearer $ASTRA_TOKEN"
----

No response indicates success.
A successful request returns either no response or `202 Accepted`.

If unsuccessful, returns `404 Not Found` or other error code.

== {pulsar-short} API namespace operations

Expand Down Expand Up @@ -238,14 +240,7 @@ curl --location --request GET “https://$WEB_SERVICE_URL/admin/v2/namespaces/$T
curl -sS --fail --location --request PUT --header "Authorization: Bearer $PULSAR_TOKEN" "$WEB_SERVICE_URL/admin/v2/namespaces/$TENANT/$NAMESPACE"
----

.Result
[%collapsible]
====
[source,console]
----
Output: No reply means successful.
----
====
No response indicates success.

=== Delete a namespace

Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed modules/developing/images/astream-create-tenant.png
Binary file not shown.
Binary file not shown.
Binary file removed modules/developing/images/astream-ecs-find-url.png
Binary file not shown.
Binary file removed modules/developing/images/astream-ecs-index.png
Binary file not shown.
Binary file not shown.
Binary file removed modules/developing/images/astream-enable-cdc.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed modules/developing/images/astream-io-topics.png
Binary file not shown.
Binary file removed modules/developing/images/astream-name-function.png
Binary file not shown.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Binary file removed modules/developing/images/astream-table-change.png
Diff not rendered.
Binary file removed modules/developing/images/config-try-me.png
Diff not rendered.
Binary file removed modules/developing/images/connect-tab.png
Diff not rendered.
Binary file removed modules/developing/images/copy-token.png
Diff not rendered.
Binary file removed modules/developing/images/csharp-icon.png
Diff not rendered.
Binary file removed modules/developing/images/download-client.png
Diff not rendered.
Binary file removed modules/developing/images/golang-icon.png
Diff not rendered.
Binary file removed modules/developing/images/java-icon.png
Diff not rendered.
Binary file removed modules/developing/images/node-icon.png
Diff not rendered.
Binary file removed modules/developing/images/python-icon.png
Diff not rendered.
Binary file removed modules/developing/images/settings-tab.png
Diff not rendered.
Binary file removed modules/developing/images/spring-boot-icon.png
Diff not rendered.
Binary file removed modules/developing/images/test-message-input.png
Diff not rendered.
Binary file removed modules/developing/images/try-me-tab.png
Diff not rendered.
Binary file removed modules/developing/images/try-me-test-message.png
Diff not rendered.
53 changes: 45 additions & 8 deletions modules/developing/pages/clients/csharp-produce-consume.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

You can produce and consume messages with the C# {pulsar-short} client and {product}.

Go to the https://github.com/datastax/astra-streaming-examples[examples repo] for the complete source of this example.
For a complete source code example, see the https://github.com/datastax/astra-streaming-examples[{product} Examples repository].

== Prerequisites

Expand All @@ -18,7 +18,13 @@ Create a new console project, and then add a reference to the https://www.nuget.

[source,shell]
----
include::{astra-streaming-examples-repo}/csharp/simple-producer-consumer/create-project.sh[]
dotnet new console \
--output SimpleProducerConsumer \
--framework net6.0

cd SimpleProducerConsumer

dotnet add package DotPulsar --version 2.7.0
----

== Write the script
Expand All @@ -30,7 +36,24 @@ include::{astra-streaming-examples-repo}/csharp/simple-producer-consumer/create-
.Program.cs
[source,csharp]
----
include::{astra-streaming-examples-repo}/csharp/simple-producer-consumer/SimpleProducerConsumer/Program.cs[tag=build-client]
using DotPulsar;
using DotPulsar.Extensions;

var serviceUrl = "<REPLACE_WITH_SERVICE_URL>";
var pulsarToken = "<REPLACE_WITH_PULSAR_TOKEN>";

var tenantName = "<REPLACE_WITH_TENANT_NAME>";
var nmspace = "<REPLACE_WITH_NAMESPACE>";
var topicName = "<REPLACE_WITH_TOPIC>";

var topic = $"persistent://{tenantName}/{nmspace}/{topicName}";

await using var client = PulsarClient.Builder()
.ServiceUrl(new Uri(serviceUrl))
.Authentication(
AuthenticationFactory.Token(pulsarToken)
)
.Build();
----
+
This code creates an instance of `PulsarClient`.
Expand All @@ -46,15 +69,18 @@ Messages can also be in formats like JSON, byte, and AVRO.
.Program.cs
[source,csharp]
----
include::{astra-streaming-examples-repo}/csharp/simple-producer-consumer/SimpleProducerConsumer/Program.cs[tag=build-producer]
await using var producer = client.NewProducer(Schema.String)
.Topic(topic)
.Create();
----

. Asynchronously send a single message and wait for acknowledgment:
+
.Program.cs
[source,csharp]
----
include::{astra-streaming-examples-repo}/csharp/simple-producer-consumer/SimpleProducerConsumer/Program.cs[tag=produce-message]
_ = await producer.Send("Hello World"); // Send a message and ignore the returned MessageId
Console.WriteLine("Sent message");
----

. Create a new `consumer` instance and instruct it to expect messages in string format.
Expand All @@ -63,19 +89,30 @@ The consumer uses broker subscriptions to gather messages.
.Program.cs
[source,csharp]
----
include::{astra-streaming-examples-repo}/csharp/simple-producer-consumer/SimpleProducerConsumer/Program.cs[tag=build-consumer]
await using var consumer = client.NewConsumer(Schema.String)
.SubscriptionName("examples-subscription")
.Topic(topic)
.InitialPosition(SubscriptionInitialPosition.Earliest)
.Create();
----
+
A subscription is set with a subscription name and an initial position.
In this example, the subscription starts with the `Earliest` unacknowledged message, which is also the first message in the topic.


. Loop through the messages provided to the consumer's subscription and write their contents:
+
.Program.cs
[source,csharp]
----
include::{astra-streaming-examples-repo}/csharp/simple-producer-consumer/SimpleProducerConsumer/Program.cs[tag=consumer-loop]
var msgCount = 0;
await foreach (var message in consumer.Messages())
{
msgCount++;
Console.WriteLine($"Received: {message.Value()}");
await consumer.Acknowledge(message);

if(msgCount > 0) break;
}
----

== Run the script
Expand Down
93 changes: 87 additions & 6 deletions modules/developing/pages/clients/golang-produce-consume.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

You can produce and consume messages with the Golang {pulsar-short} client and {product}.

Go to the https://github.com/datastax/astra-streaming-examples[examples repo] for the complete source of this example.
For a complete source code example, see the https://github.com/datastax/astra-streaming-examples[{product} Examples repository].

== Prerequisites

Expand Down Expand Up @@ -38,7 +38,39 @@ The new project includes a `main` file and the retrieved {pulsar-short} client p
.main.go
[source,golang]
----
include::{astra-streaming-examples-repo}/go/simple-producer-consumer/SimpleProducerConsumer/main.go[tag=build-client]
package main

import (
"context"
"fmt"
"github.com/apache/pulsar-client-go/pulsar"
"log"
)

func main() {
log.Println("Pulsar Producer")

serviceUrl := "<REPLACE_WITH_SERVICE_URL>"
pulsarToken := "<REPLACE_WITH_PULSAR_TOKEN>"

tenantName := "<REPLACE_WITH_TENANT_NAME>"
namespace := "<REPLACE_WITH_NAMESPACE>"
topicName := "<REPLACE_WITH_TOPIC>"

topic := fmt.Sprintf("persistent://%v/%v/%v", tenantName, namespace, topicName)

token := pulsar.NewAuthenticationToken(pulsarToken)

client, err := pulsar.NewClient(pulsar.ClientOptions{
URL: serviceUrl,
Authentication: token,
})

if err != nil {
log.Fatalf("Could not instantiate Pulsar client: %v", err)
}

defer client.Close()
----
+
This code is incomplete.
Expand All @@ -53,7 +85,21 @@ include::developing:partial$client-variables-table.adoc[]
.main.go
[source,golang]
----
include::{astra-streaming-examples-repo}/go/simple-producer-consumer/SimpleProducerConsumer/main.go[tag=build-producer]
log.Printf("creating producer...")

// Use the client to instantiate a producer
producer, err := client.CreateProducer(pulsar.ProducerOptions{
Topic: topic,
})

log.Printf("checking error of producer creation...")
if err != nil {
log.Fatal(err)
}

defer producer.Close()

ctx := context.Background()
----
+
While the client contains directions for where to connect and how to authenticate, the producer has the full topic address where a message is published.
Expand All @@ -64,15 +110,38 @@ The full topic address includes the tenant, namespace, and topic names, as well
.main.go
[source,golang]
----
include::{astra-streaming-examples-repo}/go/simple-producer-consumer/SimpleProducerConsumer/main.go[tag=produce-message]
asyncMsg := pulsar.ProducerMessage{
Payload: []byte(fmt.Sprintf("Hello World")),
}

// Attempt to send the message asynchronously and handle the response
producer.SendAsync(ctx, &asyncMsg, func(msgID pulsar.MessageID, msg *pulsar.ProducerMessage, err error) {
if err != nil {
log.Fatal(err)
}

log.Printf("the %s successfully published with the message ID %v", string(msg.Payload), msgID)
})
----

. Use the client to create a new xref:ROOT:astream-subscriptions.adoc[subscription instance] to receive the message:
+
.main.go
[source,golang]
----
include::{astra-streaming-examples-repo}/go/simple-producer-consumer/SimpleProducerConsumer/main.go[tag=build-consumer]
consumer, err := client.Subscribe(pulsar.ConsumerOptions{
Topic: topic,
SubscriptionName: "examples-subscription",
SubscriptionInitialPosition: pulsar.SubscriptionPositionEarliest,
})

if err != nil {
log.Fatal(err)
}

defer consumer.Close()

ctx = context.Background()
----
+
A topic is set with a subscription name and an initial position.
Expand All @@ -83,7 +152,19 @@ In this example, the subscription starts with the `Earliest` unacknowledged mess
.main.go
[source,golang]
----
include::{astra-streaming-examples-repo}/go/simple-producer-consumer/SimpleProducerConsumer/main.go[tag=receive-message]
msg, err := consumer.Receive(ctx)
if err != nil {
log.Fatal(err)
} else {
log.Printf("Received message : %s", string(msg.Payload()))
}

err = consumer.Ack(msg)
if err != nil {
log.Fatal(err)
return
}
}
----

== Run the script
Expand Down
3 changes: 2 additions & 1 deletion modules/developing/pages/clients/index.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
{product} is powered by http://pulsar.apache.org/[{pulsar-reg}].

To connect to your service, use the open-source client APIs provided by the {pulsar} project.
{product} is running {pulsar-short} version {pulsar-version}. You should use this API version or higher.
{product} is running {pulsar-short} version {pulsar-version}.
You should use this API version or higher.

For more information and examples, see the following:

Expand Down
Loading