Skip to content

Instantly share code, notes, and snippets.

@ashutoshchauhan13
Last active December 1, 2023 13:45
Show Gist options
  • Save ashutoshchauhan13/73948ccbdbb4c8456d6f473e1b97c607 to your computer and use it in GitHub Desktop.
Save ashutoshchauhan13/73948ccbdbb4c8456d6f473e1b97c607 to your computer and use it in GitHub Desktop.
Useful links
https://stackoverflow.com/questions/66213659/cannot-read-parts-content-fluxdatabuffer-into-a-single-string
https://springframework.guru/using-yaml-in-spring-boot-to-configure-logback/
https://dzone.com/articles/step-by-step-procedure-of-spring-webflux-multipart
.flatMap(s -> ServerResponse.ok()
.contentType(MediaType.TEXT_PLAIN)
.bodyValue(s))
https://github.com/spring-projects/spring-framework/blob/main/spring-core/src/test/java/org/springframework/core/io/buffer/DataBufferUtilsTests.java
https://stackoverflow.com/questions/50091069/downlolad-and-save-file-from-clientrequest-using-exchangefunction-in-project-rea
https://stackoverflow.com/questions/30073980/csv-file-with-id-as-first-item-is-corrupt-in-excel
https://stackoverflow.com/questions/3327312/how-can-i-drop-all-the-tables-in-a-postgresql-database
https://developer.ibm.com/tutorials/mq-secure-msgs-tls/
https://www.appsloveworld.com/springboot/100/8/how-to-serve-files-pdf-files-the-reactive-way-in-spring
https://blog.knoldus.com/spring-webflux-testing-your-router-functions-with-webtestclient/
https://github.com/spring-projects/spring-framework/blob/main/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java
https://github.com/spring-projects/spring-framework/blob/main/spring-webflux/src/test/java/org/springframework/web/reactive/function/server/RouterFunctionsTests.java
https://stackoverflow.com/questions/10802798/spring-data-jpa-query-with-parameter-properties
https://www.appsloveworld.com/springboot/100/8/how-to-serve-files-pdf-files-the-reactive-way-in-spring
https://stackoverflow.com/questions/56911468/spring-boot-exporting-huge-database-to-csv-via-rest-endpoint
Caused by: javax.net.ssl.SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
https://developer.ibm.com/tutorials/mq-secure-msgs-tls/
https://github.com/ibm-messaging/mq-jms-spring
https://stackoverflow.com/questions/63482370/unable-to-find-a-valid-certification-path-to-requested-target
https://stackoverflow.com/questions/27350634/how-to-yum-install-node-js-on-amazon-linux
https://github.com/ibm-messaging/mq-jms-spring/blob/master/samples/s3.jms3/build.gradle
https://stackoverflow.com/questions/71686916/while-establishing-ssl-between-ibm-mq-and-jms-client-recieving-com-ibm-mq-jmqi
https://www.ibm.com/support/pages/troubleshooting-ibm-mq-javajms-ssl-configurations
https://www.ibm.com/docs/en/ibm-mq/7.5?topic=order-ssl-peer-sslpeer
https://gist.github.com/diegopacheco/9ddbafcabb6b812ef69db9f9c8a28ba3
https://stackoverflow.com/questions/27350634/how-to-yum-install-node-js-on-amazon-linux
https://developer.ibm.com/tutorials/configuring-mutual-tls-authentication-java-messaging-app/
https://projectreactor.io/docs/kafka/release/reference/
https://github.com/Kevded/example-reactive-spring-kafka-consumer-and-producer
https://gist.github.com/vzickner/577c53164a97b9918a49e6c0235813f4
https://www.baeldung.com/java-stax
https://josdem.io/techtalk/spring/spring_webflux_jaxb/
https://stackoverflow.com/questions/63097944/how-to-store-jks-certificate-in-aws-secret-manager
https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/configure-mutual-tls-authentication-for-applications-running-on-amazon-eks.html
https://stackoverflow.com/questions/9091418/how-to-execute-junit-testsuite-with-some-delay-between-each-testcase
https://stackoverflow.com/questions/73199862/test-kafka-consumer-using-embddedkafka-fail-when-launching-a-batch-of-tests
https://developer.ibm.com/tutorials/mq-connect-app-queue-manager-containers/
https://github.com/ibm-messaging/mq-dev-patterns/tree/master/reactive-amqp/amqp-vertx
https://github.com/defmsy/ibm-reactive-mq-poc/tree/master
https://blog.twitter.com/engineering/en_us/topics/infrastructure/2020/deleting-data-distributed-throughout-your-microservices-architecture
https://stackoverflow.com/questions/66132135/is-it-possible-to-create-a-queue-listener-using-web-flux-spring-integration
https://stackoverflow.com/questions/43126775/how-to-create-a-spring-reactor-flux-from-a-activemq-queue
https://github.com/apache/camel-k-examples/blob/4324d4c3f9af09249197f3fef71c372df1e34ac1/generic-examples/ibm-mq/MQRoute.java#L51
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.16.0</version> <!-- Make sure to use the latest version -->
<scope>test</scope>
</dependency>
dependencies {
testImplementation 'org.testcontainers:testcontainers:1.16.0' // Make sure to use the latest version
testImplementation 'org.testcontainers:ibm-mq:1.16.0' // Make sure to use the latest version
}
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.testcontainers.containers.IBMWebSphereMQContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@Testcontainers
@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)
public class IBMMqIntegrationTest {
@Container
private static final IBMWebSphereMQContainer mqContainer = new IBMWebSphereMQContainer()
.withEnv("LICENSE", "accept")
.withQueueManager("QMGR")
.withChannel("DEV.APP.SVRCONN")
.withExposedPorts(1414);
// Your test methods here, which interact with the IBM MQ
@Test
public void testSendMessageAndReceive() {
// Example test logic to send and receive messages from IBM MQ
// Use mqContainer.getBootstrapAddress() to get the connection string
}
}
# src/test/resources/application.properties
ibm.mq.queueManager=QMGR
ibm.mq.channel=DEV.APP.SVRCONN
ibm.mq.host=${MQ_CONTAINER_IP} # Use the IP of the MQ container here
ibm.mq.port=${MQ_CONTAINER_PORT} # Use the port of the MQ container here (1414 in this example)
ibm.mq.user=admin # Adjust the user and password as per your MQ configuration
ibm.mq.password=passw0rd
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.TestInstance;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
@Testcontainers
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
public class MqTestContainerConfiguration {
// IBM MQ Docker image and port configuration
private static final String IBM_MQ_DOCKER_IMAGE = "ibmcom/mq";
private static final int IBM_MQ_PORT = 1414;
@Container
public GenericContainer<?> ibmMqContainer = new GenericContainer<>(IBM_MQ_DOCKER_IMAGE)
.withExposedPorts(IBM_MQ_PORT)
.withEnv("LICENSE", "accept")
.withEnv("MQ_QMGR_NAME", "QM1")
.withEnv("MQ_ENABLE_METRICS", "false");
@BeforeAll
public void setUp() {
// Get the actual IBM MQ connection properties
String ibmMqHost = ibmMqContainer.getHost();
Integer ibmMqPort = ibmMqContainer.getFirstMappedPort();
// Set up Spring Boot properties to connect to IBM MQ
System.setProperty("ibm.mq.connName", ibmMqHost + "(" + ibmMqPort + ")");
System.setProperty("ibm.mq.channel", "DEV.APP.SVRCONN");
System.setProperty("ibm.mq.user", "admin");
System.setProperty("ibm.mq.password", "passw0rd");
System.setProperty("ibm.mq.queueManager", "QM1");
}
}
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jms.core.JmsTemplate;
@SpringBootTest
public class MqIntegrationTest {
@Autowired
private JmsTemplate jmsTemplate;
@Test
public void testSendMessageToQueue() {
// Assuming you have a queue named "TEST.QUEUE" on the IBM MQ server
String queueName = "TEST.QUEUE";
String message = "Hello, IBM MQ!";
jmsTemplate.convertAndSend(queueName, message);
}
}
<!-- TestContainers -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>1.16.0</version>
<scope>test</scope>
</dependency>
<!-- IBM MQ -->
<dependency>
<groupId>com.ibm.mq</groupId>
<artifactId>com.ibm.mq.allclient</artifactId>
<version>9.2.3.0</version>
</dependency>
https://stackoverflow.com/questions/49558546/run-shell-script-from-java-code
https://stackoverflow.com/questions/50953877/jmstemplate-with-receive-timeout-no-wait-doesnt-retrieve-messages-from-jms-queu
https://stackoverflow.com/questions/57799546/kafka-how-to-mock-consumer-record
https://www.baeldung.com/spring-boot-docker-start-with-profile
import com.ibm.mq.jms.MQConnectionFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.connection.JtaConnectionFactoryWrapper;
import org.springframework.jms.core.JmsTemplate;
import javax.jms.ConnectionFactory;
@Configuration
@EnableJms
public class MqConfig {
@Value("${ibm.mq.host}")
private String host;
@Value("${ibm.mq.port}")
private int port;
@Value("${ibm.mq.queueManager}")
private String queueManager;
@Value("${ibm.mq.channel}")
private String channel;
@Value("${ibm.mq.sslCipherSuite}")
private String sslCipherSuite;
@Value("${ibm.mq.sslKeyStore}")
private String sslKeyStore;
@Value("${ibm.mq.sslKeyStorePassword}")
private String sslKeyStorePassword;
@Bean
public ConnectionFactory mqConnectionFactory() {
MQConnectionFactory mqConnectionFactory = new MQConnectionFactory();
mqConnectionFactory.setHostName(host);
mqConnectionFactory.setPort(port);
mqConnectionFactory.setQueueManager(queueManager);
mqConnectionFactory.setChannel(channel);
// Configure SSL properties for mTLS
mqConnectionFactory.setSSLCipherSuite(sslCipherSuite);
mqConnectionFactory.setSSLKeyStore(sslKeyStore);
mqConnectionFactory.setSSLKeyStorePassword(sslKeyStorePassword);
return new JtaConnectionFactoryWrapper(mqConnectionFactory);
}
@Bean
public JmsTemplate jmsTemplate() {
return new JmsTemplate(mqConnectionFactory());
}
}
ibm.mq.host=<MQ_HOST>
ibm.mq.port=<MQ_PORT>
ibm.mq.queueManager=<QUEUE_MANAGER_NAME>
ibm.mq.channel=<CHANNEL_NAME>
ibm.mq.sslCipherSuite=<SSL_CIPHER_SUITE>
ibm.mq.sslKeyStore=<PATH_TO_KEYSTORE_FILE>
ibm.mq.sslKeyStorePassword=<KEYSTORE_PASSWORD>
https://blog.gembaacademy.com/2009/04/21/the-way-of-the-goose-5-leadership-lessons/
https://medium.com/swlh/data-liberation-pattern-using-debezium-engine-4fd32b92d826
private Mono<ExecUnitsQueryResponse> getExecUnitsQueryResponseErrorMono(
ExecUnitsQueryResponse execUnitsQueryResponse,
String firstTradePartyIdentifier,
String secondTradePartyIdentifier,
String tradePartyIdentifierErrorMsgCopy,
String regexTarget) {
List<String> errorMessage = new ArrayList<>();
Optional.of(execUnitsQueryResponse)
.map(ExecUnitsQueryResponse::getExecutingUnits)
.filter(units -> !units.isEmpty())
.map(units -> units.get(0).getPartyIds())
.filter(partyIds -> !partyIds.isEmpty())
.filter(partyIds -> partyIds.stream().noneMatch(item -> item.getPartyId().equals(firstTradePartyIdentifier)))
.ifPresent(units -> errorMessage.add(tradePartyIdentifierErrorMsgCopy.replaceFirst(regexTarget, firstTradePartyIdentifier)));
Optional.of(execUnitsQueryResponse)
.map(ExecUnitsQueryResponse::getExecutingUnits)
.filter(units -> !units.isEmpty())
.map(units -> units.get(0).getPartyIds())
.filter(partyIds -> !partyIds.isEmpty())
.filter(partyIds -> partyIds.stream().noneMatch(item -> item.getPartyId().equals(secondTradePartyIdentifier)))
.ifPresent(units -> errorMessage.add(tradePartyIdentifierErrorMsgCopy.replaceFirst(regexTarget, secondTradePartyIdentifier)));
ExecUnitErrorDescription execUnitErrorDescription;
try {
execUnitErrorDescription = ExecUnitErrorDescription.builder().withErrors(errorMessage).build();
return Mono.error(new ExecUnitResponseException(
objectMapper.writer().withDefaultPrettyPrinter().writeValueAsString(execUnitErrorDescription)));
} catch (JsonProcessingException e) {
Log.error(e.getMessage());
return Mono.error(e);
}
}
https://www.fintechnorth.uk/digital-assets-the-next-generation-of-finance-webinar-write-up/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment