Bird
0
0

Which of the following is the correct syntax to publish an event in an event-driven microservice using a message broker?

easy📝 Conceptual Q3 of 15
Microservices - Event-Driven Architecture
Which of the following is the correct syntax to publish an event in an event-driven microservice using a message broker?
AmessageBroker.request('orderCreated', orderData);
BmessageBroker.publish('orderCreated', orderData);
CmessageBroker.call('orderCreated', orderData);
DmessageBroker.sendSync('orderCreated', orderData);
Step-by-Step Solution
Solution:
  1. Step 1: Identify event publishing method

    Publishing an event typically uses a method named 'publish' or similar to send asynchronous messages.
  2. Step 2: Eliminate synchronous or request methods

    Methods like 'request', 'call', or 'sendSync' imply synchronous or request-driven calls, not event publishing.
  3. Final Answer:

    messageBroker.publish('orderCreated', orderData); -> Option B
  4. Quick Check:

    Event publish syntax = A [OK]
Quick Trick: 'publish' means event-driven; 'request' means request-driven [OK]
Common Mistakes:
MISTAKES
  • Using synchronous method names for event publishing
  • Confusing 'request' with 'publish'
  • Assuming 'call' is for events

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Microservices Quizzes