Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wildcard Topics #401

Open
emramir opened this issue Mar 14, 2023 · 15 comments
Open

Wildcard Topics #401

emramir opened this issue Mar 14, 2023 · 15 comments

Comments

@emramir
Copy link

emramir commented Mar 14, 2023

Hello, good morning, I wanted to know how I can use wildcard with this library since I don't see anything in the documentation, I've tried several variants of code and I can't solve it.
The idea is to be able to send a message to a topic with a wildcard and for this message to be forwarded to all topics with the same wildcard pattern, example:
Wildcard: topic.*
It would have to send the message to all the topics that have that pattern topic1, topic2, etc.

@grs
Copy link
Member

grs commented Mar 14, 2023

That will depend on the broker you are using.

@emramir
Copy link
Author

emramir commented Mar 14, 2023

I am using AMQ7 Red Hat Broker

@grs
Copy link
Member

grs commented Mar 14, 2023

Use something like 'topic://topic.*' as the source address when creating a subscriber.

@emramir
Copy link
Author

emramir commented Mar 14, 2023

I tried what you told me and I had no luck, this is how the code stays, you think something is missing, make a clarification, I need the messages to be persistent, that's why I add the durable and the shared one because it is in a scalable environment
var containerClient = rhea.create_container({ id: "deploy1" });
containerClient.on("message", function (context: any) {
console.log(Message received: ${context.message.body.message});
});
var conn2 = containerClient.connect({
host: environment.TOPICS_HOST,
port: environment.TOPICS_PORT
});
var receiver_opts = {
source: {
address: "topic://topic.*",
durable: 2,
expiry_policy: "never",
capabilities: ["topic", "shared", "global"]
}, name: "deploy1"
}

conn2. open_receiver(receiver_opts);

@grs
Copy link
Member

grs commented Mar 14, 2023

In what way is it not working as you expect?

@emramir
Copy link
Author

emramir commented Mar 14, 2023

I send the publisher and the subscribers do not receive the message,
I have the publisher configured like this:
var topic=topic://topic
var container = rhea.create_container();
container.on("sendable", function (event: any) {
const message = {
body: { message: "prueba" },
};
const msg = event.sender.send(message);
console.log(msg.id)

});
var conn = container.connect({
    host: environment.TOPICS_HOST,
    port: environment.TOPICS_PORT
});

conn. open_sender(topic);

@grs
Copy link
Member

grs commented Mar 14, 2023

What if you set topic to topic://topic.foo

@emramir
Copy link
Author

emramir commented Mar 14, 2023

in the publisher or in the subscriber, you decide to put that

@grs
Copy link
Member

grs commented Mar 14, 2023

In the publisher

@grs
Copy link
Member

grs commented Mar 14, 2023

i.e. topic.* matches topic.foo or topic.bar but not topic (topic.# would match all three)

@emramir
Copy link
Author

emramir commented Mar 15, 2023

I put in the publisher topic://topic.foo I sent the message and no subscriber received it and both subscribers had topic topic://topic.*

@emramir
Copy link
Author

emramir commented Mar 15, 2023

It will be that I have to configure something in the amq red hat

@grs
Copy link
Member

grs commented Mar 15, 2023

@emramir
Copy link
Author

emramir commented Mar 15, 2023

I tried and it worked, my question is the following: if I change the topic of the example in the publisher to topic://PRICE.STOCK.*
and in the subscriber by topic://PRICE.STOCK.NYSE
I should receive a message, right?

@grs
Copy link
Member

grs commented Mar 15, 2023

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants