From 83b7eba59e5676ada709c1f107ba8fc2da3bf0dd Mon Sep 17 00:00:00 2001 From: Peter Hormanns Date: Fri, 12 Jan 2024 18:34:35 +0100 Subject: [PATCH] rollback activemq and openjpa updates --- hsarback/pom.xml | 8 ++-- .../servlets/QueueStatusReceiverServlet.java | 42 ----------------- qserv/hsadmin.properties | 14 ++++++ qserv/pom.xml | 45 ++++++++++++++++--- .../de/hsadmin/core/model/Transaction.java | 10 ++--- .../de/hsadmin/core/qserv/QueueServer.java | 26 +++-------- 6 files changed, 69 insertions(+), 76 deletions(-) create mode 100644 qserv/hsadmin.properties diff --git a/hsarback/pom.xml b/hsarback/pom.xml index 89331f5..0f9af1a 100644 --- a/hsarback/pom.xml +++ b/hsarback/pom.xml @@ -70,13 +70,13 @@ org.apache.velocity - velocity-engine-core - 2.3 + velocity + 1.7 org.apache.openjpa openjpa - 3.2.2 + 2.4.3 junit @@ -93,7 +93,7 @@ org.apache.activemq activemq-all - 5.18.1 + 5.5.0 provided diff --git a/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java b/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java index 3c72b77..eed9ffa 100644 --- a/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java +++ b/hsarback/src/main/java/de/hsadmin/servlets/QueueStatusReceiverServlet.java @@ -16,8 +16,6 @@ import javax.jms.QueueSession; import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; -import javax.naming.NameClassPair; -import javax.naming.NamingEnumeration; import javax.naming.NamingException; import javax.persistence.EntityManager; import javax.servlet.ServletConfig; @@ -26,12 +24,9 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.activemq.ActiveMQConnectionFactory; - import de.hsadmin.core.model.TechnicalException; import de.hsadmin.core.model.TicketValidator; import de.hsadmin.core.model.Transaction; -import de.hsadmin.core.qserv.NullProcessor; import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.util.Config; @@ -41,8 +36,6 @@ public class QueueStatusReceiverServlet extends HttpServlet private static final long serialVersionUID = -5701350884034782083L; - private static boolean initQueuesDone = false; - private String jmsUser; private String jmsPass; private QueueConnectionFactory queueConnectionFactory; @@ -61,14 +54,6 @@ public class QueueStatusReceiverServlet extends HttpServlet isConnected = false; messageCount = 0; errorCount = 0; - try { - if (!initQueuesDone) { - initQueues(); - } - initQueuesDone = true; - } catch (NamingException e) { - throw new ServletException(e); - } try { connect(); } catch (NamingException e) { @@ -83,10 +68,6 @@ public class QueueStatusReceiverServlet extends HttpServlet InitialContext ctx = new InitialContext(); Context env = (Context) ctx.lookup("java:comp/env"); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF"); - if (queueConnectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) queueConnectionFactory; - activeMQConnectionFactory.setTrustAllPackages(true); - } int timeoutCounter = 10; while (!isConnected && (timeoutCounter > 0)) { try { @@ -108,29 +89,6 @@ public class QueueStatusReceiverServlet extends HttpServlet } } - private void initQueues() throws NamingException { - InitialContext ctx = new InitialContext(); - NamingEnumeration list = ctx.list("java:comp/env/jms"); - Transaction transaction = new Transaction("anonymous"); - transaction.beginTransaction(); - EntityManager entityManager = transaction.getEntityManager(); - while (list.hasMore()) { - NameClassPair pair = list.next(); - String jndiName = pair.getName(); - if (jndiName != null && jndiName.startsWith("hsadminSystem-")) { - QueueTask task = new QueueTask(); - task.setProcessor(new NullProcessor()); - entityManager.persist(task); - entityManager.flush(); - String hive = jndiName.substring(14); - transaction.enqueue(hive, task); - } - } - transaction.commitTransaction(); - transaction.close(); - ctx.close(); - } - @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { diff --git a/qserv/hsadmin.properties b/qserv/hsadmin.properties new file mode 100644 index 0000000..abc80cf --- /dev/null +++ b/qserv/hsadmin.properties @@ -0,0 +1,14 @@ +hsadmin.jms.url=ssl://hsh02.hostsharing.net:61617 +hsadmin.jms.username=user-h98 +hsadmin.jms.password=kein-echtes-ppasswort +hsadmin.jms.system-queue=queue.hsadminSystem-h98 +hsadmin.jms.status-queue=queue.hsadminStatus +accountprefix.customer=hsh00 +accountprefix.hostmaster=hsh01 +queues.dns=testdns +queues.mail=testmail +hsadmin.smtp.from=nobody@hostsharing.net +hsadmin.smtp.cc=hostmaster@hostsharing.net +loginURL=TestUmgebung +backendURL=https://config.hostsharing.net:443/hsar/backend +xmlrpcURL=http://localhost:8080/hsar/xmlrpc/hsadmin diff --git a/qserv/pom.xml b/qserv/pom.xml index d2694d6..5a3b2a0 100644 --- a/qserv/pom.xml +++ b/qserv/pom.xml @@ -27,13 +27,13 @@ org.apache.velocity - velocity-engine-core - 2.3 + velocity + 1.7 org.apache.openjpa openjpa - 3.2.2 + 2.4.3 junit @@ -44,7 +44,7 @@ org.apache.activemq activemq-all - 5.18.1 + 5.5.0 provided @@ -68,7 +68,7 @@ org.apache.openjpa openjpa-maven-plugin - 3.2.2 + 2.4.3 **/QueueTask.class,**/Domain.class,**/DomainOption.class,**/EMailAddress.class,**/EMailAlias.class,**/Customer.class,**/Contact.class,**/UnixUser.class,**/Pac.class,**/BasePac.class,**/BaseComponent.class,**/PacComponent.class,**/Component.class,**/Hive.class,**/INetAddress.class,**/Database.class,**/DatabaseUser.class,**/PgSqlDatabase.class,**/MySqlDatabase.class,**/PgSqlUser.class,**/MySqlUser.class @@ -89,5 +89,40 @@ + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + + org.apache.openjpa + + + openjpa-maven-plugin + + + [2.4.3,) + + + enhance + + + + + + + + + + + + diff --git a/qserv/src/main/java/de/hsadmin/core/model/Transaction.java b/qserv/src/main/java/de/hsadmin/core/model/Transaction.java index 4e7f890..13fd71a 100644 --- a/qserv/src/main/java/de/hsadmin/core/model/Transaction.java +++ b/qserv/src/main/java/de/hsadmin/core/model/Transaction.java @@ -15,7 +15,7 @@ import javax.persistence.EntityManager; import javax.persistence.EntityTransaction; import javax.persistence.Query; -import org.apache.activemq.ActiveMQConnectionFactory; +//import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.openjpa.persistence.OpenJPAEntityManager; import de.hsadmin.core.qserv.QueueClient; @@ -43,10 +43,10 @@ public class Transaction { ctx = new InitialContext(); Context env = (Context) ctx.lookup("java:comp/env"); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF"); - if (queueConnectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory; - activeMQconnectionFatory.setTrustAllPackages(true); - } +// if (queueConnectionFactory instanceof ActiveMQConnectionFactory) { +// ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory; +// activeMQconnectionFatory.setTrustAllPackages(true); +// } } catch (NamingException e) { throw new TechnicalException("no jms queue: jms/QueueCF", e); } diff --git a/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java b/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java index f997a7b..bf64403 100644 --- a/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java +++ b/qserv/src/main/java/de/hsadmin/core/qserv/QueueServer.java @@ -7,6 +7,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import javax.jms.Connection; +import javax.jms.ConnectionFactory; import javax.jms.Destination; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -23,8 +24,6 @@ import javax.jms.Session; import javax.naming.Context; import javax.naming.InitialContext; -import org.apache.activemq.ActiveMQConnectionFactory; - public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener { private static final String VERSION_NO = "4.0.11"; @@ -53,13 +52,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except throw new Exception(userHelp(propFile)); } } - FileInputStream propStream = null; - try { - propStream = new FileInputStream(propFile); - } catch (Exception e) { - System.out.println("couldn't read config file " + propFile.getAbsolutePath()); - System.exit(1); - } + FileInputStream propStream = new FileInputStream(propFile); Properties props = new Properties(System.getProperties()); props.load(propStream); propStream.close(); @@ -85,7 +78,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except } }); while (!qServ.connect()) { - Thread.sleep(30000); + Thread.sleep(10000); } while (true) { Thread.sleep(10000); @@ -130,11 +123,8 @@ public class QueueServer extends QueueCommons implements MessageListener, Except // create JMS connection and session try { Context ctx = new InitialContext(); - QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup(jmsFactory); - if (connectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) connectionFactory; - activeMQConnectionFactory.setTrustAllPackages(true); - } + QueueConnectionFactory connectionFactory = + (QueueConnectionFactory) ctx.lookup(jmsFactory); conn = connectionFactory.createQueueConnection(jmsUserName, jmsPassWord); conn.setExceptionListener(this); queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); @@ -215,11 +205,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except try { logger.log(Level.INFO, "sendStatus(" + queueMessage + ")"); Context ctx = new InitialContext(); - QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup(jmsFactory); - if (connectionFactory instanceof ActiveMQConnectionFactory) { - ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) connectionFactory; - activeMQConnectionFactory.setTrustAllPackages(true); - } + ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(jmsFactory); Destination queue = (Destination) ctx.lookup(jmsStatusQueue); statusConnection = connectionFactory.createConnection(jmsUserName, jmsPassWord); statusSession = statusConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);