try { // Create a JMB instance Jmb jmb = new Jmb(); // Create a JMS connection JMSConnection connection = jmb.createConnection("tcp://localhost:61616"); // Create a JMS session JMSSession session = connection.createSession(); // Create a JMS destination (queue or topic) JMSDestination destination = session.createDestination("testQueue"); // Create a JMS message JMSMessage message = session.createMessage("Hello, World!"); // Send the message session.send(destination, message); // Cleanup resources session.close(); connection.close(); } catch (JMBException e) { e.printStackTrace(); }
try { // Create a JMB instance Jmb jmb = new Jmb(); // Create a JMS connection JMSConnection connection = jmb.createConnection("tcp://localhost:61616"); // Create a JMS session JMSSession session = connection.createSession(); // Create a JMS destination (queue or topic) JMSDestination destination = session.createDestination("testQueue"); // Create a JMS consumer JMSConsumer consumer = session.createConsumer(destination); // Start listening for messages consumer.setMessageListener(new JMSMessageListener() { @Override public void onMessage(JMSMessage message) { System.out.println("Received message: " + message.getBody()); } }); // Wait for messages Thread.sleep(30000); // Cleanup resources consumer.close(); session.close(); connection.close(); } catch (JMBException | InterruptedException e) { e.printStackTrace(); }JMB is part of the Java Messaging Service (JMS) and is included in the JavaEE and JavaSE libraries. The package for JMB is `javax.jms.`