Finished Reverser

main
2wenty1ne 2025-11-05 18:02:16 +01:00
commit 9bc0e44ef6
36 changed files with 873 additions and 0 deletions

1
.gitignore vendored 100644
View File

@ -0,0 +1 @@
.idea/

13
VAR-JMS/.classpath 100644
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/activemq-all-5.14.1.jar"/>
<classpathentry kind="lib" path="lib/javax.activation-api-1.2.0.jar"/>
<classpathentry kind="lib" path="lib/jaxb-api-2.3.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

17
VAR-JMS/.project 100644
View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>VAR-JMS</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View File

@ -0,0 +1,13 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="EclipseModuleManager">
<libelement value="jar://$MODULE_DIR$/lib/activemq-all-5.14.1.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/javax.activation-api-1.2.0.jar!/" />
<libelement value="jar://$MODULE_DIR$/lib/jaxb-api-2.3.1.jar!/" />
<src_description expected_position="0">
<src_folder value="file://$MODULE_DIR$/src" expected_position="0" />
</src_description>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/bin" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="jdk" jdkName="JavaSE-1.7" jdkType="JavaSDK" />
<orderEntry type="module-library">
<library name="activemq-all-5.14.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/activemq-all-5.14.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="javax.activation-api-1.2.0.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/javax.activation-api-1.2.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library name="jaxb-api-2.3.1.jar">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/jaxb-api-2.3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

View File

@ -0,0 +1,18 @@
java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url = tcp://localhost:61616
## var.mom.jms.client
queue.var.mom.jms.client.queue1 = queue4731
queue.var.mom.jms.client.queue2 = queue4732
## var.mom.jms.log
queue.var.mom.jms.log.queue = queue4733
## var.mom.jms.log
queue.var.mom.jms.echo.queue = queue4734
## var.mom.jms.chat
topic.var.mom.jms.channel1 = topic4735
## var.mom.jms.reverse
queue.var.mom.jms.reverse.queue = queue4736

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,18 @@
java.naming.factory.initial = org.apache.activemq.jndi.ActiveMQInitialContextFactory
java.naming.provider.url = tcp://localhost:61616
## var.mom.jms.client
queue.var.mom.jms.client.queue1 = queue4731
queue.var.mom.jms.client.queue2 = queue4732
## var.mom.jms.log
queue.var.mom.jms.log.queue = queue4733
## var.mom.jms.log
queue.var.mom.jms.echo.queue = queue4734
## var.mom.jms.chat
topic.var.mom.jms.channel1 = topic4735
## var.mom.jms.reverse
queue.var.mom.jms.reverse.queue = queue4736

View File

@ -0,0 +1,69 @@
package var.mom.jms.chat;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
// Code aus JMS-Client mit Umbenennung des Typs von JMSClient zu ChatClient und Anpassung des packages
public class ChatClient implements MessageListener {
private Connection connection;
private Session session;
private MessageConsumer consumer;
public ChatClient() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Destination queue = (Destination) ctx.lookup("var.mom.jms.chat.queue");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(queue);
consumer.setMessageListener(this);
connection.start();
}
@Override
public void onMessage(Message message) {
try {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String messageText = textMessage.getText();
String priority = textMessage.getStringProperty("Priority");
System.out.println(messageText + " [Priority=" + priority + "]");
}
} catch (JMSException e) {
System.err.println(e);
}
}
public static void main(String[] args) {
long wait = Long.parseLong(args[0]);
ChatClient node = null;
try {
node = new ChatClient();
Thread.sleep(wait);
} catch (InterruptedException | NamingException | JMSException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.consumer != null)
node.consumer.close();
if (node != null && node.session != null)
node.session.close();
if (node != null && node.connection != null)
node.connection.close();
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,84 @@
package var.mom.jms.client;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import javax.jms.BytesMessage;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class JMSClient implements MessageListener {
private Connection connection;
private Session session;
private MessageProducer producer;
private MessageConsumer consumer;
public JMSClient(String sendDest, String receiveDest) throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destOut = (Destination) ctx.lookup(sendDest);
Destination destIn = (Destination) ctx.lookup(receiveDest);
producer = session.createProducer(destOut);
consumer = session.createConsumer(destIn);
consumer.setMessageListener(this);
connection.start();
}
@Override
public void onMessage(Message message) {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
try {
System.out.println(textMessage.getText());
} catch (JMSException e) {
System.err.println(e);
}
}
}
public static void main(String[] args) {
JMSClient node = null;
try {
node = new JMSClient("var.mom.jms.client.queue1", "var.mom.jms.client.queue2");
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
String line;
while (true) {
line = input.readLine();
node.producer.send(node.session.createTextMessage(line));
}
} catch (NamingException | JMSException | IOException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.producer != null) {
node.producer.close();
}
if (node != null && node.consumer != null) {
node.consumer.close();
}
if (node != null && node.session != null) {
node.session.close();
}
if (node != null && node.connection != null) {
node.connection.close();
}
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,5 @@
package var.mom.jms.echo;
public class Conf {
public static final String QUEUE = "var.mom.jms.echo.queue";
}

View File

@ -0,0 +1,74 @@
package var.mom.jms.echo;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class EchoReplierNode implements MessageListener {
private Connection connection;
private Session session;
private MessageConsumer consumer;
public EchoReplierNode() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Queue queue = (Queue) ctx.lookup(Conf.QUEUE);
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(queue);
consumer.setMessageListener(this);
connection.start();
}
@Override
public void onMessage(Message request) {
try {
if (request instanceof TextMessage) {
TextMessage requestText = (TextMessage) request;
System.out.println("empfangen: " + requestText.getText());
MessageProducer replyProducer = session.createProducer(request.getJMSReplyTo());
TextMessage reply = session.createTextMessage();
reply.setText("echo: " + requestText.getText());
Thread.sleep(5000);
replyProducer.send(reply);
replyProducer.close();
}
} catch (JMSException | InterruptedException e) {
System.err.println(e);
}
}
public static void main(String[] args) {
EchoReplierNode node = null;
try {
node = new EchoReplierNode();
while (true) {
Thread.sleep(1000);
}
} catch (InterruptedException | NamingException | JMSException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.consumer != null)
node.consumer.close();
if (node != null && node.session != null)
node.session.close();
if (node != null && node.connection != null)
node.connection.close();
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,85 @@
package var.mom.jms.echo;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class EchoRequesterNode {
private Connection connection;
private Session session;
private MessageProducer producer;
private MessageConsumer consumer;
private Queue replyQueue;
public EchoRequesterNode() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = (Queue) ctx.lookup(Conf.QUEUE);
producer = session.createProducer(queue);
replyQueue = session.createTemporaryQueue();
consumer = session.createConsumer(replyQueue);
connection.start();
}
public void receiveAndPrintMessages() throws JMSException {
Message request;
while ((request = consumer.receive()) != null) {
try {
if (request instanceof TextMessage) {
TextMessage requestText = (TextMessage) request;
String messageText = requestText.getText();
System.out.println("empfangen: " + messageText);
}
} catch (JMSException e) {
System.err.println(e);
}
}
}
public void sendMessage(String text) throws JMSException {
TextMessage message = session.createTextMessage();
message.setText(text);
message.setJMSReplyTo(replyQueue);
producer.send(message);
}
public static void main(String[] args) {
String text = args[0];
EchoRequesterNode node = null;
try {
node = new EchoRequesterNode();
node.sendMessage(text);
node.receiveAndPrintMessages();
} catch (NamingException | JMSException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.producer != null) {
node.producer.close();
}
if (node != null && node.consumer != null) {
node.consumer.close();
}
if (node != null && node.session != null) {
node.session.close();
}
if (node != null && node.connection != null) {
node.connection.close();
}
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,5 @@
package var.mom.jms.log;
public class Conf {
public static final String QUEUE = "var.mom.jms.log.queue";
}

View File

@ -0,0 +1,68 @@
package var.mom.jms.log;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ConsumerCallbackNode implements MessageListener {
private Connection connection;
private Session session;
private MessageConsumer consumer;
public ConsumerCallbackNode() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Destination queue = (Destination) ctx.lookup(Conf.QUEUE);
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(queue);
consumer.setMessageListener(this);
connection.start();
}
@Override
public void onMessage(Message message) {
try {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String messageText = textMessage.getText();
String priority = textMessage.getStringProperty("Priority");
System.out.println(messageText + " [Priority=" + priority + "]");
}
} catch (JMSException e) {
System.err.println(e);
}
}
public static void main(String[] args) {
long wait = Long.parseLong(args[0]);
ConsumerCallbackNode node = null;
try {
node = new ConsumerCallbackNode();
Thread.sleep(wait);
} catch (InterruptedException | NamingException | JMSException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.consumer != null)
node.consumer.close();
if (node != null && node.session != null)
node.session.close();
if (node != null && node.connection != null)
node.connection.close();
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,68 @@
package var.mom.jms.log;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.MessageListener;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ConsumerFilteredNode implements MessageListener {
private Connection connection;
private Session session;
private MessageConsumer consumer;
public ConsumerFilteredNode() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Destination queue = (Destination) ctx.lookup(Conf.QUEUE);
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(queue, "Priority='high'");
consumer.setMessageListener(this);
connection.start();
}
@Override
public void onMessage(Message message) {
try {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String messageText = textMessage.getText();
String priority = textMessage.getStringProperty("Priority");
System.out.println(messageText + " [Priority=" + priority + "]");
}
} catch (JMSException e) {
System.err.println(e);
}
}
public static void main(String[] args) {
//long wait = Long.parseLong(args[0]);
ConsumerFilteredNode node = null;
try {
node = new ConsumerFilteredNode();
Thread.sleep(10000000);
} catch (InterruptedException | NamingException | JMSException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.consumer != null)
node.consumer.close();
if (node != null && node.session != null)
node.session.close();
if (node != null && node.connection != null)
node.connection.close();
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,62 @@
package var.mom.jms.log;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ConsumerPullNode {
private Connection connection;
private Session session;
private MessageConsumer consumer;
public ConsumerPullNode() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
Destination queue = (Destination) ctx.lookup(Conf.QUEUE);
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
consumer = session.createConsumer(queue);
connection.start();
}
public void receiveAndPrintMessages(long timeout) throws JMSException {
Message message;
while ((message = consumer.receive(timeout)) != null) {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String messageText = textMessage.getText();
System.out.println(messageText);
}
}
}
public static void main(String[] args) {
//long timeout = Long.parseLong(args[0]);
ConsumerPullNode node = null;
try {
node = new ConsumerPullNode();
node.receiveAndPrintMessages(0);
} catch (NamingException | JMSException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.consumer != null)
node.consumer.close();
if (node != null && node.session != null)
node.session.close();
if (node != null && node.connection != null)
node.connection.close();
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,60 @@
package var.mom.jms.log;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class ProducerNode {
private Connection connection;
private Session session;
private MessageProducer producer;
public ProducerNode() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination queue = (Destination) ctx.lookup(Conf.QUEUE);
producer = session.createProducer(queue);
}
public void sendMessage(String text, String priority) throws JMSException {
TextMessage message = session.createTextMessage();
message.setText(text);
message.setStringProperty("Priority", priority);
producer.send(message);
}
public static void main(String[] args) {
String text = "Hi :)";
String priority = "high";
ProducerNode node = null;
try {
node = new ProducerNode();
node.sendMessage(text, priority);
} catch (NamingException | JMSException e) {
System.err.println(e);
} finally {
try {
if (node != null && node.producer != null) {
node.producer.close();
}
if (node != null && node.session != null) {
node.session.close();
}
if (node != null && node.connection != null) {
node.connection.close();
}
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,5 @@
package var.mom.jms.reverse;
public class Conf {
public static final String QUEUE = "var.mom.jms.reverse.queue";
}

View File

@ -0,0 +1,79 @@
package var.mom.jms.reverse;
import var.mom.jms.log.ProducerNode;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class Requester {
private Connection connection;
private Session session;
private MessageProducer producer;
private Queue replyQueue;
private MessageConsumer consumer;
public Requester() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination queue = (Destination) ctx.lookup(Conf.QUEUE);
producer = session.createProducer(queue);
replyQueue = session.createTemporaryQueue();
consumer = session.createConsumer(replyQueue);
connection.start();
}
public void sendMessage(String text, String priority) throws JMSException {
TextMessage message = session.createTextMessage();
message.setText(text);
message.setStringProperty("Priority", priority);
message.setJMSReplyTo(replyQueue);
producer.send(message);
}
public void receiveMessage() throws JMSException {
Message message = consumer.receive();
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
System.out.println("Received: " + textMessage.getText());
}
}
static void main(String[] args) {
String text = "Hiiiiiiillll";
String priority = "High";
Requester node = null;
try {
node = new Requester();
node.sendMessage(text, priority);
node.receiveMessage();
}
catch (NamingException | JMSException e) {
System.err.println(e);
}
finally {
try {
if (node != null && node.producer != null) {
node.producer.close();
}
if (node != null && node.session != null) {
node.session.close();
}
if (node != null && node.connection != null) {
node.connection.close();
}
} catch (JMSException e) {
System.err.println(e);
}
}
}
}

View File

@ -0,0 +1,82 @@
package var.mom.jms.reverse;
import org.w3c.dom.Text;
import javax.jms.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class Reverser implements MessageListener {
private Connection connection;
private Session session;
private MessageConsumer consumer;
public Reverser() throws NamingException, JMSException {
Context ctx = new InitialContext();
ConnectionFactory factory = (ConnectionFactory) ctx.lookup("ConnectionFactory");
connection = factory.createConnection();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination queue = (Destination) ctx.lookup(Conf.QUEUE);
consumer = session.createConsumer(queue);
consumer.setMessageListener(this);
connection.start();
}
@Override
public void onMessage(Message message) {
try {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
System.out.println("Received: " + textMessage.getText());
StringBuilder sb = new StringBuilder();
sb.append(textMessage.getText());
sb.reverse();
Destination replyQueue = message.getJMSReplyTo();
MessageProducer producer = session.createProducer(replyQueue);
TextMessage replyMessage = session.createTextMessage();
replyMessage.setText(sb.toString());
replyMessage.setStringProperty("Priority", message.getStringProperty("Priority"));
producer.send(replyMessage);
}
} catch (JMSException e) {
System.err.println(e);
}
}
static void main(String[] args) {
Reverser node = null;
try {
node = new Reverser();
Thread.sleep(1000000);
}
catch (NamingException | JMSException | InterruptedException e) {
System.err.println(e);
}
finally {
try {
if (node != null && node.consumer != null) {
node.consumer.close();
}
if (node != null && node.session != null) {
node.session.close();
}
if (node != null && node.connection != null) {
node.connection.close();
}
}
catch (JMSException e) {
throw new RuntimeException(e);
}
}
}
}