Skip to content

Latest commit

 

History

History
108 lines (82 loc) · 3.08 KB

README.md

File metadata and controls

108 lines (82 loc) · 3.08 KB

Auf JMS

Maven Central

Introduction

Auf JMS is aimed at Spring-based applications that need to implement a messaging archiecture on top of JMS brokers. It offers an annotation-driven and declarative programming model that abstracts away low-level JMS API's by offering a set of annotations and conventions with which application developers declare the intentions via plain Java classes and provided annotations.

Quick Start

Assuming you have a Spring Boot application ready, add dependency:

Client Application

Enable by @EnableByJms.

@EnableByJms
@SpringBootApplication
class ClientApplication {
    public static void main(final String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }
}

Declare by @ByJms.

@ByJms(@To("${app.task.inbox}"))
public interface TaskInbox {
    void runJob(Job job);
}

At this point, you have a JMS client proxy that when invoked will send a message

  • to a queue named by Spring property app.task.inbox
  • with the message type of RunJob
  • with the message body of job serialized in JSON

The proxy won't do anything by itself, so the next step is to...

Inject and enjoy.

@Service
public class AppService {
    // Do something with it
    @Autowired
    private TaskInbox taskInbox;
    ...
}

To send to a topic

@ByJms(@To(value = "${app.task.status}", type = DestinationType.TOPIC))
public interface TaskStatus {
    void updateJobStatus(@OfProperty String jobId, Status status);
}

Server Application

Enable by @EnableForJms.

@EnableForJms(value = @Inbound(@From("${app.task.inbox}")))
@SpringBootApplication
class ServerApplication {
    public static void main(final String[] args) {
        SpringApplication.run(ClientApplication.class, args);
    }
}

Implement business logic by JMS type

@ForJmsType
class RunJob {
    public void invoke(Job job) {
        //Do the work
    }
}

Runtime

The latest major version 3 requires the following to run:

In addition to the above, the server-side features provided by @EnableForJms requires:

Release

The release binaries can be found on Maven Central.

Version 2

The version 2 releases are on JDK 17, JMS 3.1, Spring 6.

Version 1

The version 1 releases are on JMS 2.0 and Spring 5.