feat(command): publish device service response to external MQTT#4166
Merged
cloudxxx8 merged 3 commits intoedgexfoundry:mainfrom Oct 3, 2022
chr1shung:issue-4076
Merged
feat(command): publish device service response to external MQTT#4166cloudxxx8 merged 3 commits intoedgexfoundry:mainfrom chr1shung:issue-4076
cloudxxx8 merged 3 commits intoedgexfoundry:mainfrom
chr1shung:issue-4076
Conversation
Signed-off-by: Chris Hung <chris@iotechsys.com>
lenny-goodell
requested changes
Sep 26, 2022
Member
lenny-goodell
left a comment
There was a problem hiding this comment.
Looks good, just small name tweak for clarification
subscribe to device command response from device service via internal message bus and publish response back to 3rd-party requester Signed-off-by: Chris Hung <chris@iotechsys.com>
cloudxxx8
reviewed
Sep 27, 2022
lenny-goodell
requested changes
Sep 28, 2022
| Set(string, string) | ||
| } | ||
|
|
||
| func NewMessagingRouter() MessagingRouter { |
Member
There was a problem hiding this comment.
How is this Router determining which bus the response message goes to?
Author
There was a problem hiding this comment.
My bad I forgot the most cirtical problem ...
A quick thought came to my mind is to maintain 2 maps internally :
func (r *MessagingRouter) Get(id string) (string, bool) {
topic, ok := r.ExternalMap[id]
if ok {
return topic, true
}
topic, _ = r.InternalMap[id]
return topic, false
}
func (r *MessagingRouter) Set(id string, topic string, source string) {
switch source {
case "internal":
r.InternalMap[id] = topic
case "external":
r.ExternalMap[id] = topic
}
}Will try to improve it or find if there's better solution tomorrow ...
Member
There was a problem hiding this comment.
Yes, that was what I had in mind.
lenny-goodell
previously approved these changes
Sep 29, 2022
cloudxxx8
requested changes
Sep 30, 2022
Save active requests in two maps using requestId as keys. This allows command service to know where to route the response (to external MQTT or internal MessageBus) Signed-off-by: Chris Hung <chris@iotechsys.com>
|
Kudos, SonarCloud Quality Gate passed! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.








fix #4076
If your build fails due to your commit message not passing the build checks, please review the guidelines here: https://github.com/edgexfoundry/edgex-go/blob/main/.github/Contributing.md
PR Checklist
Please check if your PR fulfills the following requirements:
BREAKING CHANGE:describing the break)Testing Instructions
MESSAGEQUEUE_REQUIRED=trueenvironment variableedgex/command/request/<device-name>/<command-name>/<method>topic. For example send following request toedgex/command/Simple-Device01/Xrotation/get:{ "CorrelationID": "14a42ea6-c394-41c3-8bcd-a29b9f5e6835", "ApiVersion": "v2", "RequestId": "e6e8a2f4-eb14-4649-9e2b-175247911369", "ContentType": "application/json", "QueryParams": { "ds-pushevent": "no", "ds-returnevent": "yes" }, }edgex/command/response/<device-name>/<command-name>/<method>topic:New Dependency Instructions (If applicable)