Giter Site home page Giter Site logo

java-mercure's Introduction

Java library for Mercure

The goal of this library is to provide a quick way to publish messages on Mercure. If you don't know what Mercure is, take a look here: (https://github.com/dunglas/mercure).

Installing

You can install via Gradle or Maven. Whatever floats your boat. :)

Gradle:

implementation 'io.github.matts:mercure:0.14.4-1'

Maven:

<dependency>
  <groupId>io.github.matts</groupId>
  <artifactId>mercure</artifactId>
  <version>0.14.4-1</version>
  <type>pom</type>
</dependency>

How to use

This library is really simple to use, you just need to create a new Publisher and for each message you want to publish, just create a new Message object.

Here is an example:

package io.github.matts.test;

import exceptions.io.github.matts.mercure.HubNotFoundException;
import exceptions.io.github.matts.mercure.PublishRejectedException;
import exceptions.io.github.matts.mercure.UnauthorizedPublisherException;

public class Main {

    public static void main(String[] args) throws UnauthorizedPublisherException, PublishRejectedException, HubNotFoundException {
        var token = "your.secret.token";
        var data = "{\"test\": 10}";

        var publisher = new Publisher("http://localhost:3000/.well-known/mercure", token);
        var message = new Message(data, "mytopic");
        var result = publisher.publish(message);
        System.out.println("Message ID: " + result.getId().toString());
    }
}

Versioning

This project is prefixed by the version of the Mercure protocol it supports, followed by a build number. The current version is 0.14.4-1

Credits

Forked from Vitor Villar https://github.com/vitorluis/java-mercure

java-mercure's People

Contributors

vitorluis avatar dunglas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.