{"id":16305215,"url":"https://github.com/moznion/jesqulin","last_synced_at":"2025-04-11T13:50:28.335Z","repository":{"id":145078024,"uuid":"83113137","full_name":"moznion/jesqulin","owner":"moznion","description":"A framework to provide a safe way to use Jesque","archived":false,"fork":false,"pushed_at":"2017-02-25T07:16:22.000Z","size":18,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-15T23:15:49.688Z","etag":null,"topics":["framework","jesque"],"latest_commit_sha":null,"homepage":"","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/moznion.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":"2017-02-25T06:57:59.000Z","updated_at":"2017-02-25T07:20:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"0df74657-5804-478c-982a-3bcd8fdf263e","html_url":"https://github.com/moznion/jesqulin","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"9385c30f2d1b0c5bdbf43f267b79113eba85cc8f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjesqulin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjesqulin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjesqulin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moznion%2Fjesqulin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moznion","download_url":"https://codeload.github.com/moznion/jesqulin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248411864,"owners_count":21099012,"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":["framework","jesque"],"created_at":"2024-10-10T21:06:03.426Z","updated_at":"2025-04-11T13:50:28.313Z","avatar_url":"https://github.com/moznion.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"jesqulin [![Build Status](https://travis-ci.org/moznion/jesqulin.svg?branch=master)](https://travis-ci.org/moznion/jesqulin)\n========\n\nA framework to provide a safe way to use [Jesque](https://github.com/gresrun/jesque).\n\nGetting started\n--\n\n### Prepare classes\n\n#### Argument class\n\nArgument class is the payload of Jesque and this class is related to action class.\n\n```java\npublic class SampleArgument implements JesqueArgument {\n    private final long id;\n\n    public SampleArgument(final long id) {\n        this.id = id;\n    }\n\n    // This getter is necessary to serialize by Jackson\n    // (Jesque uses Jackson internally)\n    public long getId() {\n        return id;\n    }\n}\n```\n\n#### Action class\n\nAction class is the core of job. Worker of Jesque invokes this runnable action.\n\n```java\npublic class SampleAction implements JesqueAction\u003cSampleArgument\u003e {\n    private SampleArgument arg;\n\n    @Override\n    public String getQueueName() {\n        return \"sample-queue\";\n    }\n\n    @Override\n    public void run() {\n        System.out.println(arg.getId());\n    }\n\n    @Override\n    public void setArg(Map\u003cString, Object\u003e arg) {\n        final long id;\n        {\n            final Object item = arg.get(\"id\");\n            if (!(item instanceof Integer) \u0026\u0026 !(item instanceof Long)) {\n                throw new IllegalArgumentException(\"id must not be null. And which must be integer or long value\");\n            }\n            id = ((Number) item).longValue();\n        }\n\n        this.arg = new SampleArgument(id);\n    }\n}\n```\n\n### Client side\n\n#### Create Jesque client\n\n```java\npublic class SampleJesqueClient implements JesqueClient {\n    private final Client clientPool;\n    private final Pool\u003cJedis\u003e jedisPool;\n\n    public SampleJesqueClient(final String host, final int port, final String namespace) {\n        final Config jesqueConfig = new ConfigBuilder()\n                .withNamespace(namespace)\n                .withHost(host)\n                .withPort(port)\n                .build();\n        jedisPool = PoolUtils.createJedisPool(jesqueConfig);\n        clientPool = new ClientPoolImpl(jesqueConfig, jedisPool);\n    }\n\n    @Override\n    public void enqueue(String queueName, Job job) {\n        clientPool.enqueue(queueName, job);\n    }\n\n    public Pool\u003cJedis\u003e getJedisPool() {\n        return jedisPool;\n    }\n}\n```\n\n#### Enqueue job (argument)\n\n```java\nSampleJesqueClient jesqueClient = new SampleJesqueClient(\"127.0.0.1\", 6379, \"namespace\");\nfinal JesqueQueuer\u003cSampleArgument, SampleAction\u003e queuer =\n    new JesqueQueuer\u003c\u003e(SampleAction.class, jesqueClient);\nqueuer.enqueue(new SampleArgument(123));\n```\n\n### Worker side\n\n```java\n// Register queue and create job factory\nfinal List\u003c? extends JesqueAction\u003e actions = Arrays.asList(\n        new SampleAction()\n);\nMap\u003cString, Class\u003c? extends JesqueAction\u003e\u003e workingClassMap = new HashMap\u003c\u003e(actions.size());\nfor (final JesqueAction action : actions) {\n    final Class\u003c? extends JesqueAction\u003e clazz = action.getClass();\n    workingClassMap.put(clazz.getName(), clazz);\n}\nfinal Set\u003cString\u003e queues = actions.stream().map(JesqueAction::getQueueName).collect(Collectors.toSet());\n\nfinal Config jesqueConfig = new ConfigBuilder()\n        .withNamespace(\"namespace\")\n        .withHost(\"127.0.0.1\")\n        .withPort(6379)\n        .build();\nfinal Pool\u003cJedis\u003e jedisPool = PoolUtils.createJedisPool(jesqueConfig);\n\nfinal WorkerPoolImpl workerPool = new WorkerPoolImpl(\n        new ConfigBuilder().withHost(\"127.0.0.1\").withPort(6379).withNamespace(\"namespace\").build(),\n        queues,\n        new MapBasedJobFactory(workingClassMap),\n        jedisPool\n);\n\nworkerPool.run();\n```\n\nBehavior and Mechanism\n--\n\n### Client side\n\n- Enqueues an instance of the class that implements `JesqueArgument` via `JesqueQueuer`\n- `JesqueArgument` is related to `JesqueAction`\n- `JesqueAction` has the identifier of queue (i.e. `queueName`)\n- `JesqueQueuer` enqueues `JesqueArgument` to queue that is identified by `queueName`\n- When enqueuing, instance of the argument class is serialized to JSON by Jackson\n\n### Worker side\n\n- Jesque worker dequeues payload (i.e. serialized JSON string) from any queue\n- The queue is related to `JesqueAction`; worker instantiate which action\n- Deserialize payload by `JesqueArgument` class that is related to `JesqueAction`\n    - And pass this deserialized object as Map structure to instantiated `JesqueArgument` via `setArg()` method\n- Invoke `run()` method of `JesqueAction` after `setArg()` is called\n\nAuthor\n--\n\nmoznion (\u003cmoznion@gmail.com\u003e)\n\nLicense\n--\n\n```\nThe MIT License (MIT)\nCopyright © 2017 moznion, http://moznion.net/ \u003cmoznion@gmail.com\u003e\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the “Software”), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Fjesqulin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoznion%2Fjesqulin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoznion%2Fjesqulin/lists"}