LogoLogo
HomeSign UpGithub
  • Home
  • Release Notes
  • Getting Started
    • Create your first Test
    • Create Run Settings
    • Analyze the results
      • Job Summary
      • Logs
      • State
      • Payload
    • Look deeper with Metrics
  • Concepts
    • Workspaces
      • Role Based Access Control (RBAC)
      • Invitation Management
      • GitHub Integration
      • Deletion of Workspaces
      • System Status
    • Understanding Tests
      • Stages Management
        • Init Stage
        • Running Stage(s)
        • Finished State
      • Generating Messages
        • Scripting Environment
        • State Object
      • Response Handler
      • Preview Tests
      • Exporting/Importing Tests
        • Import OpenAPI JSON/YAML
      • Locking/Unlocking a test
    • Stateful Simulation
      • Mapping the IoT device lifecycle
    • Protocol Settings
      • MQTT
      • HTTP
      • Using other protocols
    • Run Settings
      • Network Simulation
      • Execution Strategies
      • Client Distribution
    • Scenarios
    • Glob Storage
    • Metrics
    • Mailbox
    • Licensing and Limits
    • Deployment Models
  • Additional Helpers
    • External Libraries
    • Inbuilt Libraries
    • IoTIFY Helper Functions
      • Job Functions
      • Messaging Functions
      • Glob Functions
      • Metrics Functions
      • Mailbox Functions
      • Data Generation Functions
  • platform integrations
    • AWS IoT Connector
  • Guides
    • Smart City
    • Smart Home
    • Load Testing Kafka
  • IoT Testing
    • Overview
      • Feed offline sensor data from Google Sheets to your IoT platform
    • Functional Testing
      • Basic functional test
      • Geofencing Validation
    • Performance Testing
      • MQTT end to end latency Measurement
    • Security Testing
    • Load Testing
    • Test Automation & CI/CD integration
  • API
    • Simulation API
    • Glob APIs
    • Metrics API
  • Glossary
  • Create Account
  • TEMP
    • Getting Started
      • Beginner
      • Developer
      • Tester
    • Walkthrough
    • Protocol Settings
      • CoAP
      • Raw (TCP/UDP/TLS/DTLS)
      • LWM2M
      • NONE
    • Under the hood
    • Google Sheets API
    • Azure IoT
    • Losant IoT
      • Losant Connector
      • Parking Space Management
      • Waste Management
      • Connected Truck
      • Delivery Van
    • Google Cloud IoT Core
    • IBM Cloud
      • Simple Messaging
      • IBM Bluemix: Monitoring Energy Consumption
    • Dweet.io
    • JMeter and why it fails at IoT
Powered by GitBook
On this page

Was this helpful?

  1. Additional Helpers
  2. IoTIFY Helper Functions

Mailbox Functions

The mailbox API allows us to have an internal message bus for our tests. The mailbox is a key value store in which each key can store an array of values. It acts as a Last in, first out (LIFO) stack, so the last message that was posted to the mailbox will be popped the first.

You can use the following functions to interact with the Mailbox.

POST

This function will add a new value to the specified key.

//this function takes a string key and a value of any type as arguments
mailbox.post(key, value)

mailbox.post("key1", 33)
mailbox.post("key1", "Hello World")
mailbox.post("key1", {"Hello" : "World"})

POP

This function will pop the last data that was added to the key.

//this function takes a string key as an argument
mailbox.pop(key)

mailbox.pop("key1")
mailbox.pop("key1")
Response:
{ Hello: 'World' }
Hello World

COUNT

This function gives a count of the number of values with the current key.

//this function takes a string key as an argument
mailbox.count(key)

//Example
mailbox.post("key1", 33)
mailbox.post("key1", "Hello World")

mailbox.count("key1")
Response:
2

DUMP

This function dumps all the content inside the key instead of popping the values one by one.

It returns an array with all the values.

//this function takes a string key as an argument
mailbox.dump(key)

//Example
mailbox.post("key1", 33)
mailbox.post("key1", "Hello World")

mailbox.dump("key1")
Response:
[{ Hello: 'World' }, 'Hello World']

DELETE

This function deletes all the data for the mentioned key.

//this function takes a string key as an argument
mailbox.delete(key)

mailbox.delete("key1")
PreviousMetrics FunctionsNextData Generation Functions

Last updated 2 years ago

Was this helpful?