Sure you can use JMS with MQLight!
As MQLight supports the wire protocol AMQP 1.0 you can use, for instance, the Apache QPid Proton library.
Working Sample in two files will produce a message to a MQLight queue.
Main.java
import org.apache.qpid.jms.JmsConnectionFactory;
import javax.jms.*;
public class Main {
public static void main(String[] args){
try {
ConnectionFactory cf = new JmsConnectionFactory("amqp://localhost:5672");
Connection connection = cf.createConnection();
Session session = connection.createSession(false,Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = session.createProducer(session.createQueue("QUE.BAR"));
producer.send(session.createTextMessage("foo bar"));
producer.close();
session.close();
connection.close();
}catch(JMSException jmsException){
jmsException.printStackTrace();
}
}
}
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example.test</groupId>
<artifactId>mqlight-jms</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>0.3.0</version>
</dependency>
</dependencies>
</project>