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

feat(command): command request from external MQTT to internal MessageBus #4153

Merged
merged 3 commits into from
Sep 21, 2022
Merged

Conversation

chr1shung
Copy link

core-command subscribes to 3rd-party command requests and publishes to the appropriate device service via messaging

Signed-off-by: Chris Hung [email protected]

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:

  • I am not introducing a breaking change (if you are, flag in conventional commit message with BREAKING CHANGE: describing the break)
  • I am not introducing a new dependency (add notes below if you are)
  • I have added unit tests for the new feature or bug fix (if not, why?)
  • I have fully tested (add details below) this the new feature or bug fix (if not, why?)
  • I have opened a PR for the related docs change (if not, why?)

Testing Instructions

  1. Run core-command from this branch with external MQTT broker and MESSAGEQUEUE_REQUIRED=true environment variable
  2. Run PSUBSCRIBE edgex.command.request.* in redis container to subscribe to the forwarded request
  3. send command request to edgex/command/request/<device>/<command>/<method> topic. For example send following message to edgex/command/request/Random-Boolean-Device/Bool/get`:
{
  "CorrelationID": "14a42ea6-c394-41c3-8bcd-a29b9f5e6835",
  "ApiVersion": "v2",
  "RequestId": "e6e8a2f4-eb14-4649-9e2b-175247911369",
  "ContentType": "application/json",
  "QueryParams": {
    "ds-pushevent":"yes",
    "ds-returnevent":"yes"
  }
}
  1. check the message is received by redis container:
/data # redis-cli
127.0.0.1:6379> PSUBSCRIBE edgex.command.request.*
Reading messages... (press Ctrl-C to quit)
1) "psubscribe"
2) "edgex.command.request.*"
3) (integer) 1
1) "pmessage"
2) "edgex.command.request.*"
3) "edgex.command.request.device-virtual.Random-Boolean-Device.Bool.get"
4) "{\"ReceivedTopic\":\"\",\"CorrelationID\":\"14a42ea6-c394-41c3-8bcd-a29b9f5e6835\",\"ApiVersion\":\"v2\",\"RequestID\":\"e6e8a2f4-eb14-4649-9e2b-175247911369\",\"ErrorCode\":0,\"Payload\":null,\"ContentType\":\"application/json\",\"QueryParams\":{\"ds-pushevent\":\"yes\",\"ds-returnevent\":\"yes\"}}"

New Dependency Instructions (If applicable)

core-command subscribes to 3rd-party command requests and publishes
to the appropriate device service via messaging

Signed-off-by: Chris Hung <[email protected]>
@codecov-commenter
Copy link

Codecov Report

Merging #4153 (d5dd3c2) into main (a0e04e5) will increase coverage by 0.04%.
The diff coverage is 54.54%.

@@            Coverage Diff             @@
##             main    #4153      +/-   ##
==========================================
+ Coverage   43.85%   43.90%   +0.04%     
==========================================
  Files         123      123              
  Lines       10899    10954      +55     
==========================================
+ Hits         4780     4809      +29     
- Misses       5710     5730      +20     
- Partials      409      415       +6     
Impacted Files Coverage Δ
.../command/controller/messaging/external/external.go 60.76% <54.54%> (-5.90%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look good, once we decide how to handle the errorResponse when we don't have the data to send it properly.

1. failed to JSON decoding request MessageEnvelope
2. invalid request topic scheme
3. invalid request command method

Signed-off-by: Chris Hung <[email protected]>
@lenny-goodell
Copy link
Member

LGTM, once on minor change above is completed.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@lenny-goodell lenny-goodell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

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

Successfully merging this pull request may close these issues.

4 participants