How to Store Message ActiveMQ into SQL Server - sql-server

I did the configuration for storing the message in SQL Server according to the examples that were in the internet.
Tables are created when ActiveMQ is executed, but when I create and send messages via localhost:8161/admin/queues.jsp a record is not inserted into the database table ACTIVEMQ_MSGS.
I tested the changes that were possible, and I saw some things on the internet. I applied them in the config file, but it didn't work.
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<value>file:${activemq.conf}/credentials.properties</value>
</property>
</bean>
<!-- Allows accessing the server log -->
<bean id="logQuery" class="io.fabric8.insight.log.log4j.Log4jLogQuery" lazy-init="false" scope="singleton" init-method="start" destroy-method="stop" />
<bean id="mssql-ds" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="jdbc:sqlserver://localhost:1433;DatabaseName=activedb" />
<property name="username" value="username" />
<property name="password" value="password" />
<property name="poolPreparedStatements" value="true" />
</bean>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost">
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry topic=">" producerFlowControl="true">
<pendingMessageLimitStrategy>
<constantPendingMessageLimitStrategy limit="1000" />
</pendingMessageLimitStrategy>
</policyEntry>
<policyEntry queue=">" producerFlowControl="true" memoryLimit="1mb" />
</policyEntries>
</policyMap>
</destinationPolicy>
<managementContext>
<managementContext createConnector="false" />
</managementContext>
<persistenceAdapter>
<jdbcPersistenceAdapter dataDirectory="${activemq.data}" dataSource="#mssql-ds" lockKeepAlivePeriod="0">
<adapter>
<transact-jdbc-adapter />
</adapter>
<locker>
<lease-database-locker lockAcquireSleepInterval="10000" dataSource="#mssql-ds">
<statements>
<statements lockTableName="activemq_lock" />
</statements>
</lease-database-locker>
</locker>
</jdbcPersistenceAdapter>
</persistenceAdapter>
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="64 mb" />
</memoryUsage>
<storeUsage>
<storeUsage limit="100 gb" />
</storeUsage>
<tempUsage>
<tempUsage limit="50 gb" />
</tempUsage>
</systemUsage>
</systemUsage>
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:0?maximumConnections=1000" />
</transportConnectors>
<shutdownHooks>
<bean xmlns="http://www.springframework.org/schema/beans" class="org.apache.activemq.hooks.SpringContextHook" />
</shutdownHooks>
</broker>
<import resource="jetty.xml" />
</beans>

Ensure you check the "Persistent Delivery" check-box when you send the message via the web console.

Related

Apache Camel is listening same message continuously from IBM MQ queue

I'm trying to pick up a message from IBM MQ queue and place it to my local ActiveMQ using XML DSL. The routing is working, but it picks up the same message continously and placing to ActiveMQ. It seems it falls into a never ending process. I have to shut down the process to stop it. Why is it so?
This is how the bean is defined in camel-conetxt.xml:
<route id="get">
<from uri="websphere:queue:CU_CUPO705_REP" />
<log message="GOT MESSAGE with Body ${in.body}" />
<inOnly uri="activemq:queue:MyOutputQueue" />
</route>
<bean id="websphereConnectionFactory"
class="com.ibm.mq.jms.MQConnectionFactory">
<property name="hostName" value="*****" />
<property name="port" value="****" />
<property name="queueManager" value="****" />
<property name="channel" value="****" />
<property name="transportType" value="1" />
<property name="shareConvAllowed" value="0" />
</bean>
<bean id="websphereConfig"
class="org.apache.camel.component.jms.JmsConfiguration">
<property name="connectionFactory"
ref="websphereConnectionFactory" />
<property name="concurrentConsumers" value="1" />
<property name="cacheLevelName" value="CACHE_CONSUMER" />
</bean>
<bean id="websphere"
class="org.apache.camel.component.jms.JmsComponent">
<property name="configuration" ref="websphereConfig" />
</bean>
Output -
2020-07-15 10:21:41.278 INFO 5212 --- [CU_CUPO705_REP]] get: GOT MESSAGE with Body <?xml version="1.0" encoding="ISO-8859-1" ?><API><Header><Function></Function><Author></Author><Version></Version><CreateTime></CreateTime><ClientStartTime></ClientStartTime><ClientEndTime></ClientEndTime><BrokerStartTime></BrokerStartTime><BrokerEndTime></BrokerEndTime><BackendStartTime>2020-07-15-10.21.41.238</BackendStartTime><BackendEndTime>2020-07-15-10.21.41.239</BackendEndTime><ReplyStatus></ReplyStatus></Header><GKSReply><ReplyBody><address><HouseKey>96325874</HouseKey><Municipality>100</Municipality><ZIP>8900</ZIP><Street>1234</Street><Street>test</Street><HouseNo>3</HouseNo><Letter></Letter><Locality></Locality></address></ReplyBody><ReplyStatus>OK</ReplyStatus></GKSReply></API>
2020-07-15 10:21:41.415 INFO 5212 --- [CU_CUPO705_REP]] get: GOT MESSAGE with Body <?xml version="1.0" encoding="ISO-8859-1" ?><API><Header><Function></Function><Author></Author><Version></Version><CreateTime></CreateTime><ClientStartTime></ClientStartTime><ClientEndTime></ClientEndTime><BrokerStartTime></BrokerStartTime><BrokerEndTime></BrokerEndTime><BackendStartTime>2020-07-15-10.21.41.238</BackendStartTime><BackendEndTime>2020-07-15-10.21.41.239</BackendEndTime><ReplyStatus></ReplyStatus></Header><GKSReply><ReplyBody><address><HouseKey>96325874</HouseKey><Municipality>100</Municipality><ZIP>8900</ZIP><Street>1234</Street><Street>test</Street><HouseNo>3</HouseNo><Letter></Letter><Locality></Locality></address></ReplyBody><ReplyStatus>OK</ReplyStatus></GKSReply></API>
2020-07-15 10:21:41.467 INFO 5212 --- [CU_CUPO705_REP]] get: GOT MESSAGE with Body <?xml version="1.0" encoding="ISO-8859-1" ?><API><Header><Function></Function><Author></Author><Version></Version><CreateTime></CreateTime><ClientStartTime></ClientStartTime><ClientEndTime></ClientEndTime><BrokerStartTime></BrokerStartTime><BrokerEndTime></BrokerEndTime><BackendStartTime>2020-07-15-10.21.41.238</BackendStartTime><BackendEndTime>2020-07-15-10.21.41.239</BackendEndTime><ReplyStatus></ReplyStatus></Header><GKSReply><ReplyBody><address><HouseKey>96325874</HouseKey><Municipality>100</Municipality><ZIP>8900</ZIP><Street>1234</Street><Street>test</Street><HouseNo>3</HouseNo><Letter></Letter><Locality></Locality></address></ReplyBody><ReplyStatus>OK</ReplyStatus></GKSReply></API>
The purpose is to print the output log only once.

Is there any Solution to download attachment from gmail in WSO2 ESB / WSO2 EI?

I am working on wso2 esb since last 6 months. I want to download attachment from gmail in wso2 esb/ei and save them into local folder.Google it and get solution only for sending attachment using gmail connector, not downloading attachment.
Note: Already seen,but can't able to get solution by referring the following link-
WSO2 esb get attach files from email
Code:
ProxyService
<proxy name="GmailConfigAttachment-TaskProxy" startOnLoad="true"
transports="http https" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<log level="custom">
<property name="Log Text"
value="Inside GmailConfigAttachment-TaskProxy Service"></property>
</log>
<property name="FORCE_SC_ACCEPTED" scope="axis2" type="STRING"
value="true" />
<property description="serviceName" name="serviceName"
scope="operation" type="STRING"
value="TaskScheduler_ASG_Read_Email_Body_Dummy_Service" />
<property description="messageId" expression="get-property('MessageID')"
name="messageId" scope="operation" type="STRING" />
<sequence key="Load_Gmail_Configuration" />
<gmail.init>
<userId>{$ctx:userId}</userId>
<accessToken>{$ctx:accessToken}</accessToken>
<apiUrl>{$ctx:apiUrl}</apiUrl>
<clientId>{$ctx:clientId}</clientId>
<clientSecret>{$ctx:clientSecret}</clientSecret>
<refreshToken>{$ctx:refreshToken}</refreshToken>
<accessTokenRegistryPath>{$ctx:registryPath}</accessTokenRegistryPath>
</gmail.init>
<gmail.listAllMails>
<labelIds>INBOX</labelIds>
<q>is:unread</q>
</gmail.listAllMails>
<log level="full" />
<iterate description="MailIterator" expression="//jsonObject/messages" sequential="true" id="listUnread">
<target>
<sequence>
<log description="Iterate Logger" level="custom" separator=",**, ">
<property expression="fn:concat('GmailConfigAttachment-TaskProxy_Service ESB-MessageId:',get-property('operation','messageId'))" name="LogText" />
<property expression="//id/text()" name="Gmail-MessageId" />
</log>
<property description="emailMsgId" expression="//id/text()" name="emailMsgId" scope="default" type="STRING" />
<property description="emailSubject" expression="//headers/name[text()='Subject']/../value/text()" name="emailSubject" scope="default" type="STRING"/>
<property description="emailDate" expression="//headers/name[text()='Date']/../value/text()" name="emailDate" scope="operation" type="STRING"/>
<property description="toAddress" expression="//headers/name[text()='To']/../value/text()" name="toAddress" scope="operation" type="STRING"/>
<header expression="fn:concat('Bearer ', $ctx:uri.var.gmail.accessToken)" name="Authorization" scope="transport" />
<gmail.readMail>
<id>{$ctx:emailMsgId}</id>
</gmail.readMail>
<payloadFactory media-type="xml">
<format>
<htmlProcessEmailBody xmlns="">
<emailMessageId>$1</emailMessageId>
<emailSubject>$2</emailSubject>
<emailBody>$3</emailBody>
</htmlProcessEmailBody>
</format>
<args>
<arg evaluator="xml" expression="get-property('emailMsgId')"/>
<arg evaluator="xml" expression="get-property('emailSubject')"/>
<arg evaluator="xml" expression="//payload"/>
</args>
</payloadFactory>
<log level="custom">
<property description="emailMsgId" expression="get-property('emailMsgId')" name="emailMsgId" scope="default" type="STRING" />
<property description="emailSubject" expression="//headers/name[text()='Subject']/../value/text()" name="emailSubject" scope="default" type="STRING"/>
<property description="emailDate" expression="//headers/name[text()='Date']/../value/text()" name="emailDate" scope="default" type="STRING"/>
<property description="toAddress" expression="//headers/name[text()='To']/../value/text()" name="toAddress" scope="default" type="STRING"/>
</log>
<!-- here i need further process to download attachment from gmail -->
</sequence>
</target>
</iterate>
</inSequence>
<outSequence />
<faultSequence />
</target>
Output of ESB
So Can anyone help me to provide solution?
Awaiting for your response.
Thank you.
Finally i found the solution for my question.
Idea :
Iterating each parts then getting email attachment id which will be passed to gmail api in order to get base64 encoded format.
Code snippet:
<iterate continueParent="true" description="MailIterator" expression="//parts" id="listUnread" sequential="true">
<target>
<sequence>
<property expression="//filename[text()!=' ']" name="AttachedFileName" scope="default" type="STRING"/>
<property expression="substring-after(get-property('AttachedFileName'),'.')" name="Attachmentextension" scope="default" type="STRING"/>
<filter description="check emailSubject" regex="jpg|jpeg|png|gif|webp|tiff|tif|psd|raw|bmp|dib|heif|heic|indd|ind|jp2" source="lower-case(get-property('Attachmentextension'))">
<then>
<property description="emailAttachmentId" expression="//attachmentId/text()" name="uri.var.attachmentId" scope="default" type="STRING"/>
<log level="custom">
<property expression="get-property('AttachedFileName')" name="=====ValidAttachmentFileName===="/>
<property expression="get-property('uri.var.attachmentId')" name="====emailAttachmentId====="/>
</log>
<header expression="fn:concat('Bearer ', $ctx:uri.var.gmail.accessToken)" name="Authorization" scope="transport"/>
<call>
<endpoint>
<http method="get" uri-template="{+uri.var.gmail.apiUrl}/{+uri.var.gmail.apiVersion}/users/{+uri.var.gmail.userId}/messages/{+uri.var.id}/attachments/{+uri.var.attachmentId}"/>
</endpoint>
</call>
<property description="emailAttachment" expression="//data/text()" name="emailAttachment" scope="default" type="STRING"/>
<!-- ==========Script for Base64 url to Base64 Encoding Format ========== -->
<script language="js"><![CDATA[var log=mc.getServiceLog();
var emailAttachment = mc.getProperty('emailAttachment');
emailAttachment=emailAttachment.replaceAll("_","/").replaceAll("-","+");
mc.setProperty("modifiedemailAttachment",emailAttachment)]]></script>
<log level="custom">
<property expression="get-property('modifiedemailAttachment')" name="========modifiedemailAttachment========"/>
</log>

how to implement Detached XML Signatures with XML Security component in apache camel?

H I have doubts with the implementation of Detached XML Signatures, I have mostly followed the example that appears here. My doubt is related to the validation that is done with the schema "test.xsd", I have not managed to generate it according to my needs.
I have to sign the body, Timestamp and BinarySecurityToken of the request, which is encrypted (for the encryption I am using the implementation that appears in http://camel.apache.org/xmlsecurity-dataformat.html)
My route camel is:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
xmlns:camel="http://camel.apache.org/schema/blueprint"
xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
xmlns:cxf="http://camel.apache.org/schema/blueprint/cxf"
xmlns:http="http://cxf.apache.org/transports/http/configuration"
xmlns:sec="http://cxf.apache.org/configuration/security"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<camel:keyStoreParameters id="injks" password="desarrollo" resource="C:/Users/Usuario/Desktop/nuevo/test.jks"/>
<bean class="org.apache.camel.util.jsse.KeyStoreParameters" id="keyStore2">
<property name="resource" value="C:/Users/Usuario/Desktop/nuevo/test.jks"/>
<property name="password" value="development"/>
</bean>
<bean
class="org.apache.camel.component.xmlsecurity.api.DefaultKeyAccessor" id="keyAccessorOne">
<property name="alias" value="test"/>
<property name="password" value="development"/>
<property name="keyStoreParameters" ref="keyStore2"/>
</bean>
<!-- Parts -->
<bean class="java.util.ArrayList" id="xpathParts">
<argument>
<list>
<bean
class="org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper" factory-method="getXpathFilter">
<argument type="java.lang.String" value="//*:Body"/>
</bean>
<bean
class="org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper" factory-method="getXpathFilter">
<argument type="java.lang.String" value="//*:Timestamp"/>
</bean>
<bean
class="org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper" factory-method="getXpathFilter">
<argument type="java.lang.String" value="//*:BinarySecurityToken"/>
</bean>
</list>
</argument>
</bean>
<camelContext id="context-redbanc" xmlns="http://camel.apache.org/schema/blueprint">
<route id="_route1">
<from id="_from1" uri="timer:foo?period=20000"/>
<setBody id="_setBody1">
<simple>resource:classpath:etc/wsdl/schema.xml</simple>
</setBody>
<marshal id="_marshal2">
<jaxb contextPath="cl.coopeuch.integracion.wsredbanc.wsdl.test"/>
</marshal>
<marshal id="_marshal1">
<secureXML id="inEncryption"
keyCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5"
keyOrTrustStoreParametersId="injks"
recipientKeyAlias="des-wls02.rbc.cl"
secureTag="//*:Body" secureTagContents="true" xmlCipherAlgorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc"/>
</marshal>
<setHeader headerName="CamelXmlSignatureContentReferenceUri" id="_setHeader1">
<constant>#Body</constant>
</setHeader>
<to id="_to2" uri="xmlsecurity:sign://oneSign?keyAccessor=#keyAccessorOne&digestAlgorithm=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23sha1&xpathsToIdAttributes=#xpathParts&schemaResourceUri=etc/wsdl/schema.xsd"/>
<to id="_to3" uri="file://C:/Users/Usuario/Desktop/salida?fileName=outbound_body.xml"/>
<to id="_to4" uri="mock:result"/>
</route>
</camelContext>
The elements to sign are:
<bean class="java.util.ArrayList" id="xpathParts">
<argument>
<list>
<bean
class="org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper" factory-method="getXpathFilter">
<argument type="java.lang.String" value="//*:Body"/>
</bean>
<bean
class="org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper" factory-method="getXpathFilter">
<argument type="java.lang.String" value="//*:Timestamp"/>
</bean>
<bean
class="org.apache.camel.component.xmlsecurity.api.XmlSignatureHelper" factory-method="getXpathFilter">
<argument type="java.lang.String" value="//*:BinarySecurityToken"/>
</bean>
</list>
</argument>
</bean>
and the uri used to sign is:
<to id="_to2" uri="xmlsecurity:sign://oneSign?keyAccessor=#keyAccessorOne&digestAlgorithm=http%3A%2F%2Fwww.w3.org%2F2000%2F09%2Fxmldsig%23sha1&xpathsToIdAttributes=#xpathParts&schemaResourceUri=etc/wsdl/schema.xsd"/>
The test.xsd in my implementation is schema.xsd, which is: (I have not known how to indicate the other two parties to sign)
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:tns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<import namespace="http://www.w3.org/2000/09/xmldsig#"
schemaLocation="xmldsig-core-schema.xsd" />
<element name="Envelope">
<complexType>
<sequence>
<element name="Header"/>
<element name="Body">
<complexType>
<sequence>
<element ref="ds:Signature" minOccurs="0" />
</sequence>
<attribute name="Body" type="ID" use="required" />
<attribute name="stringBody" type="string" />
</complexType>
</element>
</sequence>
</complexType>
</element>
Any ideas or other examples that I can follow?
..Is solved! The ws-policy framework was used with the following policies:
<?xml version="1.0" encoding="UTF-8"?>
<wsp:Policy
wsu:Id="SecureConversation_MutualCertificate10SignEncrypt_IPingService_policy"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsp:ExactlyOne xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp1_2:All xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy">
<sp:AsymmetricBinding xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wsaws="http://www.w3.org/2005/08/addressing" xmlns:wspp="http://java.sun.com/xml/ns/wsit/policy"
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata">
<wsp1_2:Policy>
<sp:InitiatorToken>
<wsp:Policy>
<sp:X509Token
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<wsp:Policy>
<sp:WssX509V3Token10 />
</wsp:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:InitiatorToken>
<sp:RecipientToken>
<wsp:Policy>
<sp:X509Token
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
<wsp1_2:Policy>
<sp:WssX509V3Token10 />
<sp:RequireIssuerSerialReference />
</wsp1_2:Policy>
</sp:X509Token>
</wsp:Policy>
</sp:RecipientToken>
<sp:AlgorithmSuite>
<wsp:Policy>
<sp:TripleDesRsa15 />
</wsp:Policy>
</sp:AlgorithmSuite>
<sp:IncludeTimestamp />
<sp:ProtectTokens />
</wsp1_2:Policy>
</sp:AsymmetricBinding>
<sp:SignedParts
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702"
xmlns:wss="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<sp:Body />
</sp:SignedParts>
<sp:EncryptedParts
xmlns:sp="http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702">
<sp:Body />
</sp:EncryptedParts>
</wsp1_2:All>
</wsp:ExactlyOne>
</wsp:Policy>

why CAMEL_MESSAGEPROCESSED created in SQL server db

I want to run Camel built application as stanalone. I am using maven to create standalone jar and execute route.When I run MainApp.java main method from eclipse or run using camel run then code runs as expected. But when I run using java -jar then 3 tables CAMEL_MESSAGEPROCESSED, CAMEL_MESSAGETRACED,hibernate_sequence are created into db. I do not want these tables created. Please help me find what I am doing wrong.
Camel, camel-jpa version 2.19.1
hibernate-entitymanager version 5.2.7.Final
Camel-context.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:prop="http://camel.apache.org/schema/placeholder"
xmlns:camel="http://camel.apache.org/schema/spring"
xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-4.3.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<bean id="properties"
class="org.apache.camel.component.properti
es.PropertiesComponent">
<property name="location" value="classpath:db.properties" />
</bean>
<bean id="bridgePropertyPlaceholder"
class="org.apache.camel.spring.spi.BridgePropertyPlaceholderConfigurer">
<property name="location" value="classpath:db.properties" />
</bean>
<camelContext id="camel5" xmlns="http://camel.apache.org/schema/spring">
<routeBuilder ref="myBuilder" />
</camelContext>
<bean id="myBuilder"
class="com.aexp.gsnt.insight.updateCentralData.InsightRouterBuilder" />
<bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
<property name="entityManagerFactory" ref="entityManagerFactory" />
<property name="transactionManager" ref="jpaTxManager" />
</bean>
<bean id="jpaTxManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="persistenceUnitName" value="persistenceUnit" />
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform" value="org.hibernate.dialect.SQLServerDialect" />
<property name="showSql" value="${showSQL}" />
<property name="generateDdl" value="${generateDdl}" />
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.format_sql">${formatSQL}</prop>
</props>
</property>
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.microsoft.sqlserver.jdbc.SQLServerDriver" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</bean>
</beans>
Persistence.xml
<?xml version="1.0" encoding="UTF-8" ?>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0" xmlns="http://java.sun.com/xml/ns/persistence">
<persistence-unit name="persistenceUnit"
transaction-type="RESOURCE_LOCAL">
</persistence-unit>
</persistence>
MainApp.java
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class MainApp {
private static ClassPathXmlApplicationContext classPathXmlApplicationContext;
/* Invoked from Jar */
public static void main(String args[]) throws Exception {
System.out.println("Started Central Data Extractor");
System.setProperty("jsse.enableSNIExtension", "false");
classPathXmlApplicationContext = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/camel-context.xml");
classPathXmlApplicationContext.start();
}
}

How to use Camel to get message from remote WMQ and place message in ActiveMQ?

I have been looking at these for days and still haven't have mush success.
I have install and run activeMQ on a server. Created a queue called "testUpdate". I also have another queue on another server, let call this "forward" and this is on the IBM MQ (WMQ).
So we have testUpdate on ActiveMQ and forward on WMQ. I want the message on forward queue to be placed into testUpdate queue. Trying to use Camel for this process.
So the setup in ActiveMQ has an XML(activemq.xml) that I can place spring beans and configure to do the routing. In this xml, I added http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd to the xmlns and then added
import resource="camel.xml"
In this new xml, I have the following:
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
<route>
<description>Example Camel Route</description>
<from uri="mqseries:forward"/>
<to uri="activemq:testUpdate"/>
</route>
</camelContext>
<bean id="mqseries" class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1"/>
<property name="hostName" value="172.00.12.21/>
<property name="port" value="xyza"/>
<property name="queueManager" value="manager"/>
<property name="channel" value="srvcChannel"/>
</bean>
<!--
Lets configure some Camel endpoints
http://camel.apache.org/components.html
-->
<!-- configure the camel activemq component to use the current broker -->
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" >
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="vm://amq-broker?create=false"/>
<property name="userName" value="${activemq.username}"/>
<property name="password" value="${activemq.password}"/>
</bean>
</property>
</bean>
</beans>
I added the jar file com.ibm.mq.allclient.jar into the lib folder of ActiveMQ. When running the program, I am getting this exception:
java.lang.ClassNotFoundException: javax.jms.JMSRuntimeException
It sounds like I am missing the websphere jar file? Is this correct?
I use both IBM MQ and ActiveMQ on a regular basis. This example below will show you some sample configuration options. Please make sure you configure these to your own use cases.
//ActiveMQ connection factory
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent" destroy-method="doStop">
<property name="configuration">
<bean class="org.apache.camel.component.jms.JmsConfiguration">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="acceptMessagesWhileStopping" value="true" />
<property name="acknowledgementModeName" value="CLIENT_ACKNOWLEDGE" />
<property name="cacheLevelName" value="CACHE_CONSUMER" />
<property name="connectionFactory">
<bean class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="1" />
<property name="MaximumActiveSessionPerConnection" value="500" />
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq1.brokerUrl}" />
<property name="userName" value="${activemq1.username}" />
<property name="password" value="${activemq1.password}" />
<property name="redeliveryPolicy">
<bean class="org.apache.activemq.RedeliveryPolicy">
<property name="maximumRedeliveries" value="-1" />
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
</property>
</bean>
//IBM MQ connection factory
<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent" destroy-method="doStop">
<property name="concurrentConsumers" value="1" />
<property name="maxConcurrentConsumers" value="1" />
<property name="connectionFactory">
<bean class="org.springframework.jms.connection.SingleConnectionFactory" destroy-method="destroy">
<constructor-arg>
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType" value="1" />
<property name="channel" value="${channel}" />
<property name="hostName" value="${hostname}" />
<property name="port" value="${port}" />
<property name="queueManager" value="${queueManager}" />
</bean>
</constructor-arg>
</bean>
</property>
</bean>
You can use jms component to consume the message from IBM MQ and use activemq component to post it to ActiveMQ
have a look at the following links
http://camel.apache.org/jms.html
http://camel.apache.org/activemq.html
Thanks,
Gibu
You can use users camel extra component https://github.com/camel-extra/camel-extra/blob/master/components/camel-wmq/README.md to get messages from wmq without using the JMS wrapping and then send messages to ActiveMQ with custom camel component https://camel.apache.org/components/latest/activemq-component.html. See also a similar topic Apache Camel with IBM MQ.

Resources