How to use WSO2 ESB to set message format to MQSTR - jms

I am using WSO2 ESB 4.9 to connect to a WebSphere MQ queue via a .bindings file. By default, WSO2 ESB sends the MQ messages via JMS with the format MQHRF2. How can I configure WSO2 ESB so that it would send the MQ messages in the MQSTR format instead, similar to the following Java coding:
Queue myQueue = session.createQueue("queue:///myQueue?targetClient=1");
or
((MQQueue) queue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ);
Many thanks in advance!
Here is part of my proxy as configured on WSO2 ESB per suggestion as below:
<outSequence>
<property name="TRANSPORT_HEADERS" scope="axis2" action="remove"/>
<property name="messageType" value="text/plain" scope="axis2"/>
<property name="JMS_IBM_Format"
value="MQSTR"
scope="transport"
type="STRING"/>
<send/>
</outSequence>
<endpoint>
<address uri="jms:/xxxx?transport.jms.ConnectionFactoryJNDIName=..."
format="soap11"/>
</endpoint>
The following property setting is used to remove the unwanted HTTP header info from the upstream (JSON/HTTP) by not sending it to the downstream (XML/JMS):
<property name="TRANSPORT_HEADERS" scope="axis2" action="remove"/>

You can try adding the following property before sending it to the MQ.
<property name="JMS_IBM_Format"
value="MQSTR"
scope="transport"
type="STRING"/>
<send>
<!-- your MQ endpoint here -->
</send>

Related

WSO2 Message Broker not receiving message

i followed the official documentation dealing with the integration between WSO2 ESB and WSO2 MB.
https://docs.wso2.com/display/MB210/Integrating+WSO2+ESB
On my WSO2 ESB 8.1.0 i wrote a simple proxy like this:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="jobReplicaFeed"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<send>
<endpoint key="ReplicaFeedEndpoint"/>
</send>
</inSequence>
<outSequence>
<log level="full"/>
</outSequence>
</target>
<description/>
</proxy>
where ReplicaFeedEndpoint is like the following linsting:
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="ReplicaFeedEndpoint">
<address uri="jms:/REPLICA_FEED?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=repository/conf/jndi.properties&transport.jms.DestinationType=topic">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
</address>
</endpoint>
and this is my jndi.properties:
connectionfactory.QueueConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://myHost:5672'
connectionfactory.TopicConnectionFactory = amqp://admin:admin#clientID/carbon?brokerlist='tcp://myHost:5672'
topic.MioEvento = REPLICA_FEED
using a simple REST client i'm trying to send a message to the proxy, expecting the same to be intercepted by the message broker.
Nothing happens. Furthermore, trying different times i get randomly this exception:
TID: [0] [ESB] [2015-05-06 19:55:16,503] ERROR {org.apache.axis2.transport.jms.JMSOutTransportInfo} - Couldn't locate the JMS destination REPLICA_FEED of type topic/ extracted from the URL jms:/REPLICA_FEED?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=repository/conf/jndi.properties&transport.jms.DestinationType=topic/ {org.apache.axis2.transport.jms.JMSOutTransportInfo}
javax.naming.NameNotFoundException: dynamicQueues/REPLICA_FEED
at org.wso2.andes.jndi.ReadOnlyContext.lookup(ReadOnlyContext.java:271)
at javax.naming.InitialContext.lookup(InitialContext.java:411)
at org.apache.axis2.transport.jms.JMSUtils.lookup(JMSUtils.java:583)
at org.apache.axis2.transport.jms.JMSUtils.lookupDestination(JMSUtils.java:814)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.getDestination(JMSOutTransportInfo.java:184)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.loadConnectionFactoryFromProperties(JMSOutTransportInfo.java:132)
at org.apache.axis2.transport.jms.JMSOutTransportInfo.createJMSSender(JMSOutTransportInfo.java:330)
at org.apache.axis2.transport.jms.JMSSender.sendMessage(JMSSender.java:127)
at org.apache.axis2.transport.base.AbstractTransportSender.invoke(AbstractTransportSender.java:112)
at org.apache.axis2.engine.AxisEngine.send(AxisEngine.java:442)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.send(DynamicAxisOperation.java:185)
at org.apache.synapse.core.axis2.DynamicAxisOperation$DynamicOperationClient.executeImpl(DynamicAxisOperation.java:167)
at org.apache.axis2.client.OperationClient.execute(OperationClient.java:149)
at org.apache.synapse.core.axis2.Axis2FlexibleMEPClient.send(Axis2FlexibleMEPClient.java:482)
at org.apache.synapse.core.axis2.Axis2Sender.sendOn(Axis2Sender.java:59)
at org.apache.synapse.core.axis2.Axis2SynapseEnvironment.send(Axis2SynapseEnvironment.java:338)
at org.apache.synapse.endpoints.AbstractEndpoint.send(AbstractEndpoint.java:333)
at org.apache.synapse.endpoints.AddressEndpoint.send(AddressEndpoint.java:59)
at org.apache.synapse.endpoints.IndirectEndpoint.send(IndirectEndpoint.java:54)
at org.apache.synapse.mediators.builtin.SendMediator.mediate(SendMediator.java:97)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:77)
at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:47)
at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:131)
at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:166)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)
at org.apache.synapse.transport.passthru.ServerWorker.processNonEntityEnclosingRESTHandler(ServerWorker.java:344)
at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:385)
at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:183)
at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Threa
What could be the problem?
thanks
In the endpoint definition, the uri contains the JNDI entry to the queue, where as the transport is defined as a topic.
transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory
Should be
transport.jms.ConnectionFactoryJNDIName=TopicConnectionFactory
You can find further information in the following article on WSO2 ESB and MB Integration.
http://wso2.com/library/articles/2013/03/configuring-wso2-esb-wso2-message-broker/

Proxy Service: AdminProxy Admin Exception in wso2 esb 4.8.1

I have defined a simple proxy service in WSO2 ESB(4.8.1) which is listening over a QUEUE via JMS. This service after reading the message send it to another queue.
Problem:
When i define inline endpoint then it works fine, but if i refer to a registry endpoint then WSO2 ESB gives me error and does not allow me to modify the service.
Proxy Service:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FailOverTest"
transports="jms"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="OUT_ONLY" value="true" scope="default" type="STRING"/>
<log level="full"/>
<property name="ClientApiNonBlocking" action="remove" scope="axis2"/>
<send>
<endpoint key="gov:/repository/Endpoints/EndpointFailover.xml"/>
</send>
<log level="full"/>
</inSequence>
<faultSequence>
<property name="SET_ROLLBACK_ONLY"
value="true"
scope="axis2"
type="STRING"/>
<log level="custom">
<property name="ERROR_CODE" expression="get-property('ERROR_CODE')"/>
<property name="ERROR_MESSAGE" expression="get-property('ERROR_MESSAGE')"/>
<property name="ERROR_DETAIL" expression="get-property('ERROR_DETAIL')"/>
<property name="ERROR_EXCEPTION" expression="get-property('ERROR_EXCEPTION')"/>
<property name="Transaction Action" value="Rollbacked"/>
</log>
</faultSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">FailOverRequest</parameter>
<parameter name="originator">ServiceAdmin</parameter>
<description/>
</proxy>
Registry Endpoint XML:
<?xml version="1.0" encoding="UTF-8"?>
<endpoint>
<address uri="jms:/FailOverResponse?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://localhost:61616&transport.jms.DestinationType=queue" format="pox">
</address>
</endpoint>
Error WSO2 ESB Displaying:
This error may occur if you are attempting to modify the endpoint through Source View. The Design-View endpoint modification has a nice feature that allows browsing of the registry, and it will format the link to registry endpoints successfully every time. Please try that Design-view to modify your endpoint.

JMS listener in Spring initiates two Consumer

I am new Spring(3.1.2) and JMS. I am trying to consume a JMS message (QUEUE) which is being sent by an ActiveMQ server. I have done the below configuration in Spring xml file.
<bean id="connectionFactory" class="org.apache.activemq.spring.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://xx.xx.xxx.144:61616" />
</bean>
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="connectionFactory" />
<property name="defaultDestinationName" value="videovantage-nslij" /> <!-- testQ -->
</bean>
<jms:listener-container connection-factory="connectionFactory" concurrency="1" >
<jms:listener destination="videovantage-nslij" ref="messageReceiver"
method="processMessage" />
</jms:listener-container>
Now I am able to receive JMS messages. But the problem is When i start the JBOSS server(7.1.1) I see two consumers from the same machine. When i do netstat i get the below, notice that activemq port 61616 is listening twice.
TCP xx.xxx.xxx.150:51234 xx.xxx.xxx.144:61616 ESTABLISHED 1044
TCP xx.xxx.xxx.150:51235 xx.xxx.xxx.190:27017 ESTABLISHED 1044
TCP xx.xxx.xxx.150:51236 xx.xxx.xxx.144:61616 ESTABLISHED 1044
Not sure why two consumers are getting created. Any suggestion or guidance will be very helpful. Please let me know if any additional details are required.
Thanks in advance,
Gopi

How Wso2CEP pick the messages in JMS

I am using wso2cep 3.0.0 and activemq5.8.0 As per CEP documents i wish to Publish events using CEP. For that i started activemq with 2 define QUEUES with the name jmsProxy for incoming message and JmsProxy for out message.I added required jars in CEP lib activemq-broker-5.8.0.jar,activemq-client-5.8.0.jar,axiom.jar,geronimo-j2ee-management_1.1_spec-1.0.1.jar,geronimo-jms_1.1_spec-1.1.1.jar,hawtbuf-1.2.jar,xpp3-1.1.4c.jar,xstream-1.4.4.jar
my configuration is like this InputEventAdaptor
<?xml version="1.0" encoding="UTF-8"?>
<inputEventAdaptor name="jmsProxy" statistics="disable" trace="enable"
type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager">
<property name="java.naming.provider.url">tcp://localhost:61616</property>
<property name="transport.jms.SubscriptionDurable">true</property>
<property name="transport.jms.DurableSubscriberName">jmsProxy</property>
<property name="transport.jms.UserName">admin</property>
<property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
<property name="transport.jms.Password">admin</property>
<property name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</property>
<property name="transport.jms.DestinationType">queue</property>
</inputEventAdaptor>
above for incoming messages which will pick the messages from jmsProxy queue But its unable to pick the message from jmsProxy Queue.How would i initiate this to get the message into CEP and outputEventAdaptor I need to intialize some thing for jms could pick the messages from jMS why because i have tried in many ways all the configuration is ok but unable to pick the message from JMS
<?xml version="1.0" encoding="UTF-8"?>
<outputEventAdaptor name="JmsProxy" statistics="disable" trace="disable"
type="jms" xmlns="http://wso2.org/carbon/eventadaptormanager">
<property name="java.naming.security.principal">admin</property>
<property name="java.naming.provider.url">tcp://localhost:61616</property>
<property name="java.naming.security.credentials">admin</property>
<property name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</property>
<property name="transport.jms.ConnectionFactoryJNDIName">QueueConnectionFactory</property>
<property name="transport.jms.DestinationType">queue</property>
</outputEventAdaptor>
event builder configuration like this
<?xml version="1.0" encoding="UTF-8"?>
<eventBuilder name="ReadingsDtoBuilder" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventbuilder">
<from eventAdaptorName="jmsProxy" eventAdaptorType="jmsProxy">
<property name="transport.jms.Destination">JmsProxy</property>
</from>
<mapping customMapping="disable"
parentXpath="//ReadingsLiteTaildtos" type="xml">
<property>
<from xpath="//ReadingsLiteTaildto/ParameterId"/>
<to name="meta_parameterId" type="string"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/Slno"/>
<to name="meta_slno" type="string"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/FinalValue"/>
<to name="finalValue" type="int"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/InputText"/>
<to name="inputText" type="string"/>
</property>
<property>
<from xpath="//ReadingsLiteTaildto/InputValue"/>
<to name="inputValue" type="double"/>
</property>
</mapping>
<to streamName="org.sample.readings.dto.stream" version="1.0.0"/>
</eventBuilder>
The execution plan can be as follows.like this
<?xml version="1.0" encoding="UTF-8"?>
<executionPlan name="ReadingsAnalyzer" statistics="disable"
trace="disable" xmlns="http://wso2.org/carbon/eventprocessor">
<description>This execution plan analyzes readings and triggers notifications based on threshold.</description>
<siddhiConfiguration>
<property name="siddhi.enable.distributed.processing">false</property>
<property name="siddhi.persistence.snapshot.time.interval.minutes">0</property>
</siddhiConfiguration>
<importedStreams>
<stream as="readings" name="org.sample.readings.dto.stream" version="1.0.0"/>
</importedStreams>
<queryExpressions><![CDATA[from readings[finalValue > 100]
select *
insert into notificationStream;]]></queryExpressions>
<exportedStreams>
<stream name="notificationStream" valueOf="notificationStream" version="1.0.0"/>
</exportedStreams>
</executionPlan
I defined streams inside stream-manager-config.xml similar to the following.
<streamDefinition name="org.sample.readings.dto.stream" version="1.0.0">
<metaData>
<property name="parameterId" type="STRING"/>
<property name="slno" type="STRING"/>
</metaData>
<payloadData>
<property name="finalValue" type="INT"/>
<property name="inputText" type="STRING"/>
<property name="inputValue" type="DOUBLE"/>
</payloadData>
</streamDefinition>
<streamDefinition name="notificationStream" version="1.0.0">
<metaData>
<property name="parameterId" type="STRING"/>
<property name="slno" type="STRING"/>
</metaData>
<payloadData>
<property name="finalValue" type="INT"/>
<property name="inputText" type="STRING"/>
<property name="inputValue" type="DOUBLE"/>
</payloadData>
</streamDefinition>
its look like all well while i am sending any message to my jmsProxy queue the message is not reflecting to CEP for event and i am getting this message in CEP.
Means its unable to get the message into CEP and i am getting errors like this
[2014-02-18 11:57:53,159] INFO - {EventBuilderDeployer} Event Builder undeployed successfully : ReadingsDtoBuilder.xml
[2014-02-18 11:57:53,160] INFO - {EventBuilderDeployer} Event builder deployment held back and in inactive state :ReadingsDtoBuilder, Waiting for Input Event Adaptor dependency :jmsProxy
[2014-02-18 12:03:58,006] INFO - {InputEventAdaptorConfigurationFilesystemInvoker} Input Event Adaptor configuration deleted from file system : jmsProxy.xml
[2014-02-18 12:03:58,006] INFO - {InputEventAdaptorDeployer} Input Event Adaptor undeployed successfully : jmsProxy.xml
[2014-02-18 12:03:58,008] INFO - {InputEventAdaptorConfigurationFilesystemInvoker} Input Event Adaptor configuration saved in th filesystem : jmsProxy
[2014-02-18 12:03:58,009] INFO - {InputEventAdaptorDeployer} Input Event Adaptor deployed successfully and in active state : jmsProxy
[2014-02-18 12:03:58,009] INFO - {EventBuilderDeployer} Event Builder undeployed successfully : ReadingsDtoBuilder.xml
[2014-02-18 12:03:58,009] INFO - {EventBuilderDeployer} Event builder deployment held back and in inactive state :ReadingsDtoBuilder, Waiting for Input Event Adaptor dependency :jmsProxy
I am really fed up with wso2 docs no proper explanation on any topic.How its wirk how INCOMING message will get into input event builder Please help me to get out from this issue.
Thanks in advance,
Faisal shaik
Looking at your configuration, it seems that you have specified the input adaptor type as 'jmsProxy' which is incorrect. It should be corrected as simply 'jms'. i.e.
<from eventAdaptorName="jmsProxy" eventAdaptorType="jms">
The way the JMS connection works is as follows. The connection details are specified by the Input event adaptor. But the subscription to a particular topic or listening on a particular queue happens only after the event builder configuration is specified since the topic/queue name is specified in the event builder configuration as the property 'transport.jms.Destination'.
So if you specified the Destination as 'JmsProxy' in the event builder configuration, make sure that a queue by the name of 'JmsProxy' exists in the ActiveMQ broker and that events are published to this queue.
The easiest way to troubleshoot the issue you are encountering would be to enable tracing of CEP artifacts. Each event goes through the sequence of Input Event Adaptor -> Event Builder -> Event Processor (Execution Plan) -> Event Formatter -> Output Event Adaptor. If you enable tracing of all 5 artifacts and tracing reports incoming and outgoing events at Input Event Adaptor and only incoming events at Event Builder, you can conclude that the issue is in the event builder configuration and so on.
If you still encounter an issue after fixing the Input Event Adaptor type, please enable tracing and share the relevant messages printed in the trace to identify in which artifact the issue is arising.
Hope this helps,

is it possible for WSO2 ESB to send JMS messages between JMS brokers?

I have a service listening on a queue that I want to forward the message to a totally different broker. Is this possible in WSO2 ESB and if so how would this configuration be done? I tried specifying the endpoint using the other broker's transport url but that did not work...
Here's the WSO2 ESB proxy service configuration I've used to pick from a JMS queue and post to another queue (on an ActiveMQ JMS provider):
<proxy xmlns="http://ws.apache.org/ns/synapse" name="JMS_to_JMS_proxy_service" transports="jms" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full" separator="," />
<property name="OUT_ONLY" value="true" scope="default" type="STRING" />
<send>
<endpoint>
<address uri="jms:/Destination_Queue_Name?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://Your_Host:61616&transport.jms.DestinationType=queue" trace="disable">
<timeout>
<duration>30000</duration>
<responseAction>fault</responseAction>
</timeout>
<suspendOnFailure>
<initialDuration>0</initialDuration>
<progressionFactor>1.0</progressionFactor>
<maximumDuration>0</maximumDuration>
</suspendOnFailure>
</address>
</endpoint>
</send>
</inSequence>
</target>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>text/plain; charset=ISO-8859-1</default>
</rules>
</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
<parameter name="transport.jms.DestinationType">queue</parameter>
<parameter name="transport.jms.Destination">Source_Queue_Name</parameter>
</proxy>
Don't forget to enable the JMS Transport Sender under Configure -> Transports menu. Also the myQueueConnectionFactory refers to a parameter set under Configure -> Transports -> JMS Transport Listener.
Update: Newer versions of WSO2 ESB will not have a GUI option to enable/disable transports. To do so, you will have to modify the {ESB_ROOT_DIRECTORY}/repository/conf/axis2/axis2.xml file and un-comment the JMSListener/JMSSender that corresponds to your environment (ActiveMQ, WSO2 MB, etc.)

Resources