{"id":28194291,"url":"https://github.com/monkey-projects/monkey-jms","last_synced_at":"2026-03-07T21:02:00.014Z","repository":{"id":241911266,"uuid":"808191668","full_name":"monkey-projects/monkey-jms","owner":"monkey-projects","description":"JMS 3 wrapper code","archived":false,"fork":false,"pushed_at":"2025-04-01T14:24:58.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-26T05:30:56.838Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Clojure","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/monkey-projects.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-05-30T15:06:52.000Z","updated_at":"2025-03-24T14:20:36.000Z","dependencies_parsed_at":"2024-05-30T18:06:26.812Z","dependency_job_id":"784849fa-0983-4dd4-b6f4-2324ca135822","html_url":"https://github.com/monkey-projects/monkey-jms","commit_stats":null,"previous_names":["monkey-projects/monkey-jms"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/monkey-projects/monkey-jms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fmonkey-jms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fmonkey-jms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fmonkey-jms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fmonkey-jms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/monkey-projects","download_url":"https://codeload.github.com/monkey-projects/monkey-jms/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/monkey-projects%2Fmonkey-jms/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30231489,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T19:01:10.287Z","status":"ssl_error","status_checked_at":"2026-03-07T18:59:58.103Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":"2025-05-16T13:11:49.960Z","updated_at":"2026-03-07T21:01:59.998Z","avatar_url":"https://github.com/monkey-projects.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Monkey JMS\n\nThis is a Clojure library that provides wrapper code for [JMS 3](https://jakarta.ee/learn/docs/jakartaee-tutorial/current/messaging/).\n\n## Why?\n\nI've played around with [Bowerick](https://github.com/ruedigergad/bowerick) which is\nnice, but one the one hand it contains too much stuff I don't need (and hence, unwanted\ndependencies), and on the other hand doesn't provide functionality that I *do* need,\nlike durable subscribers.  So I decided to roll my own.\n\n## Usage\n\nInclude the dependency in your project:\n```clojure\n{:deps {com.monkeyprojects/monkey-jms {:mvn/version \"0.3.1\"}}}\n```\n\nThen require the namespace and you can create a connection (actually a `JMSContext`)\nand producers and/or consumers.\n\n```clojure\n(require '[monkey.jms :as jms])\n\n;; Connect.  The connection is auto-started.\n(def ctx (jms/connect {:url \"amqp://localhost:61616\"\n                       :username \"testuser\"\n                       :password \"verysecret\"}))\n\n;; Start consuming.  In this case, it will just print the received message.\n(def consumer (jms/consume ctx \"topic://test.topic\" println))\n\n;; Producer is a fn that can be closed\n(def producer (jms/make-producer ctx \"topic://test.topic\"))\n;; Send a message\n(producer \"Hi, I'm a test message\")\n\n;; Stop consuming and producing\n(.close producer)\n(.close consumer)\n;; Close connection\n(.close ctx)\n```\n\nEach of the objects implements `AutoCloseable`, so you can also use them in\n`with-open`.\n\n## Serialization\n\nFor simplicity the messages are always `TextMessage`s.  But it's up to you\nwhat you put in those messages.  You can `comp`ose the listener and producer\nto suit your needs.  For example:\n\n```clojure\n(require '[cheshire.core :as json])\n\n;; Producer that encodes to json before sending\n(def json-producer (comp producer json/generate-string))\n\n;; Consumer that parses json\n(def json-consumer (jms/consume ctx \"topic://some.json.topic\" (comp println json/parse-string)))\n```\n\nIf you want to use anything else but `TextMessage`s, you can pass in a `:serializer`\nfunction as an option to the producer.  This is a 2-arity function that takes the\n`JMSContext` and the object to serialize.  As stated, by default it now always creates\na `TextMessage` and assumes the input is a `String`.\n\nWhen receiving messages, we're not always sure that the messages will be `TextMessage`s.\nFor this I have provided a multimethod `message-\u003estr` that uses `class` as a dispatch function.\nIt handles `TextMessage` and `BytesMessage`.  You can add your own implementation if needed,\nbut you can also pass a `:deserializer` option to the `consume` function to override this\ndefault behaviour.\n\n```clojure\n;; Consumer that explicitly calls `getText` on the incoming message\n(def custom-consumer (jms/consume ctx \"topic://test.topic\" println {:deserializer (memfn getText)}))\n```\n\n## Durable Consumers\n\nYou can also create durable consumers, first by specifying a `client-id` in the connection\noptions, and then by specifying an `id` in the options to `consume`.\n```clojure\n(def ctx (jms/connect {:url \"amqp://localhost:61616\"\n                       :username \"testuser\"\n                       :password \"verysecret\"\n                       :client-id \"unique-client-id\"}))\n\t\t     \n(def durable-cons (c/consume ctx \"topic://test.topic\" my-handler {:id \"durable-consumer-id\"}))\n\n;; When no longer needed, you can `unsubscribe`\n(jms/unsubscribe ctx \"durable-consumer-id\")\n```\n\nThe `client-id` set on the connection ensures that **only one client with that id** can\nconnect at the same time.  Should another client attempt to connect using the same `client-id`,\nit will receive an error.  The `id` specified on the consumer is only unique within that\nsame client.  It is not possible to register multiple consumers for the same client with\nthe same subscription id.\n\nBy default, this will create a non-shared durable subscription.  If you want a shared\nconsumer, add `shared? true` as an additional option on the consumer:\n\n```clojure\n(def shared-cons (c/consume ctx \"topic://test.topic\" my-handler {:id \"durable-consumer-id\" :shared? true}))\n```\n\nSee [the JMS docs](https://jakarta.ee/specifications/messaging/3.1/apidocs/jakarta.messaging/jakarta/jms/jmscontext)\nfor more on the difference between shared and unshared consumers.\n\n## Synchronous Consumption\n\nSometimes it's more useful or straightforward to actively poll received messages.\nYou can achieve this by not passing a listener in the `consume` function.  The\nconsumer is also a Clojure function that you can invoke to poll for the next\nmessage.  You can pass a timeout (in msecs).  If you pass a timeout of zero, it\nwill immediately return unless a message is ready.\n\n```clojure\n;; You can still pass an options map should you so desire\n(def consume (jms/consume ctx \"test.topic\"))\n\n;; Receive next message, wait for a second\n(def msg (consume 1000))\n\n(println \"The next message received is:\" msg)\n```\n\n## Message Selectors\n\nJMS also has a concept of [message selectors](https://timjansen.github.io/jarfiller/guide/jms/selectors.xhtml),\nwhich allow broker-side filtering of messages.  This can be useful if you have a consumer\nthat reads from a topic that has many messages, but only needs a few based on properties.\nYou can enable message selection by specifying a `:selector` on the consumer.  For example,\nlet's assume you want to read messages from a `high-volume.topic` that has a `customer` property,\nand only need messages for `Test Customer`, you can do this:\n\n```clojure\n(def filtered-consumer\n  (c/consume ctx \"topic://high-volume.topic\" my-handler {:selector \"customer = 'Test Customer'\"}))\n```\n\n## License\n\nCopyright (c) 2024-2025 by [Monkey Projects BV](https://www.monkey-projects.be).\n\n[MIT License](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonkey-projects%2Fmonkey-jms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonkey-projects%2Fmonkey-jms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonkey-projects%2Fmonkey-jms/lists"}