Я пытаюсь понять, как использовать Spring Boot Streams с MQueue, используя spring-cloud-stream-binder-ibm-mq. Я могу подключиться к MQueue, но получаю Could not provision topic 'queue///EMB_DEV_QUEUE'
и MQJE001: Completion Code '2', Reason '2035'
. Я подтвердил у администратора, что это очередь, а не тема.
Я могу подключиться, используя пример кода, используя MQQueueConnectionFactory
на основе самые простые примеры приложений с использованием websphere-mq-jms, поэтому я знаю, что MQueue работает.
Вот моя программа. Я успешно использовал тот же шаблон для Кафки.
@EnableBinding({Sink.class, Source.class})
@SpringBootApplication
public class MQueueStreamApplication {
private final static AtomicInteger counter = new AtomicInteger();
private final Logger logger = LoggerFactory.getLogger(getClass());
public static void main(String[] args) {
SpringApplication.run(MQueueStreamApplication.class, args);
}
@Bean
@InboundChannelAdapter(value = Source.OUTPUT, poller = @Poller(fixedRate = "2000"))
public MessageSource<String> timeSource() {
return () -> {
String message = String.format("Timed Message %d", counter.incrementAndGet());
logger.info("Producing Message: {}", message);
return MessageBuilder.withPayload(message).setHeader("Message-Type", "mqueue-stream").build();
};
}
@ServiceActivator(inputChannel = Sink.INPUT)
public void serviceSink(Message<String> message) {
String payload = String.valueOf(message.getPayload());
logger.info("Received Message: {} [{}]", payload, message.getHeaders());
}
}
Вот мой application.yml
. Я пробовал с префиксом queue:///
и без него. Пример программы работает с префиксом.
spring:
cloud:
stream:
bindings:
input:
destination: queue:///EMB_DEV_QUEUE
group: mqueue-stream
# binder: ibmmq
output:
destination: queue:///EMB_DEV_QUEUE
ibmmq:
host: vm-dev-q01.corp.int
port: 1414
channel: EMB_DEV_CHANNEL
queueManager: EMB_DEV_QMGR
Вот моя сборка Gradle.
buildscript {
ext {
springBootVersion = '1.5.3.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.cloud:spring-cloud-stream')
compile('org.springframework.cloud:spring-cloud-stream-binder-jms-ibm-mq:1.0.0.BUILD-SNAPSHOT')
testCompile('org.springframework.boot:spring-boot-starter-test')
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:Dalston.RELEASE"
}
}
Я построил spring-cloud-stream-binder-ibm-mq
, следуя инструкциям. Я получил две необходимые банки из установки MQueue. В манифесте указана версия 9.0.0.0
, поэтому я использовал 9
в pom.xml
.
Я новичок в MQueue и имею ограниченный опыт работы с потоками. Я смог успешно подключиться к Kafka. Буду признателен за любую помощь.
Уэс.
Caused by: java.lang.ClassNotFoundException: javax.jms.ConnectionFactory
. Любая идея, что вызывает это и как это исправить - person Muhammad Arslan Akhtar   schedule 27.07.2019