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

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

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

origin: org.eclipse.hono/hono-adapter-http-vertx-base

private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) {
  if (commandContext == null) {
    response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED);
  } else {
    final Command command = commandContext.getCommand();
    response.putHeader(Constants.HEADER_COMMAND, command.getName());
    currentSpan.setTag(Constants.HEADER_COMMAND, command.getName());
    LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]",
        command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId());
    if (!command.isOneWay()) {
      response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId());
      currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId());
    }
    response.setStatusCode(HttpURLConnection.HTTP_OK);
    HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType());
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the request identifier of this command.
 *
 * @return The identifier.
 * @throws IllegalStateException if this command is invalid.
 */
public String getRequestId() {
  if (isValid()) {
    return requestId;
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

  @Override
  public String toString() {
    if (valid) {
      return String.format("Command [name: %s, tenant-id: %s, device-id %s, request-id: %s]",
          getName(), getTenant(), getDeviceId(), getRequestId());
    } else {
      return "Invalid Command";
    }
  }
}
origin: org.eclipse.hono/hono-adapter-mqtt-vertx-base

final String commandRequestId = (command.isOneWay() ? "" : command.getRequestId());
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: {}]",
origin: org.eclipse.hono/hono-client

(delivery, msg) -> {
  final Command command = Command.from(msg, tenantId, deviceId);
  if (command.isValid()) {
    TracingHelper.TAG_CORRELATION_ID.set(currentSpan, command.getCorrelationId());
    items.put("reply-to", command.getCommandMessage().getReplyTo());
    items.put("name", command.getName());
    items.put("content-type", command.getContentType());
origin: eclipse/hono

final Message msg = command.getCommandMessage();
if (msg.getCorrelationId() == null) {
  if (delivery.remotelySettled()) {
    if (Accepted.class.isInstance(remoteState)) {
      LOG.trace("device accepted command message [command: {}]", command.getName());
      logItems.put(Fields.EVENT, "device accepted command");
      commandContext.getCurrentSpan().log(logItems);
    } else if (Rejected.class.isInstance(remoteState)) {
      final ErrorCondition error = ((Rejected) remoteState).getError();
      LOG.debug("device rejected command message [command: {}, error: {}]", command.getName(), error);
      logItems.put(Fields.EVENT, "device rejected command");
      commandContext.getCurrentSpan().log(logItems);
      commandContext.reject(error, 1);
    } else if (Released.class.isInstance(remoteState)) {
      LOG.debug("device released command message [command: {}]", command.getName());
      logItems.put(Fields.EVENT, "device released command");
      commandContext.getCurrentSpan().log(logItems);
    LOG.debug("device did not settle command message [command: {}, remote state: {}]", command.getName(),
        remoteState.getClass().getSimpleName());
    logItems.put(Fields.EVENT, "device did not settle command");
origin: org.eclipse.hono/hono-client

private Command(
    final boolean valid,
    final Message message,
    final String tenantId,
    final String deviceId,
    final String correlationId,
    final String replyToId) {
  this.valid = valid;
  this.message = message;
  this.tenantId = tenantId;
  this.deviceId = deviceId;
  this.correlationId = correlationId;
  this.replyToId = replyToId;
  this.requestId = getRequestId(correlationId, replyToId, deviceId);
}
origin: eclipse/hono

final String commandRequestId = (command.isOneWay() ? "" : command.getRequestId());
final String topic = String.format("%s/%s/%s/%s/%s/%s", subscription.getEndpoint(), tenantId, deviceId,
    subscription.getRequestPart(), commandRequestId, command.getName());
LOG.debug("Publishing command to device [tenant-id: {}, device-id: {}, MQTT client-id: {}, QoS: {}]",
    subscription.getTenant(), subscription.getDeviceId(), subscription.getClientId(),
commandContext.getCurrentSpan().log(items);
endpoint.publish(topic, command.getPayload(), subscription.getQos(), false, false, sentHandler -> {
  if (sentHandler.succeeded()) {
    if (MqttQoS.AT_LEAST_ONCE.equals(subscription.getQos())) {
origin: eclipse/hono

private void setResponsePayload(final HttpServerResponse response, final CommandContext commandContext, final Span currentSpan) {
  if (commandContext == null) {
    response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED);
  } else {
    final Command command = commandContext.getCommand();
    response.putHeader(Constants.HEADER_COMMAND, command.getName());
    currentSpan.setTag(Constants.HEADER_COMMAND, command.getName());
    LOG.trace("adding command [name: {}, request-id: {}] to response for device [tenant-id: {}, device-id: {}]",
        command.getName(), command.getRequestId(), command.getTenant(), command.getDeviceId());
    if (!command.isOneWay()) {
      response.putHeader(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId());
      currentSpan.setTag(Constants.HEADER_COMMAND_REQUEST_ID, command.getRequestId());
    }
    response.setStatusCode(HttpURLConnection.HTTP_OK);
    HttpUtils.setResponseBody(response, command.getPayload(), command.getContentType());
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets this command's reply-to-id.
 *
 * @return The identifier.
 * @throws IllegalStateException if this command is invalid.
 */
public String getReplyToId() {
  if (isValid()) {
    return replyToId;
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the ID to use for correlating a response to this command.
 *
 * @return The identifier.
 * @throws IllegalStateException if this command is invalid.
 */
public String getCorrelationId() {
  if (isValid()) {
    return correlationId;
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the tenant that the device belongs to.
 *
 * @return The tenant identifier.
 * @throws IllegalStateException if this command is invalid.
 */
public String getTenant() {
  if (isValid()) {
    return tenantId;
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the device's identifier.
 *
 * @return The identifier.
 * @throws IllegalStateException if this command is invalid.
 */
public String getDeviceId() {
  if (isValid()) {
    return deviceId;
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the payload of this command.
 *
 * @return The message payload or {@code null} if the command message contains no payload.
 * @throws IllegalStateException if this command is invalid.
 */
public Buffer getPayload() {
  if (isValid()) {
    return MessageHelper.getPayload(message);
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the name of this command.
 *
 * @return The name.
 * @throws IllegalStateException if this command is invalid.
 */
public String getName() {
  if (isValid()) {
    return message.getSubject();
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the type of this command's payload.
 *
 * @return The content type or {@code null} if not set.
 * @throws IllegalStateException if this command is invalid.
 */
public String getContentType() {
  if (isValid()) {
    return message.getContentType();
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
origin: org.eclipse.hono/hono-client

/**
 * Gets the application properties of a message if any.
 *
 * @return The application properties.
 * @throws IllegalStateException if this command is invalid.
 */
public Map<String, Object> getApplicationProperties() {
  if (isValid()) {
    if (message.getApplicationProperties() == null) {
      return null;
    }
    return message.getApplicationProperties().getValue();
  } else {
    throw new IllegalStateException("command is invalid");
  }
}
/**
origin: org.eclipse.hono/hono-adapter-http-vertx-base

if (command.isValid()) {
  if (responseReady.isComplete()) {
origin: eclipse/hono

if (command.isValid()) {
  if (responseReady.isComplete()) {
origin: eclipse/hono

private Future<MessageConsumer> createCommandConsumer(final MqttEndpoint mqttEndpoint, final CommandSubscription sub, final CommandHandler<T> cmdHandler) {
  // 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, cmdHandler);
        } 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);
}
org.eclipse.hono.clientCommand

Javadoc

A wrapper around an AMQP 1.0 message representing a command.

Most used methods

  • getName
    Gets the name of this command.
  • isValid
    Checks if this command contains all required information.
  • getRequestId
    Creates a request ID for a command.
  • getCommandMessage
    Gets the AMQP 1.0 message representing this command.
  • getContentType
    Gets the type of this command's payload.
  • getDeviceId
    Gets the device's identifier.
  • getPayload
    Gets the payload of this command.
  • getTenant
    Gets the tenant that the device belongs to.
  • isOneWay
    Checks if this command is a one-way command (meaning there is no response expected).
  • <init>
  • from
    Creates a command for an AMQP 1.0 message that should be sent to a device. The message is expected t
  • getCorrelationId
    Gets the ID to use for correlating a response to this command.
  • from,
  • getCorrelationId

Popular in Java

  • Reading from database using SQL prepared statement
  • getSystemService (Context)
  • scheduleAtFixedRate (Timer)
  • addToBackStack (FragmentTransaction)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • ReentrantLock (java.util.concurrent.locks)
    A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor
  • BoxLayout (javax.swing)
  • IOUtils (org.apache.commons.io)
    General IO stream manipulation utilities. This class provides static utility methods for input/outpu
  • IsNull (org.hamcrest.core)
    Is the value null?
  • CodeWhisperer 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