How to share events code in a microservice architecture The 2019 Stack Overflow Developer Survey Results Are InEvent binding on dynamically created elements?How to find event listeners on a DOM node when debugging or from the JavaScript code?What is a good event store/stream middleware for service-oriented/ microservice-architecturesMicroservice Architecture dependencyData Consistency Across MicroservicesUnderstanding Event Driven MicroservicesMicroservice Communication in EDA using Event SourcingDesign choice for a microservice event-driven architecturemicroservice shared domain layerGenerating human-friendly codes within a microservice architecture
Why isn't airport relocation done gradually?
How to manage monthly salary
A poker game description that does not feel gimmicky
How technical should a Scrum Master be to effectively remove impediments?
How to type this arrow in math mode?
What is the meaning of Triage in Cybersec world?
Which Sci-Fi work first showed weapon of galactic-scale mass destruction?
Resizing object distorts it (Illustrator CC 2018)
Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?
Time travel alters history but people keep saying nothing's changed
How to support a colleague who finds meetings extremely tiring?
Is a "Democratic" Oligarchy-Style System Possible?
How to check whether the reindex working or not in Magento?
Why not take a picture of a closer black hole?
For what reasons would an animal species NOT cross a *horizontal* land bridge?
The difference between dialogue marks
Should I use my personal e-mail address, or my workplace one, when registering to external websites for work purposes?
Origin of "cooter" meaning "vagina"
Are there incongruent pythagorean triangles with the same perimeter and same area?
Can one be advised by a professor who is very far away?
Multiply Two Integer Polynomials
Why can Shazam fly?
Pokemon Turn Based battle (Python)
What is the accessibility of a package's `Private` context variables?
How to share events code in a microservice architecture
The 2019 Stack Overflow Developer Survey Results Are InEvent binding on dynamically created elements?How to find event listeners on a DOM node when debugging or from the JavaScript code?What is a good event store/stream middleware for service-oriented/ microservice-architecturesMicroservice Architecture dependencyData Consistency Across MicroservicesUnderstanding Event Driven MicroservicesMicroservice Communication in EDA using Event SourcingDesign choice for a microservice event-driven architecturemicroservice shared domain layerGenerating human-friendly codes within a microservice architecture
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm working on a "microservice-like" architecture. Each microservice can fire some events to RabbitMQ. The events are identified by an event code. At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event.
My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
I see the possible alternatives:
Declare the event code only in the microservice that fire the event. Let the consumers microservices directly access to the code declared in the microservice that fire the event. In this case, the event is declared once but it creates a source code dependency between microservices... which is bad.
Create a source file (outside all microservices) that contains all the events code of all the application. This source file is shared by all microservices. In this case, each event is declared once but it creates a global dependency for all microservices which is against the single responsability principle... which is bad.
How do you tackle this problem ?
events design-patterns architecture domain-driven-design microservices
add a comment |
I'm working on a "microservice-like" architecture. Each microservice can fire some events to RabbitMQ. The events are identified by an event code. At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event.
My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
I see the possible alternatives:
Declare the event code only in the microservice that fire the event. Let the consumers microservices directly access to the code declared in the microservice that fire the event. In this case, the event is declared once but it creates a source code dependency between microservices... which is bad.
Create a source file (outside all microservices) that contains all the events code of all the application. This source file is shared by all microservices. In this case, each event is declared once but it creates a global dependency for all microservices which is against the single responsability principle... which is bad.
How do you tackle this problem ?
events design-patterns architecture domain-driven-design microservices
How do microservices communicate on you architecture? Can't you use some message bus that shares information? Each microservice could communicate to a queue for the event code fired, with timestamp or other unique and relevant information, thus removing source code dependencies.
– Pedro Bonifácio
Mar 8 at 10:03
Yes this is very precisely my problem. I use rabbitMQ. Both the publisher and the consumer microservice need to know event code (and payload) in order to publish for the first one and to decode for the second one.
– ayorosmage
Mar 8 at 10:32
I think if you want to have a truly effective microservice architecture you should have a shared nothing architecture means whatever you have now is the best way to handle it. I don't see the problem you are trying to solve.
– cool
Mar 8 at 12:58
add a comment |
I'm working on a "microservice-like" architecture. Each microservice can fire some events to RabbitMQ. The events are identified by an event code. At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event.
My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
I see the possible alternatives:
Declare the event code only in the microservice that fire the event. Let the consumers microservices directly access to the code declared in the microservice that fire the event. In this case, the event is declared once but it creates a source code dependency between microservices... which is bad.
Create a source file (outside all microservices) that contains all the events code of all the application. This source file is shared by all microservices. In this case, each event is declared once but it creates a global dependency for all microservices which is against the single responsability principle... which is bad.
How do you tackle this problem ?
events design-patterns architecture domain-driven-design microservices
I'm working on a "microservice-like" architecture. Each microservice can fire some events to RabbitMQ. The events are identified by an event code. At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event.
My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
I see the possible alternatives:
Declare the event code only in the microservice that fire the event. Let the consumers microservices directly access to the code declared in the microservice that fire the event. In this case, the event is declared once but it creates a source code dependency between microservices... which is bad.
Create a source file (outside all microservices) that contains all the events code of all the application. This source file is shared by all microservices. In this case, each event is declared once but it creates a global dependency for all microservices which is against the single responsability principle... which is bad.
How do you tackle this problem ?
events design-patterns architecture domain-driven-design microservices
events design-patterns architecture domain-driven-design microservices
edited Mar 8 at 10:33
ayorosmage
asked Mar 8 at 9:53
ayorosmageayorosmage
259417
259417
How do microservices communicate on you architecture? Can't you use some message bus that shares information? Each microservice could communicate to a queue for the event code fired, with timestamp or other unique and relevant information, thus removing source code dependencies.
– Pedro Bonifácio
Mar 8 at 10:03
Yes this is very precisely my problem. I use rabbitMQ. Both the publisher and the consumer microservice need to know event code (and payload) in order to publish for the first one and to decode for the second one.
– ayorosmage
Mar 8 at 10:32
I think if you want to have a truly effective microservice architecture you should have a shared nothing architecture means whatever you have now is the best way to handle it. I don't see the problem you are trying to solve.
– cool
Mar 8 at 12:58
add a comment |
How do microservices communicate on you architecture? Can't you use some message bus that shares information? Each microservice could communicate to a queue for the event code fired, with timestamp or other unique and relevant information, thus removing source code dependencies.
– Pedro Bonifácio
Mar 8 at 10:03
Yes this is very precisely my problem. I use rabbitMQ. Both the publisher and the consumer microservice need to know event code (and payload) in order to publish for the first one and to decode for the second one.
– ayorosmage
Mar 8 at 10:32
I think if you want to have a truly effective microservice architecture you should have a shared nothing architecture means whatever you have now is the best way to handle it. I don't see the problem you are trying to solve.
– cool
Mar 8 at 12:58
How do microservices communicate on you architecture? Can't you use some message bus that shares information? Each microservice could communicate to a queue for the event code fired, with timestamp or other unique and relevant information, thus removing source code dependencies.
– Pedro Bonifácio
Mar 8 at 10:03
How do microservices communicate on you architecture? Can't you use some message bus that shares information? Each microservice could communicate to a queue for the event code fired, with timestamp or other unique and relevant information, thus removing source code dependencies.
– Pedro Bonifácio
Mar 8 at 10:03
Yes this is very precisely my problem. I use rabbitMQ. Both the publisher and the consumer microservice need to know event code (and payload) in order to publish for the first one and to decode for the second one.
– ayorosmage
Mar 8 at 10:32
Yes this is very precisely my problem. I use rabbitMQ. Both the publisher and the consumer microservice need to know event code (and payload) in order to publish for the first one and to decode for the second one.
– ayorosmage
Mar 8 at 10:32
I think if you want to have a truly effective microservice architecture you should have a shared nothing architecture means whatever you have now is the best way to handle it. I don't see the problem you are trying to solve.
– cool
Mar 8 at 12:58
I think if you want to have a truly effective microservice architecture you should have a shared nothing architecture means whatever you have now is the best way to handle it. I don't see the problem you are trying to solve.
– cool
Mar 8 at 12:58
add a comment |
1 Answer
1
active
oldest
votes
At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event. My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
Events are messages. All of the constraints that we use to manage the evolution of messages applies to events as well.
In a microservices architecture, we expect to be able to deploy instances of the services independently of one another. Requiring that all of the services shut down together to coordinate a change in message schema kind of misses the point. That in turn implies that we need to design reasonable behaviors for the cases where the producer and consumer don't have matching understandings of the message.
In practice, this means something like
- We never introduce a new required field, only optional fields (with documented default values).
- Unrecognized fields are ignored (but forwarded)
- Consumers of optional fields know to use default value to use when an expected field is missing.
- When these constraints cannot be satisfied, then you are introducing a new message.
If you have the message contracts in place, then you aren't restricting yourself to microservice implementations that share the same runtime platform (because two different implementations of the same contract are equivalent).
Recommend reading:
ZeroMQ RFC 42/C4, specifically section 2.6 which describes the evolution of public contracts
Versioning in an Event Sourced System, speficically "Basic Type Based Versioning"
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060659%2fhow-to-share-events-code-in-a-microservice-architecture%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event. My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
Events are messages. All of the constraints that we use to manage the evolution of messages applies to events as well.
In a microservices architecture, we expect to be able to deploy instances of the services independently of one another. Requiring that all of the services shut down together to coordinate a change in message schema kind of misses the point. That in turn implies that we need to design reasonable behaviors for the cases where the producer and consumer don't have matching understandings of the message.
In practice, this means something like
- We never introduce a new required field, only optional fields (with documented default values).
- Unrecognized fields are ignored (but forwarded)
- Consumers of optional fields know to use default value to use when an expected field is missing.
- When these constraints cannot be satisfied, then you are introducing a new message.
If you have the message contracts in place, then you aren't restricting yourself to microservice implementations that share the same runtime platform (because two different implementations of the same contract are equivalent).
Recommend reading:
ZeroMQ RFC 42/C4, specifically section 2.6 which describes the evolution of public contracts
Versioning in an Event Sourced System, speficically "Basic Type Based Versioning"
add a comment |
At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event. My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
Events are messages. All of the constraints that we use to manage the evolution of messages applies to events as well.
In a microservices architecture, we expect to be able to deploy instances of the services independently of one another. Requiring that all of the services shut down together to coordinate a change in message schema kind of misses the point. That in turn implies that we need to design reasonable behaviors for the cases where the producer and consumer don't have matching understandings of the message.
In practice, this means something like
- We never introduce a new required field, only optional fields (with documented default values).
- Unrecognized fields are ignored (but forwarded)
- Consumers of optional fields know to use default value to use when an expected field is missing.
- When these constraints cannot be satisfied, then you are introducing a new message.
If you have the message contracts in place, then you aren't restricting yourself to microservice implementations that share the same runtime platform (because two different implementations of the same contract are equivalent).
Recommend reading:
ZeroMQ RFC 42/C4, specifically section 2.6 which describes the evolution of public contracts
Versioning in an Event Sourced System, speficically "Basic Type Based Versioning"
add a comment |
At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event. My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
Events are messages. All of the constraints that we use to manage the evolution of messages applies to events as well.
In a microservices architecture, we expect to be able to deploy instances of the services independently of one another. Requiring that all of the services shut down together to coordinate a change in message schema kind of misses the point. That in turn implies that we need to design reasonable behaviors for the cases where the producer and consumer don't have matching understandings of the message.
In practice, this means something like
- We never introduce a new required field, only optional fields (with documented default values).
- Unrecognized fields are ignored (but forwarded)
- Consumers of optional fields know to use default value to use when an expected field is missing.
- When these constraints cannot be satisfied, then you are introducing a new message.
If you have the message contracts in place, then you aren't restricting yourself to microservice implementations that share the same runtime platform (because two different implementations of the same contract are equivalent).
Recommend reading:
ZeroMQ RFC 42/C4, specifically section 2.6 which describes the evolution of public contracts
Versioning in an Event Sourced System, speficically "Basic Type Based Versioning"
At the moment, the code of the event triggered is an hard coded const string declared inside the microservice that fire the event. My problem is that each microservice that want to subscribe to this event must duplicate this event code string. This is error prone especially when an event code is renamed because all microservices that subscribed to this event code need to be changed accordingly... which is very bad.
Events are messages. All of the constraints that we use to manage the evolution of messages applies to events as well.
In a microservices architecture, we expect to be able to deploy instances of the services independently of one another. Requiring that all of the services shut down together to coordinate a change in message schema kind of misses the point. That in turn implies that we need to design reasonable behaviors for the cases where the producer and consumer don't have matching understandings of the message.
In practice, this means something like
- We never introduce a new required field, only optional fields (with documented default values).
- Unrecognized fields are ignored (but forwarded)
- Consumers of optional fields know to use default value to use when an expected field is missing.
- When these constraints cannot be satisfied, then you are introducing a new message.
If you have the message contracts in place, then you aren't restricting yourself to microservice implementations that share the same runtime platform (because two different implementations of the same contract are equivalent).
Recommend reading:
ZeroMQ RFC 42/C4, specifically section 2.6 which describes the evolution of public contracts
Versioning in an Event Sourced System, speficically "Basic Type Based Versioning"
answered Mar 8 at 14:05
VoiceOfUnreasonVoiceOfUnreason
21.8k22251
21.8k22251
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55060659%2fhow-to-share-events-code-in-a-microservice-architecture%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
How do microservices communicate on you architecture? Can't you use some message bus that shares information? Each microservice could communicate to a queue for the event code fired, with timestamp or other unique and relevant information, thus removing source code dependencies.
– Pedro Bonifácio
Mar 8 at 10:03
Yes this is very precisely my problem. I use rabbitMQ. Both the publisher and the consumer microservice need to know event code (and payload) in order to publish for the first one and to decode for the second one.
– ayorosmage
Mar 8 at 10:32
I think if you want to have a truly effective microservice architecture you should have a shared nothing architecture means whatever you have now is the best way to handle it. I don't see the problem you are trying to solve.
– cool
Mar 8 at 12:58