{"id":18706334,"url":"https://github.com/axonframework/scynapse","last_synced_at":"2025-04-12T10:21:07.406Z","repository":{"id":22042673,"uuid":"25371112","full_name":"AxonFramework/Scynapse","owner":"AxonFramework","description":"Scynapse - the Scala API for Axon Framework","archived":false,"fork":false,"pushed_at":"2018-11-02T16:18:55.000Z","size":100,"stargazers_count":20,"open_issues_count":1,"forks_count":4,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-26T05:11:27.556Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AxonFramework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-10-17T18:18:39.000Z","updated_at":"2023-07-31T07:37:29.000Z","dependencies_parsed_at":"2022-08-18T21:21:48.530Z","dependency_job_id":null,"html_url":"https://github.com/AxonFramework/Scynapse","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxonFramework%2FScynapse","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxonFramework%2FScynapse/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxonFramework%2FScynapse/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AxonFramework%2FScynapse/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AxonFramework","download_url":"https://codeload.github.com/AxonFramework/Scynapse/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550622,"owners_count":21122934,"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-11-07T12:13:50.535Z","updated_at":"2025-04-12T10:21:07.383Z","avatar_url":"https://github.com/AxonFramework.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Welcome to the Scynapse\n\nScynapse enables the use of Axon with Scala\n\n**This version (0.6.0) works with Axon version 3.4**\n## Axon 3 Upgrade notes\n\nThis version is compatible with Axon 3 and has some API changes in\nAkka system extension for the event bus (AxonEventBusExtension)\nThe API for subscribing and unsubscribing now use Futures as return value instead of the\n```Try[_]```. Have a look at the AxonExtensionSpec for usage details and samples.\n\nNote that 0.6.0 is the first version that supports Axon 3 and needs testing.\nPlease give your feedback in the github ticketing system.\n\n## A quick start in using scynapse (core)\n\n1) Setup a structure with an event store that makes use of the XStreamSerializer found in scynapse-core\n\n2) Create your aggregate root as\n\n    class MyAggregateRoot extends AbstractAnnotatedAggregateRoot[MyIdentifier]\n\n      @AggregateIdentifier\n      private var id : MyIdentifier = _\n\n3) Create your Commands and Events\n\nNote that Commands need an annotation in order to route them to the proper AggregateRoot instance using\nthe @aggregateId annotation\n\n    case class MyCommand(@aggregateId myId: MyIdentifier, otherParam: String)\n\n4) Have the Aggregate Root handle the commands that results in events\n\n    @CommandHandler\n      def handle(cmd: MyCommand) {\n        apply(MyCommandHappened(id))\n      }\n\n  Creation of a new aggregate root works with a command and event handler like this:\n  \n     @CommandHandler\n      def this(cmd: CreateMyAggregate) = {\n        this()\n        apply(MyAggregateCreated(cmd.myId, more values))\n      }\n    \n      @EventHandler\n      def on(e: MyAggregateCreated) = {\n        id = e.myId \n      }\n\n5) Update the state (if required) in the aggregate root\n\n      @EventHandler\n      def on(e: MyCommandHappened) {\n        someState = Some(e.otherParam)\n      }\n\n6) Have event handlers in views build up specific state.\n\n\n## Integrate with Akka\n\n`scynapse-akka` module provides facilities that make it easier to\nintegrate Axon components with Akka.\n\n### Subscribing actors to events\n\n`AxonEventBusExtension` allows to subscribe Akka actors to events\npublished on Axon event bus.  It is implemented as an\n[Akka extension](https://doc.akka.io/docs/akka/current/scala/extending-akka.html#akka-extensions)\nthat manages event bus subscriptions.\n\nIn order to subscribe an `ActorRef` to the event bus you should first\ninitialize an `AxonAkkaBridge`. Here is an example(using Spring):\n\n    import org.axonframework.eventhandling.EventBus\n    import com.thenewmotion.scynapse.akka.AxonEventBusExtension\n\n    val eventBus = getBean(\"eventBus\", classOf[EventBus])\n    val axonAkkaBridge = AxonEventBusExtension(actorSystem) forEventBus eventBus\n\nThen `axonAkkaBridge` can be used to subscribe actors to the Event bus:\n\n    val eventListener: ActorRef = context.actorOf(...)\n    axonAkkaBridge subscribe eventListener\n\nAfter that `eventListener` actor will receive all events published to\nthe event bus as simple messages.\n\nTo unsubscribe actor from the event bus:\n\n    axonAkkaBridge unsubscribe eventListener\n\nIf actor is terminated unsubscription occurs automatically.\n\n\n### Sending commands from actors\n\nIn order to make sending domain commands from Akka components easier a\n`CommandGatewayActor` was introduced. It is just a simple actor\ninterface for the Axon `CommandBus` that dispatches all messages it\nreceives to a command bus. A result returned by the command handler\n(if any) is sent back to the original command sender.\n\nExample usage (again, we're using Spring context here):\n\n    import org.axonframework.commandhandling.CommandBus\n    import com.thenewmotion.scynapse.akka.CommandGatewayActor\n\n    val commandBus = getBean(\"commandBus\", classOf[CommandBus])\n    val cmdGateway = actorSystem.actorOf(CommandGatewayActor.props(commandBus))\n\n    ...\n\n    cmdGateway ! CreateOrder(...)\n\n\n\n## Make use of scalatest to test your domain logic\n\nIt's possible to make use of the Axon given -\u003e when -\u003e then test logic in scalatest and have matchers that work in scala style.\nThe test in the scynapse-test package shows best in what way this works.\n\n# Dependencies\n\nIn order to make use of the the scynapse framework, you need to include in your build.sbt\n\nFor Scynapse core:\n\n    libraryDependencies ++= Seq(\n        \"org.axonframework.scynapse\"        %% \"scynapse-core\"           % 0.6.0\n    )\n\nFor Scynapse akka:\n\n    libraryDependencies ++= Seq(\n        \"org.axonframework.scynapse\"        %% \"scynapse-akka\"           % 0.6.0\n    )\n\nFor Scynapse test:\n\n    libraryDependencies ++= Seq(\n        \"org.axonframework.scynapse\"        %% \"scynapse-test\"           % 0.6.0 % \"test\"\n    )\n\n\n# Development of Scynapse\n\nFor the development of scynapse, you need [SBT](http://www.scala-sbt.org)\nThe build is setup in the project folder and with\n\n    sbt publishLocal\n\nYou will build and publish the packages to your local machine.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxonframework%2Fscynapse","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faxonframework%2Fscynapse","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faxonframework%2Fscynapse/lists"}