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

Restore messages per client/subscription #2000

Closed
vaLP2eh opened this issue May 17, 2024 · 2 comments
Closed

Restore messages per client/subscription #2000

vaLP2eh opened this issue May 17, 2024 · 2 comments
Labels
question It is a question regarding the project

Comments

@vaLP2eh
Copy link

vaLP2eh commented May 17, 2024

Describe your question

I would like to use MQTTnet to track logging information. Each of my services shall send its logging information to an individual topic. Each message shall be written to a database/cache to have them available for later. The database/cache will be trimmed to get rid of old information.

The thing with writing all messages to a database/cache seems to be easy. But this is my requirement:

When a client subscribes to a topic,, the client should be able to specify in the user properties how far back in history the subscription should "look", i.e. 24h, 7d, ...

How to restore/resend messages for a specific client/subscription?

I read all questions (open/close) of this issue tracker and the wiki and samples, but could not find something that matches my requirements.

Which project is your question related to?

  • Client
  • Server
@vaLP2eh vaLP2eh added the question It is a question regarding the project label May 17, 2024
@xyderos
Copy link

xyderos commented May 27, 2024

I think this is more of a "broker specific" question as most of the brokers just allow the messages to pass through them. In a more general context, you would need to have a QoS of at least 1 or 2, not having set the clear flag and have some sort of TTL in place which I am not sure mqtt supports that.

A "dirty approach" would be to subscribe to the db/logging whatever service to a topic that would essentially ping you when there is an update and you would execute a request/response scheme.

                  |          SUBSCRIBE TO "NOTIFIER"                   |
                  |------------------------------------------------------------>|
                  |         RECEIVED EVENT "NOTIFIER"                |
Consumer|<------------------------------------------------------------|Producer
                  |QUERY THE DB WITH A PUBLISH MESSAGE|
                  |------------------------------------------------------------>|
                  |RECEIVE RESPONSE IN A DIFFERENT TOPIC|
                  |<------------------------------------------------------------|

But are you sure MQTT is the right way to solve the problem?

@vaLP2eh
Copy link
Author

vaLP2eh commented May 27, 2024

Yes, MQTT is the right way to go for the use case I work on.

I read more in the source code to get a better understanding. It's a pity that there is no documentation for IntelliSense provided by this project. Makes the API difficult to understand. Anyway...

My plan is to use the intercept-subscribe to restore the messages (if needed/requested) for the calling client and the intercept-unsubscribe/-disconnected to cleanup if needed. Should work fine.

@vaLP2eh vaLP2eh closed this as completed May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question It is a question regarding the project
Projects
None yet
Development

No branches or pull requests

2 participants