com.amazon.kepler.experimental_mr33.messaging) in the Vega SDK which offers a message passing communication mechanism.
You can use Vega Messaging in a variety of ways, such as launching apps, publishing system changes using broadcasts, and inter-app communication. In contrast to procedure calls, message-oriented communication decouples the execution of the sender and the recipient, so they don’t have to be running at the same time. This is accomplished through the use of a centralized broker service called the Message Router.
This mechanism is also a foundation for deferred execution using the Vega Tasks Library (com.amazon.kepler.tasks).
Message Definition and Security
The key concept is that messages are treated as API contracts between the sender and receiver. The message URI, the type of attachment, the sender, and receiver privileges together are a contract that both parties must adhere to for the communication to be successful. Unilateral changes to the message constitute API breakage, leading to delivery or interpretation issues. To maintain message contract integrity, a message definition must be static, where the contract is specified upfront. Both system services and apps can define new messages as explained below. Existing Vega Modules are used for versioning and dependency specification for messages. Vega Modules are the Vega SDK’s mechanism for expressing contracts and expressing dependencies upon them. For more information about modules, see the modules documentation in the manifest offers, wants, and needs documentation.Author Messages
Follow these steps to author messages:- Define a module.
- Define messages that are part of it.
- Define privileges for using the message at runtime.
[[message]] blocks as needed. Specify the URI of the message without query params. Include fragments only when defining legacy URIs (discouraged). Skip adding [[message]] section for pkg:// scheme URIs that are not used outside the vpkg. For more information, see Message Addressing Schemes.
com.amazon.security.example1 privilege and receivers that have the com.amazon.security.example2 privilege you define your message as follows.
* or self instead of specific privilege strings:
- Use
*if you want to allow anyone to use the message. - Use
selfif you want only the vpkg your module is part of to use the message.
sender-privileges and receiver-privileges
independently.
Use Messages
Add Module Dependency Note: The following sections don’t apply if the messages were defined within your own vpkg. To use the message in a different vpkg, add the following manifest specification. Use the syntax uniformly as a message senders or a receiver. The module is the unit of dependency specification. When depending on a module, you can use all messages defined by the module.needs syntax is a stronger form of dependency specification that requires your dependencies to
exist before your app can be installed on the device. Refer to the app manifest user guide
for more details.
Request Privilege
Unless the message of interest has a self or * include the following section to request the
necessary privileges. The following snippet shows how you would to specify that your app wants the privilege to use the
testSendPriv.main message defined in /com.amazon.samplepkg.module@IMod1.
needs syntax is a stronger specification than the wants syntax. For more information on needs, see Needs.
Map Messages to Launch Component
Launch every lifecycle component by name by using thepkg:// scheme followed by the name of the component to launch. However, as noted in the message addressing document, there are other URI schemes that do not directly identify the component to launch. In such circumstances, specify additional information in the manifest in the offers.message-target section.
Debugging FAQs
Why are my messages not being received even though I registered a filter?
Why are my messages not being received even though I registered a filter?
Even when channel is alive, why are my messages are not being received?
Even when channel is alive, why are my messages are not being received?
vmsgr listen
command allows developers to confirm if a message is being sent. Run this CLI from the root shell or
the non root shell.How do I verify message access controls are set up correctly?
How do I verify message access controls are set up correctly?
-
Before side loading your app run
vpt validateon the development machine. Static analysis checks are built intovpt validatecommand that can assist developers when they are trying to migrate from the old launch configuration syntax to the new one described in this document. Address both warnings and errors. See Migration Errors for specific error strings and corrective actions. Amazon will make additional static checks available over time to better assist your app development journey and to shorten the time to market of your apps. See Use Vega Packaging Tool for Vega App Packages. -
Access controls will be turned on in a future release to provide app developers the
time to configure their manifests appropriately. However, you can certify that your app is
compliant by turning on enforcement locally for your app. Use
vmsgr enforce-securityto turn on enforcement. See Test With Access Controls for details on how to detect violations from the logs. Once you detect the violations, you can use feature documentation to identify the right snippets to add to your manifest. If you are unsure why a certain error is printing you can also identify the missing module using the next tip. -
The static checks described in item 1, will only ensure that the old and the new syntax are
consistent. However, if you make the same mistake in both sections (e.g. you requested the wrong
privilege) or when integrating a brand new functionality which did not exist previously, then the
vmsgr check-accesscommand can be used on the device as a further confirmation that message access controls are configured correctly. Developers can use this CLI in the development cycle, to detect errors in the manifest. The CLI can also be used to debug issues discovered in QA. See Verify Access Controls for details on how to use this CLI.
Migration Errors
Use the following examples to interpret the warnings/errors. This step will also ensure that there is no inconsistencies between programmatic launching of your app and when using the CLI.Missing[[message]] section[[offers.message-target]] section[[offers.message-target]]Test With Access Controls
Theenforce-security CLI configures the system to locally turn on enforcement for a specific
package. After turning on, run through various app usage scenarios to detect what breaks. Collect
device logs and filter out the error string listed below and take the appropriate action described.
Note that the setting is automatically cleared on reboot. Run the command again to reapply after
reboot.Usage:package-id is a package ID of sender or receiver.For example:- missing
[[wants.module]]section:
[[wants.module]] entry to
the manifest.- missing
[[wants.privilege]]section:
[[wants.privilege]] entry in the manifest and additionally request user
to grant the privilege if it is a runtime privilege. Check feature
documentation for the feature that requires a runtime privilege.- missing
[[offers.message-target]]section:
[[offers.message-target]]
entry for this URI and designate a lifecycle component to be launched in response. If unsure if the
error is relevant to your app, please reach out to Amazon.- missing message definition:
Verify Access Controls
Thecheck-access CLI verifies if the app passes module and privileges checks and prints an informative output on the shell. As an example if your package ID is
com.amazon.messaging.mr33.okidl.ac.example1 and you are interested in receiving the URI, pkg://com.amazon.messaging.mr33.okidl.ac.example2.explicit_privileges, you can use the CLI command as follows.Usage:pkg_id is a package ID of sender or receiver and uri is the URI to test access control.Example:[[wants.module]] but lacks the right privilege to receive
the message. This can be because of a missing [[wants.privilege]]. Add it if missing. If you have
the right manifest entry and have confirmed that there are no typos, then the privilege check fails
if the privilege needs user consent which has not been granted yet.
