{"id":23037228,"url":"https://github.com/ZenWave360/spring-modulith-events-spring-cloud-stream","last_synced_at":"2025-08-14T18:31:46.908Z","repository":{"id":267519400,"uuid":"901495340","full_name":"ZenWave360/zenwave-spring-modulith-events-spring-cloud-stream","owner":"ZenWave360","description":"ZenWave Spring-Modulith events externalizer for Spring Cloud Stream","archived":false,"fork":false,"pushed_at":"2024-12-10T19:41:02.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-12-10T20:33:48.030Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZenWave360.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-10T19:04:55.000Z","updated_at":"2024-12-10T19:41:07.000Z","dependencies_parsed_at":"2024-12-10T20:34:01.790Z","dependency_job_id":"79670892-8bb7-415d-a265-c33713f0d330","html_url":"https://github.com/ZenWave360/zenwave-spring-modulith-events-spring-cloud-stream","commit_stats":null,"previous_names":["zenwave360/zenwave-spring-modulith-events-spring-cloud-stream"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenWave360%2Fzenwave-spring-modulith-events-spring-cloud-stream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenWave360%2Fzenwave-spring-modulith-events-spring-cloud-stream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenWave360%2Fzenwave-spring-modulith-events-spring-cloud-stream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZenWave360%2Fzenwave-spring-modulith-events-spring-cloud-stream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZenWave360","download_url":"https://codeload.github.com/ZenWave360/zenwave-spring-modulith-events-spring-cloud-stream/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229852723,"owners_count":18134462,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-15T17:31:48.953Z","updated_at":"2025-08-14T18:31:46.899Z","avatar_url":"https://github.com/ZenWave360.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring-Modulith Events Externalizer for Spring Cloud Stream\n\n[![Maven Central](https://img.shields.io/maven-central/v/io.zenwave360.sdk/spring-modulith-events-scs.svg?label=Maven%20Central\u0026logo=apachemaven)](https://search.maven.org/artifact/io.zenwave360.sdk/spring-modulith-events-scs)\n[![build](https://github.com/ZenWave360/spring-modulith-events-spring-cloud-stream/workflows/Build%20and%20Publish%20Maven%20Snapshots/badge.svg)](https://github.com/ZenWave360/spring-modulith-events-spring-cloud-stream/actions/workflows/publish-maven-snapshots.yml)\n[![coverage](https://raw.githubusercontent.com/ZenWave360/spring-modulith-events-spring-cloud-stream/badges/jacoco.svg)](https://github.com/ZenWave360/spring-modulith-events-spring-cloud-stream/actions/workflows/build.yml)\n[![branches coverage](https://raw.githubusercontent.com/ZenWave360/spring-modulith-events-spring-cloud-stream/badges/branches.svg)](https://github.com/ZenWave360/spring-modulith-events-spring-cloud-stream/actions/workflows/build.yml)\n[![GitHub](https://img.shields.io/github/license/ZenWave360/spring-modulith-events-spring-cloud-stream)](https://github.com/ZenWave360/spring-modulith-events-spring-cloud-stream/blob/main/LICENSE)\n\nSpring-Modulith Events Externalizer that uses Spring Cloud Stream supporting both JSON and Avro serialization formats.\n\nCheck out the blog post here: https://www.zenwave360.io/posts/Spring-Modulith-Events-Spring-Cloud-Stream-Externalizer/\n\n## Getting Started\n\n### Dependency\nAdd the following Maven dependency to your project:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.zenwave360.sdk\u003c/groupId\u003e\n    \u003cartifactId\u003espring-modulith-events-scs\u003c/artifactId\u003e\n    \u003cversion\u003e${spring-modulith-events-scs.version}\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Configuration\nUse `@EnableSpringCloudStreamEventExternalization` annotation to enable Spring Cloud Stream event externalization in your Spring configuration:\n\n```java\n@Configuration\n@EnableSpringCloudStreamEventExternalization\npublic class SpringCloudStreamEventsConfig {\n    // Additional configurations (if needed)\n}\n```\n\nThis configuration ensures that, in addition to events annotated with `@Externalized`, all events of type `org.springframework.messaging.Message` with a header named `SpringCloudStreamEventExternalizer.SPRING_CLOUD_STREAM_EVENT_HEADER` will be externalized and routed to their specified destination using the value of this header as the routing target.\n\n---\n\n## Event Serialization\n\nUsing the transactional event publication log requires serializing events to a format that can be stored in a database. Since the generic type of `Message\u003c?\u003e` payload is lost when using the default `JacksonEventSerializer`, this library adds an extra `_class` field to preserve payload type information, allowing for complete deserialization to its original type.\n\nThis library provides support for POJO (JSON) and Avro serialization formats for `Message\u003c?\u003e` payloads.\n\n### Avro Serialization\n\nAvro serialization needs `com.fasterxml.jackson.dataformat.avro.AvroMapper` class present in the classpath. In order to use Avro serialization, you need to add the following dependency to your project:\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.fasterxml.jackson.dataformat\u003c/groupId\u003e\n    \u003cartifactId\u003ejackson-dataformat-avro\u003c/artifactId\u003e\n\u003c/dependency\u003e\n```\n\n---\n\n## Routing Events\n\n### Programmatic Routing for `Message\u003c?`\u003e events\n\nYou can define routing targets programmatically using a Message header:\n\n```java\npublic class CustomerEventsProducer implements ICustomerEventsProducer {\n\n    private final ApplicationEventPublisher applicationEventPublisher;\n\n    public void onCustomerCreated(CustomerCreated event) {\n        Message\u003cCustomerCreated\u003e message = MessageBuilder.withPayload(event)\n                .setHeader(\n                        SpringCloudStreamEventExternalizer.SPRING_CLOUD_STREAM_SENDTO_DESTINATION_HEADER, \n                        \"customer-created\") // \u003c- target binding name\n                .build();\n        applicationEventPublisher.publishEvent(message);\n    }\n}\n```\n\n### Annotation-Based Routing for POJO Events\n\nLeverage the `@Externalized` annotation to define the target binding name and routing key:\n\n```java\n@Externalized(\"customer-created::#{#this.getLastname()}\")\nclass CustomerCreated {\n\n    public String getLastname() {\n        // Return the customer's last name\n    }\n}\n```\n\n### Configure Spring Cloud Stream destination\n\nConfigure Spring Cloud Stream destination for your bindings as usual in `application.yml`:\n\n```yaml\nspring:\n  cloud:\n    stream:\n      bindings:\n        customer-created:\n          destination: customer-created-topic\n```\n\n### Routing Key\n\n`SpringCloudStreamEventExternalizer` dynamically sets the appropriate Message header (e.g., `kafka_messageKey` or `rabbit_routingKey`) from your routing key based on the channel binder type, if the routing header is not already present.\n\n- KafkaMessageChannelBinder: `kafka_messageKey`\n- RabbitMessageChannelBinder: `rabbit_routingKey`\n- KinesisMessageChannelBinder: `partitionKey`\n- PubSubMessageChannelBinder: `pubsub_orderingKey`\n- EventHubsMessageChannelBinder: `partitionKey`\n- SolaceMessageChannelBinder: `solace_messageKey`\n- PulsarMessageChannelBinder: `pulsar_key`\n\n---\n\n## Using Snapshot Versions\nIn order to test snapshot versions of this library, add the following repository to your Maven configuration:\n\n```xml\n\u003crepository\u003e\n    \u003cid\u003emaven-snapshots\u003c/id\u003e\n    \u003curl\u003ehttps://central.sonatype.com/repository/maven-snapshots\u003c/url\u003e\n    \u003csnapshots\u003e\n        \u003cenabled\u003etrue\u003c/enabled\u003e\n    \u003c/snapshots\u003e\n\u003c/repository\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZenWave360%2Fspring-modulith-events-spring-cloud-stream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FZenWave360%2Fspring-modulith-events-spring-cloud-stream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FZenWave360%2Fspring-modulith-events-spring-cloud-stream/lists"}