-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update dependencies for MQ 9.2.1, Spring Boot 2.4.0
- Loading branch information
Showing
15 changed files
with
194 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.3.5 | ||
2.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# This script compiles and runs the sample program in this directory. | ||
# | ||
# The program puts a single message to the DEV.QUEUE.1 queue and tries to | ||
# retrieve it via a JMS Listener. | ||
# | ||
# You may need to modify the application.properties file to get it to | ||
# connect to your queue manager. | ||
|
||
###### Cleanup from previous runs | ||
# Kill any old instances of the application | ||
ps -ef|grep gradle | grep sample2.Application | awk '{print $2}' | xargs kill -9 >/dev/null 2>&1 | ||
# and try to clear the queue (assuming it's a local queue manager) | ||
echo "CLEAR QLOCAL(DEV.QUEUE.1)" | runmqsc -e QM1 >/dev/null 2>&1 | ||
###### | ||
|
||
# Now run the program. Build using the gradle wrapper in parent directory | ||
cd ../.. | ||
|
||
./gradlew -p samples/s2 bootRun |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
} | ||
dependencies { | ||
classpath("org.springframework.boot:spring-boot-gradle-plugin:2.0.5.RELEASE") | ||
} | ||
} | ||
|
||
|
||
apply plugin: 'java' | ||
apply plugin: 'maven' | ||
apply plugin: 'org.springframework.boot' | ||
|
||
// The local, flatDir configuration lets us use a modified version from | ||
// this repository without needing it released via maven | ||
repositories { | ||
flatDir() { | ||
dirs '../../mq-jms-spring-boot-starter' | ||
} | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile("com.ibm.mq:mq-jms-spring-boot-starter:2.4.0") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright © 2017, 2020 IBM Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
|
||
rootProject.name = 'mq-jms-spring-sample2' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
/* | ||
* Copyright © 2017, 2020 IBM Corp. All rights reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file | ||
* except in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the | ||
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
// An example of using the Spring Boot JmsTemplate in conjunction with local transactions | ||
// | ||
// This program connects to a queue manager, puts a message and then tries to move the message | ||
// from one queue to another, but choosing to fail that movement through a rollback of the | ||
// transaction. Despite using a Spring TransactionManager object, there is no distributed (XA or | ||
// two-phase) transaction created. | ||
// | ||
// An equivalent MQI program would have this logic: | ||
// MQPUT(q1) with SYNCPOINT | ||
// MQCMIT | ||
// MQGET(q1) with SYNCPOINT | ||
// MQPUT(q2) with SYNCPOINT | ||
// MQBACK | ||
|
||
package sample2; | ||
|
||
import java.util.Date; | ||
|
||
import javax.jms.Message; | ||
|
||
import org.springframework.boot.SpringApplication; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.context.ConfigurableApplicationContext; | ||
import org.springframework.jms.annotation.EnableJms; | ||
import org.springframework.jms.connection.JmsTransactionManager; | ||
import org.springframework.jms.core.JmsTemplate; | ||
import org.springframework.transaction.TransactionStatus; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
@SpringBootApplication | ||
@EnableJms | ||
@EnableTransactionManagement | ||
public class Application { | ||
|
||
static final String qName1 = "DEV.QUEUE.1"; // A queue from the default MQ Developer container config | ||
static final String qName2 = "DEV.QUEUE.2"; // Another queue from the default MQ Developer container config | ||
|
||
public static void main(String[] args) { | ||
|
||
// Launch the application | ||
ConfigurableApplicationContext context = SpringApplication.run(Application.class, args); | ||
|
||
// Create a transaction manager object that will be used to control commit/rollback of operations. | ||
JmsTransactionManager tm = new JmsTransactionManager(); | ||
|
||
printStarted(); | ||
|
||
// Create the JMS Template object to control connections and sessions. | ||
JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class); | ||
|
||
// Associate the connection factory with the transaction manager | ||
tm.setConnectionFactory(jmsTemplate.getConnectionFactory()); | ||
|
||
// This starts a new transaction scope. "null" can be used to get a default transaction model | ||
TransactionStatus status = tm.getTransaction(null); | ||
|
||
// Create a single message with a timestamp | ||
String outMsg = "Hello from IBM MQ at " + new Date(); | ||
|
||
// The default SimpleMessageConverter class will be called and turn a String | ||
// into a JMS TextMessage which we send to qName1. This operation will be made | ||
// part of the transaction that we initiated. | ||
jmsTemplate.convertAndSend(qName1, outMsg); | ||
|
||
// Commit the transaction so the message is now visible | ||
tm.commit(status); | ||
|
||
// But now we're going to start a new transaction to hold multiple operations. | ||
status = tm.getTransaction(null); | ||
// Read it from the queue where we just put it, and then send it straight on to | ||
// a different queue | ||
Message inMsg = jmsTemplate.receive(qName1); | ||
jmsTemplate.convertAndSend(qName2, inMsg); | ||
// This time we decide to rollback the transaction so the receive() and send() are | ||
// reverted. We end up with the message still on qName1. | ||
tm.rollback(status); | ||
|
||
System.out.println("Done."); | ||
} | ||
|
||
static void printStarted() { | ||
System.out.println(); | ||
System.out.println("========================================"); | ||
System.out.println("MQ JMS Transaction Sample started."); | ||
System.out.println("========================================"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
ibm.mq.queueManager=QM1 | ||
ibm.mq.channel=SYSTEM.DEF.SVRCONN | ||
ibm.mq.connName=localhost(1414) | ||
|
||
# Change the following lines as necessary. Set the ibm.mq.user | ||
# property to an empty string to send no authentication request. | ||
#ibm.mq.user=mqguest | ||
#ibm.mq.user= | ||
#ibm.mq.password=passw0rd |