Searching...

Matching results

    How to use the Google Pub Sub Connector

    Integrate and extend your AirVantage platform

    Here we give you an overview of 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.

    We’ll explain all the technical aspects needed for a robust, secure & 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

    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, …)

    Parameters

    When you connect Airvantage to the Google Cloud platform, you have to define the notification you want: operations, data, alert.

    Reliability

    If the message is not acknowledged by the receiver, Airvantage will 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 in order to supply the correct information and thus enable the end point on the Airvantage side.

    What can I use?

    How do I configure my client?

    Prerequisites

    Set up a Google Console Project, activate the Pub/Sub API on the Google Cloud platform, and create a topic as explained here .

    Configuration

    Cconfiguration is processed in 2 steps: give permissions to AirVantage to access to your Google Pub/Sub topic, then declare this topic in AirVantage so that it can push your messages (data, alert, …).

    Process these 2 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: 231589913618-ocock8n1cn701l5qidb5lg87bjkjc0j8@developer.gserviceaccount.com. Thus, 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.

    • Kind of messages you want to receive:

      • Alert event: any alert rule triggered will be send
      • Operation: any operation state will be sent (creation, progress, success or failed)
      • Usages: any SIM usage
      • New message sent by the device: any device incoming communication
        • Optionnaly you can supply the data path to whitelist the data (only the values for these data will be sent in the data stream). To get the data path for a data, you can go to the timeline to view the data path in the tooltip like 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

    First of all, you have to install the Cloud SDK and authenticate gcloud with the Google Cloud Platform:

            gcloud init
    

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

            gcloud components install alpha
    

    and you can 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, and if you haven’t chosen the auto-acknowledgement option, you have to acknowledge it. If a received message is not acknowledged, Airvantage will 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, you need to check your configuration in the Google console.

    Get the messages

    This section explains how to consume messages from the Google Cloud platform in order 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 Google Cloud Pub/Sub topic and to pull messages.

    Installation

    Clone it using git 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:

    • a configuration file to edit (see next section)
    • a PubSubClient which handles the topic
    • the main application which 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 by one call

    Robustness

    This application is robust . It retries automatically, with an exponential strategy, upon RPC (remote procedure call) failures.

    How to run

    The configuration file config.properties has to be adapted.

    Enjoy !

    Samples

    TOP