Diseña Azure Service Bus para pedidos EC con Claude Code
Separa pedidos, inventario, correo, DLQ y reintentos de una tienda EC con Azure Service Bus.
En una tienda EC, la pantalla de pedidos, el CSV de inventario, la solicitud de envío, el log de correo y la nota de reintento suelen estar separados. Si alguien reenvía un pedido completo cuando solo falló el correo, el stock puede bajar dos veces. Este artículo convierte Azure Service Bus en una tabla sencilla para pedidos, inventario y reintentos.
Dónde se rompe el flujo de pedidos EC
- No mezcles pedido aceptado, reserva de inventario, envío, correo y reintento en una sola queue.
- Usa topic cuando un pedido debe llegar a inventario, envío, correo y analítica.
- Define MessageId estable con order id, línea y acción antes de confiar en duplicate detection.
- La dead-letter queue sirve para inspección, no para reenvío ciego.
- Claude Code redacta tablas; pago, reembolso, datos personales y aprobación quedan en personas.
The Microsoft documentation for Service Bus overview, queues, topics, and subscriptions, dead-letter queues, duplicate detection, message transfers, and pricing tiers is the source base. The internal Azure memo pattern is also related to the Azure OpenAI privacy memo.
Qué hace Claude Code y qué revisan las personas
En una tienda EC, la pantalla de pedidos, el CSV de inventario, la solicitud de envío, el log de correo y la nota de reintento suelen estar separados. Si alguien reenvía un pedido completo cuando solo falló el correo, el stock puede bajar dos veces. Este artículo convierte Azure Service Bus en una tabla sencilla para pedidos, inventario y reintentos. Claude Code should read column names, event names, retry samples, and DLQ reason text. It should not receive card data, full address text, refund judgment, or credentials. The output should be a table with event name, input columns, queue or topic, subscription, MessageId, DLQ owner, retry condition, and human review.
Humans keep payment state, refund permission, privacy policy, stock finalization, warehouse contract, apology text, and release approval. This split matters because a technically valid retry can still be a business mistake. The table makes the stop point visible before production.
Tres casos de uso
Use case 1
El pedido aceptado dispara varias tareas. Entrada: CSV de pedido, order id, línea, SKU, cantidad, pago y bandera de correo. Salida: topic:orders con suscripciones para inventario, envío, correo y analítica. Revisión humana: pedido no pagado, reserva, bundle, regalo, ajuste manual y texto de correo.
Use case 2
La reserva de inventario necesita una clave de negocio estable. Entrada: order id, línea, SKU, cantidad, acción reserve y log de envío. Salida: tabla de MessageId como order id más línea más reserve. Revisión humana: cambio de cantidad, cancelación, recompra, bundle y devolución de stock.
Use case 3
La DLQ debe leerse por operaciones y desarrollo. Entrada: reason, description, order id, SKU, número de fallos, hora y memo. Salida: retry automático, corregir y reenviar, retener pedido, revisar reembolso o investigar. Revisión humana: aviso al cliente, inventario, almacén y permiso de reenvío.
Prompt para copiar
You are preparing an Azure Service Bus design memo for an EC store.
Inputs: order CSV columns, inventory CSV columns, event names, retry logs, DLQ reason samples, and planned Azure tier.
Output:
1. Event table with eventName, input columns, queue or topic, subscription, MessageId, and DLQ owner.
2. Human review table for payment, refund, personal data, stock finalization, customer notice, and resend approval.
3. MessageId naming rules based on order id, line item id, and action.
4. DLQ classification: auto retry, fix then retry, hold order, refund review, engineering investigation.
5. One first action that can be done in 30 minutes.
Rules: do not put card data or full address text in messages. Do not blindly resend every DLQ message.
Código de comprobación
const events = [
{ type: "order.accepted", orderId: "ORD-1001", lineItemId: "1", sku: "TSHIRT-M", quantity: 2, action: "accept" },
{ type: "inventory.reserve", orderId: "ORD-1001", lineItemId: "1", sku: "TSHIRT-M", quantity: 2, action: "reserve" },
{ type: "inventory.reserve", orderId: "ORD-1001", lineItemId: "1", sku: "TSHIRT-M", quantity: 2, action: "reserve" },
{ type: "mail.send", orderId: "ORD-1001", lineItemId: "", sku: "", quantity: 0, action: "confirmation" },
{ type: "inventory.reserve", orderId: "", lineItemId: "2", sku: "MUG-BLUE", quantity: 1, action: "reserve" },
{ type: "shipping.requested", orderId: "ORD-1002", lineItemId: "1", sku: "BAG-BK", quantity: 1, action: "ship" }
];
function routeEvent(event) {
if (event.type === "order.accepted") {
return {
entity: "topic:orders",
messageId: event.orderId + ":accepted",
reason: "fan out to inventory, shipping, mail, and analytics subscriptions"
};
}
if (event.type === "inventory.reserve") {
return {
entity: "queue:inventory-reserve",
messageId: event.orderId + ":" + event.lineItemId + ":reserve",
reason: "one stock reservation worker should own this line item"
};
}
if (event.type === "mail.send") {
return {
entity: "queue:mail-send",
messageId: event.orderId + ":" + event.action,
reason: "mail can retry without touching stock"
};
}
return {
entity: "needs-design-review",
messageId: event.orderId + ":" + event.type,
reason: "route is not documented yet"
};
}
const seen = new Set();
const findings = [];
for (const event of events) {
const route = routeEvent(event);
if (!event.orderId) {
findings.push({
type: "missing-order-id",
eventType: event.type,
fix: "do not send this message until the order id is present"
});
}
if (seen.has(route.messageId)) {
findings.push({
type: "duplicate-message-id",
eventType: event.type,
messageId: route.messageId,
fix: "keep the same MessageId for sender retry, but make the handler idempotent"
});
}
if (route.entity === "needs-design-review") {
findings.push({
type: "unknown-route",
eventType: event.type,
fix: "decide queue, topic subscription, DLQ owner, and retry rule before release"
});
}
seen.add(route.messageId);
}
console.table(findings);
if (findings.length > 0) process.exitCode = 1;
Pitfall: errores comunes
The first cause is one queue for every action. The fix is to use a topic for order accepted and separate queues or subscriptions for inventory, shipping, and mail. This prevents a mail retry from touching stock again.
The second cause is random MessageId generation. The fix is to generate the id from order id, line item id, and action before sending. Duplicate detection can only help inside the configured window when the id stays stable.
The third cause is blind DLQ resend. The fix is to classify each reason into auto retry, fix then retry, hold order, refund review, or engineering investigation. Messages that affect customers or refunds need human review.
The fourth cause is ignoring tier differences. The fix is to check whether topics, transactions, de-duplication, or sessions are required before choosing Basic, Standard, or Premium.
Preguntas frecuentes
Q. Should every EC event be a topic? A. No. Topic is useful when one event fans out. A queue is clearer when one worker owns one task such as inventory reservation or mail send.
Q. Does duplicate detection remove all double stock moves? A. No. It helps when MessageId is stable. The handler should still check whether the line item was already processed.
Q. Who should read DLQ? A. Operations and developers. EC failures can involve customer notice, refund, stock gap, and warehouse contact.
Q. What should message body contain? A. Prefer order id, line item id, SKU, quantity, and reference id. Review personal data and logging policy before adding sensitive text.
Camino a consultoría
Para EC, el valor no está en un diagrama bonito. Está en menos doble descuento de stock, menos retrasos y menos tickets. Lleva columnas del CSV, tres fallos y el proceso actual a la página de consultoría. Use Claude Code training and consultation when the team needs help turning order CSV, inventory CSV, retry logs, and release approval into a workflow.
Qué verifiqué
Verifiqué documentación de Service Bus, queues/topics/subscriptions, DLQ, duplicate detection, transfers y tiers. También ejecuté el código local y confirmó order id faltante, MessageId duplicado y ruta desconocida. El primer paso es una tabla para pedido, inventario, correo y reintento.
Artículos relacionados
Crear una tienda e-commerce con Claude Code: Next.js, Stripe Checkout e inventario
Guía práctica para crear una tienda con Claude Code: productos, carrito, inventario, Stripe Checkout, Webhook, admin, SEO y operaciones.
Carteles, folletos y notas de planograma para tu tienda con Claude Code
Crea carteles, textos de folleto y notas de planograma para tu tienda con Claude Code: plantilla de prompt y script de verificación.
Service Worker con Claude Code: caché, actualizaciones y offline
Guía práctica para implementar Service Worker con Claude Code: caché, ciclo de actualización, UX offline y ejemplos.
PDF gratis: cheatsheet de Claude Code
Introduce tu email y descarga una hoja con comandos, hábitos de revisión y flujos seguros.
Cuidamos tus datos y no enviamos spam.
Sobre el autor
Masa
Ingeniero enfocado en workflows prácticos con Claude Code.