Tabnine Logo
CommandSubscription
Code IndexAdd Tabnine to your IDE (free)

How to use
CommandSubscription
in
org.eclipse.hono.client

Best Java code snippets using org.eclipse.hono.client.CommandSubscription (Showing top 5 results out of 315)

origin: org.eclipse.hono/hono-client

/**
 * Creates a command subscription object for the given topic. When the authenticated device is given
 * it is used to either check given tenant and device-id from topic or fill this
 * fields if not given.
 *
 * @param topic The topic to subscribe for commands.
 * @param authenticatedDevice The authenticated device or {@code null}.
 * @return The CommandSubscription object or {@code null} if the topic does not match the rules.
 * @throws NullPointerException if topic is {@code null}.
 */
public static CommandSubscription fromTopic(final String topic, final Device authenticatedDevice) {
  try {
    return new CommandSubscription(topic, authenticatedDevice);
  } catch (final IllegalArgumentException e) {
    LOG.debug(e.getMessage());
    return null;
  }
}
origin: org.eclipse.hono/hono-adapter-mqtt-vertx-base

String tenantId = subscription.getTenant();
String deviceId = subscription.getDeviceId();
if (subscription.isAuthenticated()) {
final String topic = String.format("%s/%s/%s/%s/%s/%s", subscription.getEndpoint(), tenantId, deviceId,
    subscription.getRequestPart(), commandRequestId, command.getName());
endpoint.publish(topic, command.getPayload(), qos, false, false);
metrics.incrementCommandDeliveredToDevice(subscription.getTenant());
LOG.trace("command published to device [tenant-id: {}, device-id: {}, MQTT client-id: {}]",
    subscription.getTenant(), subscription.getDeviceId(), endpoint.clientIdentifier());
final Map<String, String> items = new HashMap<>(3);
items.put(Fields.EVENT, "command published to device");
origin: org.eclipse.hono/hono-adapter-mqtt-vertx-base

final CommandSubscription cmdSub = CommandSubscription.fromTopic(subscription.topicName(), authenticatedDevice);
if (cmdSub == null) {
  span.log(String.format("ignoring unsupported topic filter [%s]", subscription.topicName()));
      sendDisconnectedTtdEvent(cmdSub.getTenant(), cmdSub.getDeviceId(), authenticatedDevice, null)
      .setHandler(sendAttempt -> {
        consumer.close(null);
    span.log(items);
    LOG.debug("created subscription [tenant: {}, device: {}, filter: {}, requested QoS: {}, granted QoS: {}]",
        cmdSub.getTenant(), cmdSub.getDeviceId(), subscription.topicName(),
        subscription.qualityOfService(), MqttQoS.AT_MOST_ONCE);
    return cmdSub;
    TracingHelper.logError(span, items);
    LOG.debug("cannot create subscription [tenant: {}, device: {}, filter: {}, requested QoS: {}]",
        cmdSub.getTenant(), cmdSub.getDeviceId(), subscription.topicName(),
        subscription.qualityOfService(), t);
    return Future.failedFuture(t);
if (f.succeeded() && f.result() instanceof CommandSubscription) {
  final CommandSubscription s = (CommandSubscription) f.result();
  sendConnectedTtdEvent(s.getTenant(), s.getDeviceId(), authenticatedDevice, span.context());
origin: org.eclipse.hono/hono-adapter-mqtt-vertx-base

private Future<MessageConsumer> createCommandConsumer(final MqttEndpoint mqttEndpoint, final CommandSubscription sub) {
  // if a device does not specify a keep alive in its CONNECT packet then
  // the default value of the CommandConnection will be used
  final long livenessCheckInterval = mqttEndpoint.keepAliveTimeSeconds() * 1000 / 2;
  return getCommandConnection().createCommandConsumer(
      sub.getTenant(),
      sub.getDeviceId(),
      commandContext -> {
        Tags.COMPONENT.set(commandContext.getCurrentSpan(), getTypeName());
        final Command command = commandContext.getCommand();
        if (command.isValid()) {
          onCommandReceived(mqttEndpoint, sub, commandContext);
        } else {
          // issue credit so that application(s) can send the next command
          commandContext.reject(new ErrorCondition(Constants.AMQP_BAD_REQUEST, "malformed command message"), 1);
        }
      },
      remoteClose -> {},
      livenessCheckInterval);
}
origin: org.eclipse.hono/hono-adapter-mqtt-vertx-base

final CommandSubscription cmdSub = CommandSubscription.fromTopic(topic, authenticatedDevice);
if (cmdSub == null) {
  final Map<String, Object> items = new HashMap<>(2);
  LOG.debug("ignoring unsubscribe request for unsupported topic filter [{}]", topic);
} else {
  final String tenantId = cmdSub.getTenant();
  final String deviceId = cmdSub.getDeviceId();
  final Map<String, Object> items = new HashMap<>(2);
  items.put(Fields.EVENT, "unsubscribing device from topic");
org.eclipse.hono.clientCommandSubscription

Javadoc

The MQTT subscription of devices, to get commands.

Format of subscription need to be: control|c/+|TENANT/+|DEVICE_ID/req|q/# - e.g.:

  1. control/+/+/req/# - authenticated device and verbose format
  2. c/+/+/q/# - authenticated device with short format
  3. control/DEFAULT_TENANT/4711/req/# unauthenticated device with verbose format

Most used methods

  • <init>
  • fromTopic
    Creates a command subscription object for the given topic. When the authenticated device is given it
  • getDeviceId
    Gets the device id from topic or authentication.
  • getEndpoint
    Gets the endpoint of the subscription.
  • getRequestPart
    Gets the request part of the subscription.
  • getTenant
    Gets the tenant from topic or authentication .
  • isAuthenticated
    Gets the authentication status, which indicates the need to publish on tenant/device-id for unauthen

Popular in Java

  • Start an intent from android
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • runOnUiThread (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Permission (java.security)
    Legacy security code; do not use.
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now