send MQ message draft

This commit is contained in:
Radek Davidek 2026-02-27 15:58:20 +01:00
parent e9105429e1
commit 0b0b118a3b
5 changed files with 365 additions and 290 deletions

View File

@ -461,16 +461,16 @@
<repository> <repository>
<snapshots><enabled>false</enabled></snapshots> <snapshots><enabled>false</enabled></snapshots>
<releases><enabled>true</enabled></releases> <releases><enabled>true</enabled></releases>
<id>central</id> <id>mcentral</id>
<name>libs-release</name> <name>Maven Central</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/libs-release</url> <url>https://repo1.maven.org/maven2/</url>
</repository> </repository>
<repository> <repository>
<snapshots><enabled>true</enabled></snapshots> <snapshots><enabled>false</enabled></snapshots>
<releases><enabled>false</enabled></releases> <releases><enabled>true</enabled></releases>
<id>snapshots</id> <id>mvnrepo</id>
<name>libs-snapshot</name> <name>MVN Repository</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot</url> <url>https://mvnrepository.com/artifact/</url>
</repository> </repository>
</repositories> </repositories>
<pluginRepositories> <pluginRepositories>

View File

@ -1,23 +1,5 @@
package cz.moneta.test.harness.connectors.messaging; package cz.moneta.test.harness.connectors.messaging;
import com.ibm.msg.client.jms.JmsConnectionFactory;
import com.ibm.msg.client.jms.JmsFactoryFactory;
import com.ibm.msg.client.wmq.WMQConstants;
import cz.moneta.test.harness.connectors.Connector;
import cz.moneta.test.harness.exception.MessagingTimeoutException;
import cz.moneta.test.harness.messaging.model.MessageContentType;
import cz.moneta.test.harness.messaging.model.MqMessageFormat;
import cz.moneta.test.harness.messaging.model.ReceivedMessage;
import javax.jms.BytesMessage;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.JMSProducer;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueBrowser;
import javax.jms.TextMessage;
import java.nio.charset.Charset; import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.Duration; import java.time.Duration;
@ -32,11 +14,30 @@ import java.util.Optional;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.function.Predicate; import java.util.function.Predicate;
import javax.jms.BytesMessage;
import javax.jms.JMSConsumer;
import javax.jms.JMSContext;
import javax.jms.JMSException;
import javax.jms.JMSProducer;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueBrowser;
import javax.jms.TextMessage;
import com.ibm.mq.jms.MQConnectionFactory;
import com.ibm.msg.client.wmq.WMQConstants;
import cz.moneta.test.harness.connectors.Connector;
import cz.moneta.test.harness.exception.MessagingTimeoutException;
import cz.moneta.test.harness.messaging.model.MessageContentType;
import cz.moneta.test.harness.messaging.model.MqMessageFormat;
import cz.moneta.test.harness.messaging.model.ReceivedMessage;
public class IbmMqConnector implements Connector { public class IbmMqConnector implements Connector {
private static final Charset EBCDIC_870 = Charset.forName("IBM870"); private static final Charset EBCDIC_870 = Charset.forName("IBM870");
private static final Charset UTF_8 = StandardCharsets.UTF_8; private static final Charset UTF_8 = StandardCharsets.UTF_8;
private final JmsConnectionFactory connectionFactory; private final MQConnectionFactory connectionFactory;
private final String user; private final String user;
private final String password; private final String password;
private final Object contextLock = new Object(); private final Object contextLock = new Object();
@ -49,7 +50,8 @@ public class IbmMqConnector implements Connector {
String user, String user,
String password, String password,
String keystorePath, String keystorePath,
String keystorePassword) { String keystorePassword,
String cipherSuite) {
this.user = user; this.user = user;
this.password = password; this.password = password;
try { try {
@ -60,15 +62,22 @@ public class IbmMqConnector implements Connector {
} }
} }
JmsFactoryFactory factoryFactory = JmsFactoryFactory.getInstance(WMQConstants.WMQ_PROVIDER); connectionFactory = new MQConnectionFactory();
connectionFactory = factoryFactory.createConnectionFactory(); connectionFactory.setHostName(host);
connectionFactory.setStringProperty(WMQConstants.WMQ_HOST_NAME, host); connectionFactory.setPort(port);
connectionFactory.setIntProperty(WMQConstants.WMQ_PORT, port); connectionFactory.setQueueManager(queueManager);
connectionFactory.setStringProperty(WMQConstants.WMQ_CHANNEL, channel); connectionFactory.setChannel(channel);
connectionFactory.setStringProperty(WMQConstants.WMQ_QUEUE_MANAGER, queueManager); connectionFactory.setTransportType(WMQConstants.WMQ_CM_CLIENT);
connectionFactory.setIntProperty(WMQConstants.WMQ_CONNECTION_MODE, WMQConstants.WMQ_CM_CLIENT); if (user != null && !user.isBlank()) {
connectionFactory.setStringProperty(WMQConstants.USERID, user); connectionFactory.setStringProperty(WMQConstants.USERID, user);
}
if (password != null && !password.isBlank()) {
connectionFactory.setStringProperty(WMQConstants.PASSWORD, password); connectionFactory.setStringProperty(WMQConstants.PASSWORD, password);
}
if (cipherSuite != null && !cipherSuite.isBlank()) {
connectionFactory.setSSLCipherSuite(cipherSuite);
}
} catch (Exception e) { } catch (Exception e) {
throw new IllegalStateException("Failed to initialize IBM MQ connection factory", e); throw new IllegalStateException("Failed to initialize IBM MQ connection factory", e);
} }

View File

@ -25,6 +25,7 @@ public class IbmMqEndpoint implements Endpoint {
private static final String CONFIG_VAULT_PATH = "vault.path.messaging.ibmmq"; private static final String CONFIG_VAULT_PATH = "vault.path.messaging.ibmmq";
private static final String CONFIG_USERNAME = "messaging.ibmmq.username"; private static final String CONFIG_USERNAME = "messaging.ibmmq.username";
private static final String CONFIG_PASSWORD = "messaging.ibmmq.password"; private static final String CONFIG_PASSWORD = "messaging.ibmmq.password";
private static final String CONFIG_SSL_CYPHER_SUITES = "messaging.ibmmq.ssl-cipher-suite";
private final StoreAccessor store; private final StoreAccessor store;
private volatile IbmMqConnector connector; private volatile IbmMqConnector connector;
@ -86,8 +87,9 @@ public class IbmMqEndpoint implements Endpoint {
String password = resolveSecret(CONFIG_PASSWORD, "password"); String password = resolveSecret(CONFIG_PASSWORD, "password");
String keystorePath = store.getConfig(CONFIG_KEYSTORE_PATH); String keystorePath = store.getConfig(CONFIG_KEYSTORE_PATH);
String keystorePassword = store.getConfig(CONFIG_KEYSTORE_PASSWORD); String keystorePassword = store.getConfig(CONFIG_KEYSTORE_PASSWORD);
String sslCipherSuites = store.getConfig(CONFIG_SSL_CYPHER_SUITES);
return new IbmMqConnector(host, port, channel, queueManager, username, password, keystorePath, keystorePassword); return new IbmMqConnector(host, port, channel, queueManager, username, password, keystorePath, keystorePassword, sslCipherSuites);
} }
private String resolveSecret(String localConfigKey, String vaultKey) { private String resolveSecret(String localConfigKey, String vaultKey) {

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" <project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>cz.moneta.test</groupId> <groupId>cz.moneta.test</groupId>
@ -9,6 +11,7 @@
<harness.version>7.55-SNAPSHOT</harness.version> <harness.version>7.55-SNAPSHOT</harness.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.platform.version>1.5.1</junit.platform.version> <junit.platform.version>1.5.1</junit.platform.version>
<ibm.mq.version>9.4.2.0</ibm.mq.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -16,6 +19,17 @@
<artifactId>harness</artifactId> <artifactId>harness</artifactId>
<version>${harness.version}</version> <version>${harness.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>${ibm.mq.version}</version>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
</dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
@ -83,7 +97,8 @@
<goal>copy-dependencies</goal> <goal>copy-dependencies</goal>
</goals> </goals>
<configuration> <configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory> <outputDirectory>
${project.build.directory}/lib</outputDirectory>
<includeScope>runtime</includeScope> <includeScope>runtime</includeScope>
</configuration> </configuration>
</execution> </execution>
@ -101,10 +116,17 @@
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version> <version>2.22.2</version>
<configuration> <configuration>
<argLine>--add-opens java.base/java.lang.invoke=ALL-UNNAMED -Dhttp.proxyHost=wsa-aws.mbid.cz -Dhttp.proxyPort=8008 -Dhttps.proxyHost=wsa-aws.mbid.cz -Dhttps.proxyPort=8008 <argLine>
--add-opens
java.base/java.lang.invoke=ALL-UNNAMED
-Dhttp.proxyHost=wsa-aws.mbid.cz
-Dhttp.proxyPort=8008
-Dhttps.proxyHost=wsa-aws.mbid.cz
-Dhttps.proxyPort=8008
-Dhttp.nonProxyHosts="elasticclusterawscoord*|elasticclusterawsingest*|jenkinslivex*|cbltstx|vault|vault.svc.k8s.moneta-containers.net|selenium-hub.svc.k8s.moneta-containers.net|jira*|d000*|x000*|l000*|digdev*|r000|spii-live-significant|mbczvl1dl0ihat3.ux.mbid.cz|mbczvl1dl0ihet3.ux.mbid.cz|wso2-fve-gw.ux.mbid.cz|wso2eifve.lb.mbid.cz|wso2eippe.lb.mbid.cz|wso2-ppe-gw.ux.mbid.cz|mbczvl0bl0enin3.ux.mbid.cz|wso2-tst1-gw.ux.mbid.cz|wso2eitst1.lb.mbid.cz|wso2-edu-gw.ux.mbid.cz|mbczvl0bl0enin5.ux.mbid.cz|mbczvl1dl0enin6.ux.mbid.cz|wso2api01-wso2-02.ux.mbid.cz|api-szr.tst.moneta-containers.net|api-szr.ppe.moneta-containers.net|docker1|mbczvl1dl0mockt.ux.mbid.cz|api.tst.moneta-containers.net|api.ppe.moneta-containers.net"</argLine> -Dhttp.nonProxyHosts="elasticclusterawscoord*|elasticclusterawsingest*|jenkinslivex*|cbltstx|vault|vault.svc.k8s.moneta-containers.net|selenium-hub.svc.k8s.moneta-containers.net|jira*|d000*|x000*|l000*|digdev*|r000|spii-live-significant|mbczvl1dl0ihat3.ux.mbid.cz|mbczvl1dl0ihet3.ux.mbid.cz|wso2-fve-gw.ux.mbid.cz|wso2eifve.lb.mbid.cz|wso2eippe.lb.mbid.cz|wso2-ppe-gw.ux.mbid.cz|mbczvl0bl0enin3.ux.mbid.cz|wso2-tst1-gw.ux.mbid.cz|wso2eitst1.lb.mbid.cz|wso2-edu-gw.ux.mbid.cz|mbczvl0bl0enin5.ux.mbid.cz|mbczvl1dl0enin6.ux.mbid.cz|wso2api01-wso2-02.ux.mbid.cz|api-szr.tst.moneta-containers.net|api-szr.ppe.moneta-containers.net|docker1|mbczvl1dl0mockt.ux.mbid.cz|api.tst.moneta-containers.net|api.ppe.moneta-containers.net"</argLine>
<includes> <includes>
<include>cz.moneta.test.sandbox.demo.HarnessDemoTest.java</include> <include>
cz.moneta.test.sandbox.demo.HarnessDemoTest.java</include>
</includes> </includes>
<trimStackTrace>false</trimStackTrace> <trimStackTrace>false</trimStackTrace>
<useFile>false</useFile> <useFile>false</useFile>
@ -114,26 +136,37 @@
</build> </build>
<repositories> <repositories>
<repository> <repository>
<releases>
<enabled>true</enabled>
</releases>
<snapshots> <snapshots>
<enabled>false</enabled> <enabled>false</enabled>
</snapshots> </snapshots>
<id>central</id> <releases>
<name>libs-release</name> <enabled>true</enabled>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/libs-release</url> </releases>
<id>confluent</id>
<name>Confluent Hub</name>
<url>https://packages.confluent.io/maven/</url>
</repository> </repository>
<repository> <repository>
<releases>
<enabled>false</enabled>
</releases>
<snapshots> <snapshots>
<enabled>true</enabled> <enabled>false</enabled>
</snapshots> </snapshots>
<id>snapshots</id> <releases>
<name>libs-snapshot</name> <enabled>true</enabled>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot</url> </releases>
<id>mcentral</id>
<name>Maven Central</name>
<url>https://repo1.maven.org/maven2/</url>
</repository>
<repository>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<id>mvnrepo</id>
<name>MVN Repository</name>
<url>https://mvnrepository.com/artifact/</url>
</repository> </repository>
</repositories> </repositories>
<pluginRepositories> <pluginRepositories>
@ -146,7 +179,8 @@
</snapshots> </snapshots>
<id>central</id> <id>central</id>
<name>plugins-release</name> <name>plugins-release</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release</url> <url>
https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release</url>
</pluginRepository> </pluginRepository>
<pluginRepository> <pluginRepository>
<releases> <releases>
@ -157,7 +191,8 @@
</snapshots> </snapshots>
<id>snapshots</id> <id>snapshots</id>
<name>plugins-snapshot</name> <name>plugins-snapshot</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot</url> <url>
https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot</url>
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>
</profile> </profile>
@ -191,7 +226,8 @@
<configuration> <configuration>
<archive> <archive>
<manifest> <manifest>
<mainClass>cz.moneta.test.testrunner.TestRunner</mainClass> <mainClass>
cz.moneta.test.testrunner.TestRunner</mainClass>
</manifest> </manifest>
</archive> </archive>
<descriptors> <descriptors>
@ -213,7 +249,8 @@
</snapshots> </snapshots>
<id>central</id> <id>central</id>
<name>libs-release</name> <name>libs-release</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/libs-release</url> <url>
https://artifactory-aws.ux.mbid.cz/artifactory/libs-release</url>
</repository> </repository>
<repository> <repository>
<releases> <releases>
@ -224,7 +261,8 @@
</snapshots> </snapshots>
<id>snapshots</id> <id>snapshots</id>
<name>libs-snapshot</name> <name>libs-snapshot</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot</url> <url>
https://artifactory-aws.ux.mbid.cz/artifactory/libs-snapshot</url>
</repository> </repository>
</repositories> </repositories>
<pluginRepositories> <pluginRepositories>
@ -237,7 +275,8 @@
</snapshots> </snapshots>
<id>central</id> <id>central</id>
<name>plugins-release</name> <name>plugins-release</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release</url> <url>
https://artifactory-aws.ux.mbid.cz/artifactory/plugins-release</url>
</pluginRepository> </pluginRepository>
<pluginRepository> <pluginRepository>
<releases> <releases>
@ -248,7 +287,8 @@
</snapshots> </snapshots>
<id>snapshots</id> <id>snapshots</id>
<name>plugins-snapshot</name> <name>plugins-snapshot</name>
<url>https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot</url> <url>
https://artifactory-aws.ux.mbid.cz/artifactory/plugins-snapshot</url>
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>
</profile> </profile>

View File

@ -0,0 +1,24 @@
package cz.moneta.test.system.messaging;
import cz.moneta.test.dsl.Harness;
import cz.moneta.test.harness.annotations.TestCase;
import cz.moneta.test.harness.annotations.TestScenario;
@TestScenario(name = "Send MQ message")
public class SendMQMessage {
@TestCase(name = "Send MQ message")
public void sendMessage(Harness harness) {
String message = "Hello, this is a test message!";
String destination = "mainframe-utf8-queue";
System.setProperty("javax.net.ssl.trustStore", "/home/kamma/tmp/mq-docker/ibmmq-client.p12");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
//System.setProperty("jdk.tls.client.protocols", "TLSv1.2");
//System.setProperty("javax.net.ssl.trustStoreType", "PKCS12");
harness.withMessaging().to(destination).asJson().withPayload(message).send();
}
}