Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aashikam committed Apr 1, 2024
1 parent f3a225d commit 950636b
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 17 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ nats:Error? result =
2. Publish as a request that expects a reply:
```ballerina
string message = "hello world";
nats:Message|nats:Error reqReply =
nats:AnydataMessage|nats:Error reqReply =
natsClient->requestMessage({ content: message.toBytes(), subject: "demo.nats.basic"}, 5);
```

Expand All @@ -76,7 +76,7 @@ nats:Error? result = natsClient->publish({ content: message.toBytes(), subject:
}
service nats:Service on new nats:Listener(nats:DEFAULT_URL) {
remote function onMessage(nats:Message message) {
remote function onMessage(nats:AnydataMessage message) {
}
}
```
Expand All @@ -90,7 +90,7 @@ service nats:Service on new nats:Listener(nats:DEFAULT_URL) {
service nats:Service on new nats:Listener(nats:DEFAULT_URL) {
// The returned message will be published to the replyTo subject of the consumed message
remote function onRequest(nats:Message message) returns string? {
remote function onRequest(nats:AnydataMessage message) returns string? {
return "Reply Message";
}
}
Expand Down
2 changes: 1 addition & 1 deletion ballerina-tests/tests/data_binding_publish_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ service nats:Service on new nats:Listener(DATA_BINDING_URL) {
remote function onMessage(XmlMessage msg) {
}

remote function onError(nats:Message message, nats:Error err) {
remote function onError(nats:AnydataMessage message, nats:Error err) {
log:printInfo("Error Received: " + err.message());
setOnErrorReceived(true);
setOnErrorMessage(err.message());
Expand Down
6 changes: 3 additions & 3 deletions ballerina/Module.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ nats:Error? result =
2. Publish as a request that expects a reply:
```ballerina
string message = "hello world";
nats:Message|nats:Error reqReply =
nats:AnydataMessage|nats:Error reqReply =
natsClient->requestMessage({ content: message.toBytes(), subject: "demo.nats.basic"}, 5);
```

Expand All @@ -69,7 +69,7 @@ nats:Error? result = natsClient->publish({ content: message.toBytes(), subject:
}
service nats:Service on new nats:Listener(nats:DEFAULT_URL) {
remote function onMessage(nats:Message message) {
remote function onMessage(nats:AnydataMessage message) {
}
}
```
Expand All @@ -83,7 +83,7 @@ service nats:Service on new nats:Listener(nats:DEFAULT_URL) {
service nats:Service on new nats:Listener(nats:DEFAULT_URL) {
// The returned message will be published to the replyTo subject of the consumed message
remote function onRequest(nats:Message message) returns string? {
remote function onRequest(nats:AnydataMessage message) returns string? {
return "Reply Message";
}
}
Expand Down
4 changes: 2 additions & 2 deletions ballerina/Package.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ nats:Error? result =
2. Publish as a request that expects a reply:
```ballerina
string message = "hello world";
nats:Message|nats:Error reqReply =
nats:AnydataMessage|nats:Error reqReply =
natsClient->requestMessage({ content: message.toBytes(), subject: "demo.nats.basic"}, 5);
```

Expand All @@ -69,7 +69,7 @@ nats:Error? result = natsClient->publish({ content: message.toBytes(), subject:
}
service nats:Service on new nats:Listener(nats:DEFAULT_URL) {
remote function onMessage(nats:Message message) {
remote function onMessage(nats:AnydataMessage message) {
}
}
```
Expand Down
4 changes: 2 additions & 2 deletions docs/proposals/data-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ When receiving the same message,
```ballerina
service "demo" on new nats:Listener(nats:DEFAULT_URL) {
remote function onMessage(nats:Message message) returns nats:Error? {
remote function onMessage(nats:AnydataMessage message) returns nats:Error? {
string messageContent = check string:fromBytes(message.content);
Person person = check value:fromJsonStringWithType(messageContent);
}
Expand All @@ -56,7 +56,7 @@ Receiving the message as a request,
```ballerina
service "demo" on new nats:Listener(nats:DEFAULT_URL) {
remote function onRequest(nats:Message message) returns anydata|nats:Error? {
remote function onRequest(nats:AnydataMessage message) returns anydata|nats:Error? {
string messageContent = check string:fromBytes(message.content);
Person person = check value:fromJsonStringWithType(messageContent);
return "New person received";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ configurable string LISTENING_SUBJECT = ?;
service "notificationService" on new nats:Listener(nats:DEFAULT_URL) {

// Listens to NATS subject for any successful orders
remote function onMessage(nats:Message message) returns error? {
remote function onMessage(nats:BytesMessage message) returns error? {

// Convert the byte values in the NATS Message to type Order
string messageContent = check string:fromBytes(message.content);
Expand Down
4 changes: 2 additions & 2 deletions examples/order-manager/order-processor/order_processor.bal
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ service "orderProcessorService" on new nats:Listener(nats:DEFAULT_URL) {
nats:Client natsClient = checkpanic new(nats:DEFAULT_URL);

// Listens to NATS subject for any new orders and process them
remote function onMessage(nats:Message message) returns error? {
remote function onMessage(nats:BytesMessage message) returns error? {

// Uses Ballerina query expressions to filter out the successful orders and publish to NATS subject
check from types:Order 'order in check getOrdersFromMessage(message)
Expand All @@ -48,7 +48,7 @@ service "orderProcessorService" on new nats:Listener(nats:DEFAULT_URL) {
}

// Convert the byte values in NATS message to type Order[]
function getOrdersFromMessage(nats:Message message) returns types:Order[]|error {
function getOrdersFromMessage(nats:BytesMessage message) returns types:Order[]|error {
types:Order[] receivedOrders = [];
string messageContent = check string:fromBytes(message.content);
json jsonContent = check value:fromJsonString(messageContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ nats:Service consumerService =
subject: PUBLISH_SUBJECT
}
service object {
remote function onMessage(nats:Message msg) {
remote function onMessage(nats:BytesMessage msg) {
byte[] messageContent = <@untainted> msg.content;

string|error message = string:fromBytes(messageContent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ nats:Service consumerService =
subject: SUBJECT
}
service object {
remote function onMessage(nats:Message msg) {
remote function onMessage(nats:BytesMessage msg) {
byte[] messageContent = <@untainted> msg.content;

string|error message = strings:fromBytes(messageContent);
Expand Down
2 changes: 1 addition & 1 deletion load-tests/simple_producer_consumer/src/main.bal
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ nats:Service natsService =
subject: SUBJECT
}
service object {
remote function onMessage(nats:Message message) returns error? {
remote function onMessage(nats:BytesMessage message) returns error? {
string|error messageContent = 'string:fromBytes(message.content);
if messageContent is error {
lock {
Expand Down

0 comments on commit 950636b

Please sign in to comment.