INVERS CloudConnect sharing vehicle connector header

Vehicle Messages

Get notified about changes of connected vehicles.

API Reference

Inspect Vehicle Messages API reference.

Consume messages

Learn how to consume messages and get started!

Quick Start: Consume Vehicle State messages (C#)

Follow instructions and have your configuration data ready (user, password, …).

The following example shows how to connect to your the RabbitMQ broker and consume messages. The C# example uses the RabbitMq.Client library.

  using System;
  using System.Text.Json;
  using RabbitMQ.Client;
  using RabbitMQ.Client.Events;
  ​
  namespace ReceiveInformation
  {
    class Program
    {
      static void Main(string[] args)
      {
        Console.WriteLine("Consuming... Press any key to exit.");
​
        string queueName = "VehicleState_v1-descriminator";
        ConnectionFactory factory = new ConnectionFactory();
        factory.Uri =
          new Uri("amqps://username:passw@api.invers.com:5671/vhost");
        IConnection conn = factory.CreateConnection();
        IModel channel = conn.CreateModel();
        var consumer = new EventingBasicConsumer(channel);
        consumer.Received += (ch, ea) =>
        {
          try
          {
            var body = ea.Body.ToArray();
            var message = System.Text.Encoding.UTF8.GetString(body);
            Console.WriteLine(BeautifyJson(message));
          }
          catch (Exception e)
          {
            Console.WriteLine(e);
          }
          channel.BasicAck(ea.DeliveryTag, false);
        };
​
        // Start consuming (consumer tag identifies the subscription
        // when it has to be cancelled)
        String consumerTag =
          channel.BasicConsume(queueName, false, consumer);
​
        Console.ReadKey();
      }
​
      public static string BeautifyJson(string json)
      {
        var options = new JsonSerializerOptions()
        {
          WriteIndented = true
        };
​
        var jsonElement = JsonSerializer.Deserialize(json);
​
        return JsonSerializer.Serialize(jsonElement, options);
      }
    }
  }