Active MQ to WebLogic JMS Bridge with Apache Camel
Note the highlighted sections .
1.
Required Libraries
·
WebLogic Thin Client library jar
·
Camel libraries
·
Active mq libraries
·
Spring libraries
Gradle config file example
/*
* This build file was auto generated by running the Gradle 'init' task * by 'CTank' at '6/30/15 8:45 AM' with Gradle 2.4 * * This generated file contains a sample Java project to get you started. * For more details take a look at the Java Quickstart chapter in the Gradle * user guide available at http://gradle.org/docs/2.4/userguide/tutorial_java_projects.html */ // Apply the java plugin to add support for Java apply plugin: 'java' apply plugin: 'idea' // In this section you declare where to find the dependencies of your project repositories { // Use 'jcenter' for resolving your dependencies. // You can declare any Maven/Ivy/file repository here. jcenter() } // In this section you declare the dependencies for your production and test code dependencies { // The production code uses the SLF4J logging API at compile time compile 'org.slf4j:slf4j-api:1.7.12' //Spring compile 'org.springframework:spring-webmvc:4.1.0.RELEASE' compile 'org.springframework:spring-jdbc:4.1.0.RELEASE' compile 'org.springframework:spring-jms:4.1.0.RELEASE' compile 'org.hibernate:hibernate-core:4.3.9.Final' compile 'org.springframework:spring-tx:4.1.0.RELEASE' compile 'org.springframework:spring-orm:4.1.0.RELEASE' compile 'org.springframework:spring-beans:4.1.0.RELEASE' //logging compile 'ch.qos.logback:logback-classic:1.1.2' compile 'org.slf4j:slf4j-api:1.7.2' compile 'log4j:log4j:1.2.17' compile 'org.apache.commons:commons-io:1.3.2' //groovy compile group: 'org.codehaus.groovy', name: 'groovy-all', version:'2.3.10' //ActiveMQ compile 'org.apache.activemq:activemq-broker:5.10.0' compile 'org.apache.activemq:activemq-client:5.10.0' compile 'org.apache.activemq:activemq-console:5.10.0' compile 'org.apache.activemq:activemq-jaas:5.10.0' compile 'org.apache.activemq:activemq-kahadb-store:5.10.0' compile 'org.apache.activemq:activemq-openwire-legacy:5.10.0' compile 'org.apache.activemq:activemq-ra:5.1.0' compile 'org.apache.activemq:activemq-spring:5.10.0' compile 'org.apache.activemq:activemq-pool:5.10.0' // Camel compile 'org.apache.camel:camel-core:2.15.2' compile 'org.apache.camel:camel-spring:2.15.2' compile 'org.apache.camel:camel-jms:2.15.2' // compile 'org.apache.camel:camel-spring:2.15.0' // compile 'org.apache.camel:camel-jms:2.15.0' // compile 'org.apache.camel:camel-bundle:2.0-M3' runtime files("${project.projectDir}/src/main/resources") compile fileTree(dir: 'lib', include: [' wlthint3client.jar']) // Declare the dependency for your favourite test framework you want to use in your tests. // TestNG is also supported by the Gradle Test task. Just change the // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add // 'test.useTestNG()' to your build script. testCompile 'junit:junit:4.12' } task execute(type:JavaExec) { main = mainClass classpath = sourceSets.main.runtimeClasspath systemProperty 'java.security.policy', "${project.projectDir}/project-java-security.policy" } |
2.
Sample WebLogic Configuraiton
WebLogic Managed Server Name : MS1
JMS Server : JMSServer-01
SubDeployment :
SystemModule-0
Connection Factory : sample.ccs.cf
JMS Queue : sample.ccs.inbox
Login name : weblogic
Password : weblogic1 [ You don’t need login password for
non-secure configuration]
|
3.
Camel Spring Configuration
For sending a ping message to JMS Queue once every 6 seconds
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:camel="http://camel.apache.org/schema/spring" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <camelContext xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="timer:foo?period=6s"/> <transform> <simple>Message at ${date:now:yyyy-MM-dd HH:mm:ss}</simple> </transform> <to uri="weblogic:queue:JMSServer-0/SystemModule-0!sample_contracts"/> </route> </camelContext> <bean id="wljndiTemplate" class="org.springframework.jndi.JndiTemplate"> <property name="environment"> <props> <prop key="java.naming.factory.initial">weblogic.jndi.WLInitialContextFactory</prop> <prop key="java.naming.provider.url">t3://localhost:7001</prop> <prop key="java.naming.security.authentication">simple</prop> <prop key="java.naming.security.principal">weblogic</prop> <prop key="java.naming.security.credentials">weblogic1</prop> </props> </property> </bean> <bean id="wlqueueConnectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate"> <ref bean="wljndiTemplate" /> </property> <property name="jndiName"> <value>sample.ccs.cf</value> </property> </bean> <bean id="wlsample_out_queue" class="org.springframework.jndi.JndiObjectFactoryBean"> <property name="jndiTemplate"> <ref bean="wljndiTemplate" /> </property> <property name="jndiName"> <value>sample.ccs.inbox</value> </property> </bean> <bean id="wlsample_out_queueTemplate" class="org.springframework.jms.core.JmsTemplate"> <property name="connectionFactory"> <ref bean="wlqueueConnectionFactory" /> </property> <property name="defaultDestination" ref="wlsample_out_queue" /> <property name="destinationResolver"> <bean class="org.springframework.jms.support.destination.JndiDestinationResolver"> <property name="jndiTemplate"> <ref bean="wljndiTemplate" /> </property> <property name="cache"> <value>true</value> </property> </bean> </property> <property name="sessionTransacted" value="false" /> </bean> <bean id="weblogicConfig" class="org.apache.camel.component.jms.JmsConfiguration"> <property name="connectionFactory" ref="wlqueueConnectionFactory"/> <property name="concurrentConsumers" value="10"/> </bean> <bean id="weblogic" class="org.apache.camel.component.jms.JmsComponent"> <property name="configuration" ref="weblogicConfig"/> </bean> </beans> |
No comments:
Post a Comment