Skip to content

Commit 947fce8

Browse files
committed
JMS with Camel
JMS with Camel project is added
1 parent 9ca41ea commit 947fce8

5 files changed

Lines changed: 144 additions & 0 deletions

File tree

jms/pom.xml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>com.fd</groupId>
8+
<artifactId>tryout.jms</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
11+
<parent>
12+
<groupId>org.springframework.boot</groupId>
13+
<artifactId>spring-boot-starter-parent</artifactId>
14+
<version>2.0.3.RELEASE</version>
15+
</parent>
16+
17+
<properties>
18+
<java.version>1.8</java.version>
19+
</properties>
20+
21+
<dependencies>
22+
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-activemq</artifactId>
26+
</dependency>
27+
28+
<dependency>
29+
<groupId>org.apache.activemq</groupId>
30+
<artifactId>activemq-pool</artifactId>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.apache.camel</groupId>
35+
<artifactId>camel-spring-boot-starter</artifactId>
36+
<version>2.22.0</version>
37+
</dependency>
38+
39+
<dependency>
40+
<groupId>org.apache.camel</groupId>
41+
<artifactId>camel-jms</artifactId>
42+
<version>2.22.0</version>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.springframework.boot</groupId>
47+
<artifactId>spring-boot-starter-web</artifactId>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>org.springframework.boot</groupId>
52+
<artifactId>spring-boot-starter-test</artifactId>
53+
<scope>test</scope>
54+
</dependency>
55+
56+
</dependencies>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.springframework.boot</groupId>
62+
<artifactId>spring-boot-maven-plugin</artifactId>
63+
</plugin>
64+
</plugins>
65+
</build>
66+
67+
</project>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.fd.tryout.jms;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
@SpringBootApplication
7+
public class App {
8+
9+
public static void main(String[] args) {
10+
SpringApplication.run(App.class, args);
11+
}
12+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.fd.tryout.jms.config;
2+
3+
import org.apache.camel.component.jms.JmsComponent;
4+
import org.springframework.context.annotation.Bean;
5+
import org.springframework.context.annotation.Configuration;
6+
import org.springframework.jms.connection.JmsTransactionManager;
7+
8+
import javax.jms.ConnectionFactory;
9+
10+
@Configuration
11+
public class JmsConfig {
12+
13+
@Bean
14+
public JmsTransactionManager jmsTransactionManager(final ConnectionFactory connectionFactory) {
15+
JmsTransactionManager jmsTransactionManager = new JmsTransactionManager();
16+
jmsTransactionManager.setConnectionFactory(connectionFactory);
17+
return jmsTransactionManager;
18+
}
19+
20+
@Bean
21+
public JmsComponent jmsComponent(final ConnectionFactory connectionFactory,
22+
final JmsTransactionManager jmsTransactionManager) {
23+
JmsComponent jmsComponent = JmsComponent.jmsComponentTransacted(connectionFactory, jmsTransactionManager);
24+
return jmsComponent;
25+
}
26+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.fd.tryout.jms.routes;
2+
3+
import org.apache.camel.LoggingLevel;
4+
import org.apache.camel.builder.RouteBuilder;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
import org.springframework.stereotype.Component;
8+
9+
@Component
10+
public class JmsTestRouter extends RouteBuilder {
11+
12+
static final Logger log = LoggerFactory.getLogger(JmsTestRouter.class);
13+
14+
@Override
15+
public void configure() throws Exception {
16+
System.out.println("Configuring route");
17+
18+
from("{{input.queue}}")
19+
.log(LoggingLevel.DEBUG, log, "New message received")
20+
.process(exchange -> {
21+
String convertedMessage = exchange.getMessage().getBody() + " is converted";
22+
exchange.getMessage().setBody(convertedMessage);
23+
})
24+
.to("{{output.queue}}")
25+
.log(LoggingLevel.DEBUG, log, "Message sent to the other queue")
26+
.end();
27+
28+
}
29+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spring.activemq.broker-url=tcp://localhost:61616
2+
spring.activemq.user=admin
3+
spring.activemq.password=admin
4+
spring.activemq.pool.enabled=true
5+
spring.activemq.pool.max-connections=10
6+
7+
max.concurrent.consumers=2
8+
9+
input.queue=jms:INBOUND.D
10+
output.queue=jms:OUTBOUND.D

0 commit comments

Comments
 (0)