Searching...

Matching results

    How to use the Google Pub Sub Connector

    Integrate and extend your AirVantage platform

    This overview describes what you can do with the AirVantage Cloud Connector via a simple use case: Connecting your system to Google Cloud Pub/Sub and getting raw data from your Google topic.

    This topic covers all of the technical aspects needed for a robust, secure, and reliable interface:

    • principles & best practices
    • configuration & authentication
    • how to get messages

    Principles

    This section explains when and why you should use the Cloud connector, what it is and the available options.

    Introduction

    The following are key features of the Google Cloud Connector:

    • Notifications of new messages from AirVantage.
    • A routing mechanism.
    • Robust messaging for applications.
    • Support for high volume messaging.
    • Runs on all major operating systems.
    • Open source libraries for several common languages (java, c#, python, PHP, etc.).

    Parameters

    When you connect AirVantage to the Google Cloud platform, you have to define which notifications you want to receive:

    • Operations
    • Data
    • Alerts

    Reliability

    If the message is not acknowledged by the receiver, AirVantage will try to deliver it again until the message is acknowledged.

    Configuration

    This section explains how to configure your client to be robust, reliable, and secure. Please read this section carefully and supply the correct information to enable the endpoint on the AirVantage side.

    Which SDK do I use?

    How do I configure my client?

    Prerequisites

    Ensure you have the following prerequisites

    • Set up a Google Console Project.
    • Activate the Pub/Sub API on the Google Cloud platform.
    • Create a topic as explained here .

    Configuration

    Configuration is performed in two steps:

    • Give permissions to AirVantage to access to your Google Pub/Sub topic.
    • Declare the topic in AirVantage so that it can push your messages (data, alert, …).

    Perform these two steps to activate this feature with your application:

    • Step 1: Create your Pub/Sub topic and authorize Sierra Wireless to access to your topic by using Identity & Access Management on the Google Cloud Platform. You have to use the Sierra Wireless Google Account ID: production@airvantage-pub-sub.iam.gserviceaccount.com. No password is supplied to Sierra Wireless.

    • Step2: Supply the following information using the CRM and select Request Support:

    • Company Name on AirVantage.

    • Google Developers Console Project ID which is the project ID automatically generated when you create your project in Google Cloud Platform.

    • Name of the topic When the ticket is resolved, you will be able to receive messages in your Google Pub/Sub topic. You just need to subscribe to your Google topic.

    • The type of messages you want to receive:

      • Alert event: Any alert rule triggered.
      • Operation: Any operation state (creation, progress, success or failed).
      • Usages: SIM usage.
      • New message sent by the device: Any incoming device communication.
        • (Optional) You can supply the data path to whitelist (I.e., only the values for this data will be sent in the data stream). To get the path for data, navigate to the timeline to view the data path in the tooltip as shown in the screenshot below:

    Not to be confused with the project name, the project ID is a unique identifier for your project.

    Test your setup

    Install the Cloud SDK and authenticate gcloud with the Google Cloud Platform:

            gcloud init
    

    To consume a message, install the Cloud SDK alpha command component:

            gcloud components install alpha
    

    Execute the gcloud command in a terminal window, providing the Google Developers Console Project ID and the subscription name. By default, only one message will be read on the topic. But you can set a higher number of messages that Cloud Pub/Sub can return.

            gcloud alpha pubsub subscriptions pull --max-messages{max_messages} projects/{project Id}/subscriptions/{MySub}
    

    When you receive a message you have to acknowledge it, if you haven’t chosen the auto-acknowledgement option. If a received message is not acknowledged, AirVantage will try to send it again until your application acknowledges it.

            gcloud alpha pubsub subscriptions ack subscription {MySub} {ACKID [ACKID ...]}  
    

    If you now receive a message, your setup is complete. If not, check your configuration in the Google console.

    Get the messages

    This section explains how to consume messages from the Google Cloud platform to support high-volume messaging.

    Using Google API Client Libraries

    GooglePubSubConnector : This Google Cloud Java application uses the Google API Client Library to connect to the Google Cloud Pub/Sub topic and pull messages.

    Installation

    Use Git to clone it from the repository.

    You can use Eclipse to edit the files (as an Eclipse project is supplied), but it is not mandatory.

    The source project is organized with three main files:

    • Configuration file to edit (see next section).
    • PubSubClient which handles the topic.
    • Main application that connects to the topic, subscribes, consumes messages, and displays them on the console.

    Configuration

    In the configuration file config.properties, you have to specify:

    • Google Developers Console Project ID
    • Subscription name
    • Maximum number of messages returned per call

    Robustness

    This application is robust . Upon RPC (remote procedure call) failures, it retries automatically, using an exponential re-try strategy.

    How to run

    The configuration file config.properties has to be adapted.

    Enjoy !

    Samples

    TOP