AMQP Message Builder
Try Change body payload size to 200 bytes.
Observe Watch Total Message Size and Payload Efficiency after Calculate message size.
Explain Explain why TTL of 0 changes Header size.
Calculate message size
Reset
Technical boundaries. Message size uses fixed header and properties sizes plus body payload size and 16 bytes. Delivery-Count stays at 0.
Construct an AMQP message by selecting header fields, properties, and a payload format. See how each choice affects the total message size and structure.
viewof msgDurable = Inputs. select (["true (persistent)" , "false (transient)" ], {value : "true (persistent)" , label : "Durable" })
viewof msgPriority = Inputs. range ([0 , 9 ], {value : 5 , step : 1 , label : "Priority (0-9)" })
viewof msgTTL = Inputs. range ([0 , 300000 ], {value : 60000 , step : 1000 , label : "TTL (ms, 0 = no expiry)" })
viewof msgContentType = Inputs. select (["application/json" , "text/plain" , "application/octet-stream" , "application/protobuf" ], {value : "application/json" , label : "Content-Type" })
viewof msgIncludeCorrelation = Inputs. checkbox (["Include Correlation-ID" ], {value : ["Include Correlation-ID" ]})
viewof msgIncludeReplyTo = Inputs. checkbox (["Include Reply-To queue" ])
viewof msgBodySize = Inputs. range ([10 , 2000 ], {value : 200 , step : 10 , label : "Body payload size (bytes)" })
msgHeaderSize = 8 + (msgDurable === "true (persistent)" ? 1 : 0 ) + 1 + (msgTTL > 0 ? 4 : 0 ) + 1 + 4
msgPropsSize = msgContentType. length + 4 + (msgIncludeCorrelation. length > 0 ? 36 : 0 ) + (msgIncludeReplyTo. length > 0 ? 20 : 0 ) + 36 + 8 + 10
msgTotalSize = msgHeaderSize + msgPropsSize + msgBodySize + 16
html `
<div style="background: #f8f9fa; padding: 20px; border-radius: 8px; border-left: 4px solid #3498DB; margin: 20px 0;">
<div style="font-size: 15px; font-weight: bold; color: #2C3E50; margin-bottom: 15px;">Message Structure Breakdown</div>
<div style="display: flex; gap: 0; border-radius: 8px; overflow: hidden; margin-bottom: 15px; height: 40px;">
<div style="background: #2C3E50; flex: ${ msgHeaderSize} ; display: flex; align-items: center; justify-content: center; color: white; font-size: 11px; font-weight: bold; min-width: 60px;">Header ${ msgHeaderSize} B</div>
<div style="background: #16A085; flex: ${ msgPropsSize} ; display: flex; align-items: center; justify-content: center; color: white; font-size: 11px; font-weight: bold; min-width: 60px;">Properties ${ msgPropsSize} B</div>
<div style="background: #3498DB; flex: ${ msgBodySize} ; display: flex; align-items: center; justify-content: center; color: white; font-size: 11px; font-weight: bold; min-width: 60px;">Body ${ msgBodySize} B</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 15px;">
<div style="background: white; padding: 12px; border-radius: 6px; border-top: 3px solid #2C3E50;">
<div style="font-size: 12px; color: #7F8C8D; margin-bottom: 6px;">Header Fields</div>
<div style="font-size: 12px; color: #2C3E50; line-height: 1.7;">
Durable: <strong> ${ msgDurable. split (" " )[0 ]} </strong><br>
Priority: <strong> ${ msgPriority} </strong><br>
TTL: <strong> ${ msgTTL > 0 ? msgTTL + " ms" : "none" } </strong><br>
Delivery-Count: <strong>0</strong>
</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px; border-top: 3px solid #16A085;">
<div style="font-size: 12px; color: #7F8C8D; margin-bottom: 6px;">Properties</div>
<div style="font-size: 12px; color: #2C3E50; line-height: 1.7;">
Content-Type: <strong> ${ msgContentType} </strong><br>
Message-ID: <strong>uuid</strong><br>
${ msgIncludeCorrelation. length > 0 ? "Correlation-ID: <strong>uuid</strong><br>" : "" }
${ msgIncludeReplyTo. length > 0 ? "Reply-To: <strong>reply_q</strong><br>" : "" }
Timestamp: <strong>set</strong>
</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px; border-top: 3px solid #3498DB;">
<div style="font-size: 12px; color: #7F8C8D; margin-bottom: 6px;">Body</div>
<div style="font-size: 12px; color: #2C3E50; line-height: 1.7;">
Format: <strong> ${ msgContentType. split ("/" )[1 ]} </strong><br>
Size: <strong> ${ msgBodySize} bytes</strong><br>
Encoding: <strong>utf-8</strong>
</div>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 12px;">
<div style="background: white; padding: 12px; border-radius: 6px;">
<div style="font-size: 12px; color: #7F8C8D;">Total Message Size</div>
<div style="font-size: 22px; font-weight: bold; color: #2C3E50;"> ${ msgTotalSize} bytes</div>
</div>
<div style="background: white; padding: 12px; border-radius: 6px;">
<div style="font-size: 12px; color: #7F8C8D;">Payload Efficiency</div>
<div style="font-size: 22px; font-weight: bold; color: ${ (msgBodySize / msgTotalSize * 100 ) >= 70 ? '#16A085' : (msgBodySize / msgTotalSize * 100 ) >= 40 ? '#E67E22' : '#E74C3C' } ;"> ${ (msgBodySize / msgTotalSize * 100 ). toFixed (1 )} %</div>
</div>
</div>
</div>
`
Back to the chapter