routing with sdk setup always invokes default handler
See original GitHub issueExpected Behavior
i have followed the docs here and tried to setup message routing with the SDK and expect to invoke different handlers based on the type.
https://docs.dapr.io/developing-applications/sdks/js/js-server/
i had to make some adjustments as the docs seem to be slightly off?
import process from "process";
import { DaprServer } from "@dapr/dapr";
const DAPR_HOST = process.env.DAPR_HOST || "http://localhost";
const DAPR_HTTP_PORT = process.env.DAPR_HTTP_PORT || "3502";
const SERVER_HOST = process.env.SERVER_HOST || "127.0.0.1";
const SERVER_PORT = process.env.APP_PORT || 5002;
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
const server = new DaprServer(
SERVER_HOST,
SERVER_PORT.toString(),
DAPR_HOST,
DAPR_HTTP_PORT
);
const PUBSUB_NAME: string = "pubsub";
const PUBSUB_TOPIC: string = "topic-1";
await server.pubsub.subscribeWithOptions(PUBSUB_NAME, PUBSUB_TOPIC, {
route: {
default: "/default",
rules: [
{
match: `event.type == "new.event"`,
path: "/new",
},
],
},
});
server.pubsub.subscribeToRoute(
PUBSUB_NAME,
PUBSUB_TOPIC,
"default",
async (data) => {
console.log(`Handling Default`);
console.log(JSON.stringify(data));
}
);
server.pubsub.subscribeToRoute(
PUBSUB_NAME,
PUBSUB_TOPIC,
"new",
async (data) => {
console.log(`Handling new event: ${data}`);
}
);
await server.start();
Actual Behavior
the default is always invoked.
Steps to Reproduce the Problem
you should be able to run this code with the “type”: “module” in your package.json. when you publish a message through the sdk or via the vs code extension the default handler is always invoked.
Issue Analytics
- State:
- Created 9 months ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Invoking your backend integration: $default Route and custom ...
You can set up a route request for a WebSocket API in the API Gateway console, by using the AWS CLI, or by...
Read more >Routing to controller actions in ASP.NET Core - Microsoft Learn
MapControllerRoute is used to create a single route. The single route is named default route. Most apps with controllers and views use a...
Read more >Permissions used only in default handlers - Android Developers
The Settings app on Android includes a screen that shows users which apps are currently default handlers for the device's core functions, as ......
Read more >How do you enforce lowercase routing in ASP.NET Core?
I'd think it would be here: app.UseMvc(configureRoutes => { configureRoutes.MapRoute("Default", "{controller=App}/{action=Index}/{ ...
Read more >Tune Routing Behavior - Digital Assistant - Oracle Help Center
You can also customize the default welcome prompt using the Skill Bot Welcome Prompt configuration setting. Help State: Applies when the intent engine ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
for anyone stumbling upon this too before the new release has been made. i have found the easiest way to send cloud events is with the cloud events package. (https://github.com/cloudevents/sdk-javascript#emitting-events)
Till the next release, you can point to the GitHub project directly -
See https://docs.npmjs.com/cli/v9/configuring-npm/package-json#github-urls, you can also consider using a commit hash.