Skip to content

Stream Zaptec Service Bus messages#39

Open
martijnversluis wants to merge 5 commits into
mainfrom
add-service-bus-streaming
Open

Stream Zaptec Service Bus messages#39
martijnversluis wants to merge 5 commits into
mainfrom
add-service-bus-streaming

Conversation

@martijnversluis

Copy link
Copy Markdown
Contributor

Adds the building blocks to consume the per-user-group Azure Service Bus subscription that Zaptec exposes for realtime device observations (docs).

  • Zaptec::Client#user_groups — lists user groups visible to the authenticated account
  • Zaptec::Client#messaging_connection_details(user_group_id) — fetches the per-group Service Bus credentials (host, topic, subscription, SAS key)
  • Zaptec::MessagingSubscription — polls /messages/head over REST with auto-refreshing SAS tokens, parses the DataContractSerializer-wrapped JSON body, and translates StateId/DeviceType to a human-readable name via Zaptec::Constants
  • Zaptec::UserGroup and Zaptec::MessagingConnectionDetails value objects

REST polling (peek-lock or receive-and-delete) instead of AMQP 1.0 to avoid pulling in a C extension. Trade-off: slightly higher latency than push, but works with stdlib Net::HTTP and is easy to debug. Can be swapped for AMQP later if needed.

Used by stekker/stekker#7847, which wires this into a long-running consumer that logs every message to Elastic as a first PoC for replacing the Zaptec REST polling.

Add a complete(message) method that deletes the lock at the URL the
Service Bus returns in the Location header during peek-lock, and surface
that URL on Message as lock_location so callers can ack a message only
once the downstream handler has accepted it. In consume (receive-and-
delete) mode lock_location stays nil.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant