Explainer
Why your gateway talks MQTT to Azure but not AMQP
Short answer
MQTT works because Azure IoT Hub natively speaks MQTT v3.1.1 over TLS and the gateway's Java 1.4 runtime can carry that exchange. AMQP does not, because Event Hubs' client-side ingress is AMQP 1.0 on port 5671 and no supported AMQP client runs on Java 1.4. Keep the gateway on MQTT to IoT Hub and route to Event Hubs from there, or bridge with a separate box.
On this page
Your gateway speaks MQTT to Azure IoT Hub and cannot speak AMQP to Event Hubs, and the reason sits in one place: its Java runtime. IoT Hub natively accepts MQTT v3.1.1 over TLS, and a Java 1.4 environment can carry that exchange, which is why your script-based connection works and a Java rewrite of it works too. Event Hubs takes AMQP 1.0 secured with TLS on port 5671, and no supported AMQP client runs on Java 1.4 — the current Azure Java samples will not even compile there. The working design keeps the gateway on MQTT into IoT Hub and puts the AMQP leg where a modern runtime lives: IoT Hub's routing to Event Hubs, or a small bridge box beside the gateway.
What each Azure endpoint accepts #
Azure gives you two different front doors, and only one of them speaks MQTT. IoT Hub accepts three device protocols — MQTT, AMQP and HTTPS — and its MQTT support is native MQTT v3.1.1, not an adapter bolted on in front. The connection is TLS-only: IoT Hub refuses insecure MQTT on port 1883, so the session rides TLS on port 8883 under a SAS or X.509 device identity. One rule is fixed for the whole path: no cleartext MQTT anywhere, so the gateway's Java code opens TLS from the first packet.
Event Hubs is the other door. Its client-side ingress is AMQP 1.0 secured with TLS on port 5671, a port choice that surprises teams whose firewall plan assumed WebSockets on 443; AMQP uses 5671, not WebSockets on 443 breaks down what actually crosses the wire. The MQTT capability in this design belongs to IoT Hub; treat Event Hubs as the AMQP back end your gateway never talks to directly.
One device identity per MQTT connection #
Here is the documented limit that pushes gateway designers toward AMQP: on IoT Hub, MQTT and HTTPS each carry a single device identity per connection. AMQP is the protocol that multiplexes several device identities over one connection, which is exactly what a transparent field gateway wants — one TLS session, many devices behind it. Microsoft's own guidance marks MQTT and HTTPS as unsuited to that multiplexed field-gateway pattern for this reason.
With MQTT you have two compliant shapes instead. Open one TLS session per downstream device, so the cloud sees each meter as itself (the identity-translation pattern), or publish everything under the gateway's own single identity and split the topics downstream in the cloud. Both work; neither gives you the one-connection fan-in that AMQP would.
The Java 1.4 gate on the gateway #
On the Flexy 205 the Java environment is Java 1.4, and that decides the protocol question on the device. MQTT is implementable there: the same exchange your BASIC script performs can be written as Java 1.4-compatible code against the same broker parameters. AMQP is not — there is no supported AMQP client path in that runtime, and no newer Java version is committed for the gateway, so treat Java 1.4 as a fixed constraint rather than a waiting state.
The Azure Java samples compound this. They are written against current runtimes — generics arrived with Java 5 and try-with-resources with Java 7 — so the Event Hubs sample fails at compile time on Java 1.4, before any network traffic happens. A working MQTT connection proves the gateway's TLS stack and credentials; it proves nothing about AMQP, because AMQP needs a client library this runtime cannot host.
Worked example: forty meters, one gateway #
Numbers for a concrete line: 40 energy meters, each publishing one 300-byte reading every 30 s, all collected by the gateway.
- Messages per meter per day: 86,400 s ÷ 30 s = 2,880.
- Messages per day from the site: 2,880 × 40 = 115,200.
- Payload volume per day: 115,200 × 300 B = 34,560,000 B ≈ 34.6 MB.
- Connections under identity translation: 40 TLS sessions to port 8883, one per device identity.
- Connections with a single gateway identity: 1 TLS session, 40 topics or one tagged payload.
The message count and volume are trivial for the service. The 40-versus-1 connection count is the real cost of losing AMQP's multiplexing, and it is the number to verify against the gateway's documented concurrent-session limit before committing to identity translation.
The architecture that clears both gates #
Keep the device side exactly as it is proven: MQTT v3.1.1 over TLS to IoT Hub, in Java 1.4-compatible code or the existing script. If the device identity is still being chosen, the certificate path is covered in fixing X.509 certificate auth to Azure IoT Hub over MQTT.
Reach Event Hubs in the cloud, not on the device. IoT Hub's built-in message routing delivers device messages to an Event Hubs endpoint, so the AMQP 1.0 consumers sit where the runtime is unrestricted and the gateway never changes.
If IoT Hub is off the table, move the AMQP leg onto a fanless mini PC beside the gateway: MQTT in on the plant side, AMQP 1.0 out to Event Hubs, running whatever current Java the samples need. It is the same shape as bridging a TCP stream into MQTT for AWS IoT Core, with the protocols reversed on the two sides.
Plan for the link drop as well: buffer on the gateway through the outage and replay over the same MQTT identity when the WAN returns, the pattern behind replaying buffered records to Azure IoT Hub over MQTT.
The decision, case by case #
- Destination is IoT Hub: stay on MQTT. Reimplement the proven exchange as Java 1.4-compatible code, TLS on port 8883, one device identity per connection.
- Destination is Event Hubs: never direct from this gateway. Route from IoT Hub, or run AMQP 1.0 on a bridge box; the 5671 firewall rule belongs on that box, not on the gateway.
- Many devices behind one connection: that multiplexing is AMQP's feature and this runtime cannot have it. Choose identity translation (one TLS session per device) or a single gateway identity with cloud-side fan-out, and check the session count first.
- New Azure Java samples: compile them on the bridge or in the cloud consumer. On the gateway they fail before the first byte, on language features Java 1.4 never had.
Questions asked
Can the Flexy 205's Java environment send AMQP straight to Event Hubs?
No. The runtime on that gateway is Java 1.4 and AMQP has no supported client path there, while Event Hubs' device-side ingress is AMQP 1.0 secured with TLS on port 5671. Publish MQTT to IoT Hub instead and let routing, or a bridge box with a modern runtime, carry the AMQP leg.
Will the Azure Event Hubs Java sample compile on the gateway?
No. Java 1.4 predates generics, which arrived with Java 5, and try-with-resources, which arrived with Java 7, and the current Azure Java samples use both throughout, so compilation fails before any network call. Run that sample on the bridge box or a server-side consumer. No newer Java runtime is committed for the gateway.
How do 40 downstream meters share one connection to IoT Hub?
They do not share one MQTT connection with individual identities. MQTT carries a single device identity per connection, so identity translation means 40 TLS sessions to port 8883, or one session if everything publishes under the gateway's own identity and the cloud splits the topics back out. Multiplexing many identities per connection is the AMQP feature this device lacks.
How much store-and-forward buffering does the gateway need for a two-hour WAN outage?
At one message per meter every 30 s, a 2-hour outage banks 7,200 ÷ 30 = 240 messages per meter, so 240 × 40 = 9,600 messages across 40 meters, about 2.8 MB at 300 bytes each. Size persistent buffering above that figure and replay it over the same MQTT identity when the link returns.