rollback activemq and openjpa updates

This commit is contained in:
Peter Hormanns 2024-01-12 18:34:35 +01:00
parent 471e666215
commit 83b7eba59e
6 changed files with 69 additions and 76 deletions

View File

@ -70,13 +70,13 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId> <artifactId>velocity</artifactId>
<version>2.3</version> <version>1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId> <artifactId>openjpa</artifactId>
<version>3.2.2</version> <version>2.4.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -93,7 +93,7 @@
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId> <artifactId>activemq-all</artifactId>
<version>5.18.1</version> <version>5.5.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@ -16,8 +16,6 @@ import javax.jms.QueueSession;
import javax.jms.Session; import javax.jms.Session;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.naming.NameClassPair;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException; import javax.naming.NamingException;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.servlet.ServletConfig; import javax.servlet.ServletConfig;
@ -26,12 +24,9 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.activemq.ActiveMQConnectionFactory;
import de.hsadmin.core.model.TechnicalException; import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.core.model.TicketValidator; import de.hsadmin.core.model.TicketValidator;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.qserv.NullProcessor;
import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;
@ -41,8 +36,6 @@ public class QueueStatusReceiverServlet extends HttpServlet
private static final long serialVersionUID = -5701350884034782083L; private static final long serialVersionUID = -5701350884034782083L;
private static boolean initQueuesDone = false;
private String jmsUser; private String jmsUser;
private String jmsPass; private String jmsPass;
private QueueConnectionFactory queueConnectionFactory; private QueueConnectionFactory queueConnectionFactory;
@ -61,14 +54,6 @@ public class QueueStatusReceiverServlet extends HttpServlet
isConnected = false; isConnected = false;
messageCount = 0; messageCount = 0;
errorCount = 0; errorCount = 0;
try {
if (!initQueuesDone) {
initQueues();
}
initQueuesDone = true;
} catch (NamingException e) {
throw new ServletException(e);
}
try { try {
connect(); connect();
} catch (NamingException e) { } catch (NamingException e) {
@ -83,10 +68,6 @@ public class QueueStatusReceiverServlet extends HttpServlet
InitialContext ctx = new InitialContext(); InitialContext ctx = new InitialContext();
Context env = (Context) ctx.lookup("java:comp/env"); Context env = (Context) ctx.lookup("java:comp/env");
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF"); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
if (queueConnectionFactory instanceof ActiveMQConnectionFactory) {
ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) queueConnectionFactory;
activeMQConnectionFactory.setTrustAllPackages(true);
}
int timeoutCounter = 10; int timeoutCounter = 10;
while (!isConnected && (timeoutCounter > 0)) { while (!isConnected && (timeoutCounter > 0)) {
try { try {
@ -108,29 +89,6 @@ public class QueueStatusReceiverServlet extends HttpServlet
} }
} }
private void initQueues() throws NamingException {
InitialContext ctx = new InitialContext();
NamingEnumeration<NameClassPair> 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 @Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException { throws ServletException, IOException {

14
qserv/hsadmin.properties Normal file
View File

@ -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

View File

@ -27,13 +27,13 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId> <artifactId>velocity</artifactId>
<version>2.3</version> <version>1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId> <artifactId>openjpa</artifactId>
<version>3.2.2</version> <version>2.4.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -44,7 +44,7 @@
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId> <artifactId>activemq-all</artifactId>
<version>5.18.1</version> <version>5.5.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -68,7 +68,7 @@
<plugin> <plugin>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId> <artifactId>openjpa-maven-plugin</artifactId>
<version>3.2.2</version> <version>2.4.3</version>
<configuration> <configuration>
<includes> <includes>
**/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 **/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 @@
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.openjpa
</groupId>
<artifactId>
openjpa-maven-plugin
</artifactId>
<versionRange>
[2.4.3,)
</versionRange>
<goals>
<goal>enhance</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build> </build>
</project> </project>

View File

@ -15,7 +15,7 @@ import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction; import javax.persistence.EntityTransaction;
import javax.persistence.Query; import javax.persistence.Query;
import org.apache.activemq.ActiveMQConnectionFactory; //import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.openjpa.persistence.OpenJPAEntityManager; import org.apache.openjpa.persistence.OpenJPAEntityManager;
import de.hsadmin.core.qserv.QueueClient; import de.hsadmin.core.qserv.QueueClient;
@ -43,10 +43,10 @@ public class Transaction {
ctx = new InitialContext(); ctx = new InitialContext();
Context env = (Context) ctx.lookup("java:comp/env"); Context env = (Context) ctx.lookup("java:comp/env");
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF"); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
if (queueConnectionFactory instanceof ActiveMQConnectionFactory) { // if (queueConnectionFactory instanceof ActiveMQConnectionFactory) {
ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory; // ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory;
activeMQconnectionFatory.setTrustAllPackages(true); // activeMQconnectionFatory.setTrustAllPackages(true);
} // }
} catch (NamingException e) { } catch (NamingException e) {
throw new TechnicalException("no jms queue: jms/QueueCF", e); throw new TechnicalException("no jms queue: jms/QueueCF", e);
} }

View File

@ -7,6 +7,7 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.jms.Connection; import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination; import javax.jms.Destination;
import javax.jms.ExceptionListener; import javax.jms.ExceptionListener;
import javax.jms.JMSException; import javax.jms.JMSException;
@ -23,8 +24,6 @@ import javax.jms.Session;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import org.apache.activemq.ActiveMQConnectionFactory;
public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener { public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener {
private static final String VERSION_NO = "4.0.11"; 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)); throw new Exception(userHelp(propFile));
} }
} }
FileInputStream propStream = null; FileInputStream propStream = new FileInputStream(propFile);
try {
propStream = new FileInputStream(propFile);
} catch (Exception e) {
System.out.println("couldn't read config file " + propFile.getAbsolutePath());
System.exit(1);
}
Properties props = new Properties(System.getProperties()); Properties props = new Properties(System.getProperties());
props.load(propStream); props.load(propStream);
propStream.close(); propStream.close();
@ -85,7 +78,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
} }
}); });
while (!qServ.connect()) { while (!qServ.connect()) {
Thread.sleep(30000); Thread.sleep(10000);
} }
while (true) { while (true) {
Thread.sleep(10000); Thread.sleep(10000);
@ -130,11 +123,8 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
// create JMS connection and session // create JMS connection and session
try { try {
Context ctx = new InitialContext(); Context ctx = new InitialContext();
QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup(jmsFactory); QueueConnectionFactory connectionFactory =
if (connectionFactory instanceof ActiveMQConnectionFactory) { (QueueConnectionFactory) ctx.lookup(jmsFactory);
ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) connectionFactory;
activeMQConnectionFactory.setTrustAllPackages(true);
}
conn = connectionFactory.createQueueConnection(jmsUserName, jmsPassWord); conn = connectionFactory.createQueueConnection(jmsUserName, jmsPassWord);
conn.setExceptionListener(this); conn.setExceptionListener(this);
queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
@ -215,11 +205,7 @@ public class QueueServer extends QueueCommons implements MessageListener, Except
try { try {
logger.log(Level.INFO, "sendStatus(" + queueMessage + ")"); logger.log(Level.INFO, "sendStatus(" + queueMessage + ")");
Context ctx = new InitialContext(); Context ctx = new InitialContext();
QueueConnectionFactory connectionFactory = (QueueConnectionFactory) ctx.lookup(jmsFactory); ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(jmsFactory);
if (connectionFactory instanceof ActiveMQConnectionFactory) {
ActiveMQConnectionFactory activeMQConnectionFactory = (ActiveMQConnectionFactory) connectionFactory;
activeMQConnectionFactory.setTrustAllPackages(true);
}
Destination queue = (Destination) ctx.lookup(jmsStatusQueue); Destination queue = (Destination) ctx.lookup(jmsStatusQueue);
statusConnection = connectionFactory.createConnection(jmsUserName, jmsPassWord); statusConnection = connectionFactory.createConnection(jmsUserName, jmsPassWord);
statusSession = statusConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); statusSession = statusConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);