Declared Message store in ESB
<?xml version="1.0" encoding="UTF-8"?>
<messageStore class="org.apache.synapse.message.store.impl.jms.JmsStore" name="MySQLStockAdjustment" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="store.jms.destination">MySQLStockAdjustment</parameter>
<parameter name="store.failover.message.store.name">MySQLStockAdjustmentFailover</parameter>
<parameter name="store.jms.connection.factory">myQueueConnectionFactory</parameter>
<parameter name="store.producer.guaranteed.delivery.enable">true</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
</messageStore>
and I just want for beginning to store the mesage in it and than use a proxy to read messages form it ..
proxy is simple
<?xml version="1.0" encoding="UTF-8"?>
<proxy name="stockAdjustment" startOnLoad="true" transports="jms" xmlns="http://ws.apache.org/ns/synapse">
<target>
<inSequence>
<!-- get all data -->
<sequence key="AdjustmentContext"/>
<filter regex="MySQL" source="$ctx:StockSource">
<then>
<iterate expression="//request">
<target>
<sequence>
<property expression="//qty" name="qty" scope="default" type="STRING"/>
<property expression="//code" name="code" scope="default" type="STRING"/>
<log level="custom">
<property expression="fn:concat('parmams:Code: ' ,$ctx:code, ' ;Qty: ',$ctx:qty)" name="info"/>
</log>
<call blocking="true">
<endpoint key="StockAdjustmentEp"/>
</call>
</sequence>
</target>
</iterate>
</then>
<else/>
</filter>
</inSequence>
<outSequence>
<send/>
</outSequence>
<faultSequence>
</faultSequence>
</target>
<parameter name="transport.jms.Destination">MySQLStockAdjustment</parameter>
<parameter name="transport.jms.ConnectionFactory">myQueueConnectionFactory</parameter>
</proxy>
so when I send a data message trough Postman Im getting the following:
WARN {org.apache.axis2.transport.jms.JMSUtils} - Can't determine size of JMS message; unsupported message type : org.apache.activemq.command.ActiveMQObjectMessage {org.apache.axis2.transport.jms.JMSUtils}
ERROR {org.apache.axis2.transport.base.BaseUtils} - Unsupported JMS message type org.apache.activemq.command.ActiveMQObjectMessage {org.apache.axis2.transport.base.BaseUtils}
ERROR {org.apache.axis2.transport.jms.JMSMessageReceiver} - Unknown error processing message {org.apache.axis2.transport.jms.JMSMessageReceiver}
message is
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Body>
<StockAdjRequest>
<source>MySQL</source>
<request><qty>2</qty><code>PR2</code></request>
<request><qty>2</qty><code>PR2</code></request>
<request><qty>2</qty><code>PR2</code></request>
</StockAdjRequest>
</soapenv:Body>
</soapenv:Envelope>
I see that message ended in queue but I can't read it trough ActiveMQ web console ...
I documentation I found that maybe a proble that I need to "...If you are using ActiveMQ 5.12.2 and above when working with message stores, you need to set the following system property on server start up for the JMS message store of the ESB Profile to work as expected.
-Dorg.apache.activemq.SERIALIZABLE_PACKAGES="*" ...."
BUt I dont found HOW to do it ... can anyone help me ?
When you store a message in a JMS queue defining a messageStore and using store mediator, you don't just store the "textual" payload from the message, but the entire java MessageContext object is serialized and store as a binary message in the queue.
To read such a message, you need to use a message processor, you can't read it with a simple JMS proxy or even jms inbound endpoint.
And you can't read it with ActiveMQ console because it can't deserialize it
Related
I am using wso2ESB Version 4.9.0
I have a problem. My proxy like:
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="InOnlyProxy"
transports="http,https"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<log level="custom">
<property xmlns:ns="http://org.apache.synapse/xsd"
name="MESSAGE_ID_BOFORE"
expression="get-property('MessageID')"/>
</log>
<store messageStore="s2"/>
</inSequence>
</target>
<description/>
</proxy>
<messageProcessor name="Processor2" class="org.apache.synapse.message.processor.impl.forwarder.ScheduledMessageForwardingProcessor" targetEndpoint="EndPoint1" messageStore="s2" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="interval">1000</parameter>
<parameter name="client.retry.interval">1000</parameter>
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="message.processor.reply.sequence">replySequence</parameter>
<parameter name="is.active">true</parameter>
<parameter name="max.delivery.drop">Disabled</parameter>
<parameter name="member.count">1</parameter>
</messageProcessor>
<?xml version="1.0" encoding="UTF-8"?>
<sequence name="replySequence" trace="enable" xmlns="http://ws.apache.org/ns/synapse">
<log level="full">
<property name="REPLY" value="MESSAGE"/>
</log>
<send/>
</sequence>
Suppose my web-service has a message_id parameter and when i call this web-service with message_id=10, the web-service return same message_id with 10.
So now i call web-service without message_id.
I want save a message in a queue and a messageProcessor call message in the queue. So i want a ID for identity message in replaySequence. I use message ID but message id before call is different after call. so can you help me for identity message response?
I want call another web-service in replaySequence using Message-id.
Thanks.
I create a proxy and sequence to read file from source folder then write it to target folder with send mediator with VFS. My Proxy look like this :
<proxy name="XXX" transports="vfs" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence>
<property name="filename"
expression="fn:concat(get-property('transport', 'FILE_NAME'), '')"/>
<sequence key="write"/>
<log level="custom">
<property name="finish" value="finish"/>
</log>
</inSequence>
</target>
<parameter name="transport.PollInterval">1</parameter>
<parameter name="transport.vfs.ActionAfterProcess">MOVE</parameter>
<parameter name="transport.vfs.MoveAfterProcess">file:///after</parameter>
<parameter name="transport.vfs.FileURI">file:///process</parameter>
<parameter name="transport.vfs.FileNamePattern">.*.txt</parameter>
<parameter name="transport.vfs.ContentType">text/plain</parameter>
and my "write" sequence look like this :
<sequence name="write">
<property name="transport.vfs.ReplyFileName"
expression="get-property('filename')"
scope="transport"/>
<property name="OUT_ONLY" value="true"/>
<send>
<endpoint name="FileEpr">
<address uri="vfs:file:///Target"/>
</endpoint>
</send>
When I tried this proxy and sequence, the send mediator success to create a file in the "target" folder, but the problem is the content of the file is not written. So the size is 0 byte. My original file is 1000bytes. If I add this config in the sequence
<log level="full"/>
it works perfectly fine. My question is, do I need to use the log full config? but when I look at the File Processing sample in WSO2 web it doesn't use any log full config. So how can I use send mediator to write file without using any "log" property?
Thanks,
i am working with wso2esb 4.7.0 and ActiveMQ5.8.0 whenever i am working with wso2esb4.6.0 and ActiveMQ5.5.1 its working fine i am publishing my configuration below any one help for this
message store
<messageStore xmlns="http://ws.apache.org/ns/synapse"
class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore"
name="JMSQueue">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.destination">JMS_Reading_Queue</parameter>
</messageStore>
message processor
<messageProcessor xmlns="http://ws.apache.org/ns/synapse"
class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor"
name="faisal"
messageStore="JMSQueue">
<parameter name="max.delivery.attempts">4</parameter>
<parameter name="interval">1000</parameter>
</messageProcessor
and proxy is like this
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Jms"
transports="https http jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<log level="full"/>
<store messageStore="JMSQueue"/>
<property name="target.endpoint"
value="JmsEndpoint"
scope="default"
type="STRING"/>
</inSequence>
<outSequence/>
</target>
</proxy>
and i defined my endpoint in endpoints
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="JmsEndpoint">
<address uri="http://192.168.1.122:8282/services/ReadingsMobile"
format="soap11"/>
</endpoint>
now i am getting no target endpoint errors same configuration working in wso2esb4.6.0 mbut not working in wso2esb4.7.0
and its giving errors like this
[2013-08-21 16:48:32,049] WARN - ForwardingHandler Property target.endpoint not found in the message context. Removing the message.
[2013-08-21 16:49:32,093] WARN - SourceHandler Connection time out after request is read: http-incoming-13
Try doing the below modifications in the proxy configuration in order to get rid of the warnings;
a) Replace < target > with < target endpoint="JmsEndpoint" >
b) Move the "store" tag entry after the property where you set the "target.endpoint".
These changes seem to do the trick in my environment. Check if it fixes your issue too.
Hope this helps.
Basically the error you are getting says message processor cannot find the target.endpoint property from the stored message context.
The reason for this is, you are storing the message before setting this property.
You have to set the 'target.endpoint' property before the store mediator in the flow.
Proxy configuration should look likes follows.
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Jms"
transports="https http jms"
startOnLoad="true"
trace="disable">
<description/>
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<log level="full"/>
<property name="target.endpoint"
value="JmsEndpoint"
scope="default"
type="STRING"/>
<store messageStore="JMSQueue"/>
</inSequence>
<outSequence/>
</target>
</proxy>
I am using wso2esb4.7.0 and ActiveMQ5.8.0 i wish to store the messages in Queue
for this i try with this code but its not working
i created store which will helpful for storing the messages,my conumeing process has done in JAVA code so i need not worry about the Consuming
if i do it my message will appear in acivemq UI
my config is like this
<messageStore name="JMSQueue" class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.destination">faisal5_Queue</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
</messageStore>
and i am trying to pass the message through the proxy for that i write simple proxy service for that
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="Jms"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="messageType" value="application/json" scope="axis2"/>
<log level="full"/>
<property name="OUT_ONLY" value="true"/>
<store messageStore="JMSQueue"/>
</inSequence>
<outSequence/>
</target>
<description/>
</proxy>
in this case my queue is not creating in Activemq Why its happening
if i create message process then only my QUEUE is appearing in ActiveMQ UI
will you write sample code for this my scenario is simple i wsih to store my client messages without failure they will consume after the storing process
Your proxy and message store are okay, I tested those.
I think you have not correctly Configure the ESB with ActiveMQ.
Follow this link and place the jars as mentioned and edit the Axis2.xml. Then try with your code. It should work
You can simply use the below config to store messages in activemq.
Since you are not using a message processor, it is no need of making a message store. So you can simple store messages in the queue as follows.
<proxy name="JmsProxyTest"
transports="https http"
startOnLoad="true"
trace="disable">
<target endpoint="jmsEndpoint">
<inSequence>
<property name="OUT_ONLY" value="true"/>
<property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
</inSequence>
<outSequence>
<drop/>
</outSequence>
</target>
<endpoint name="jmsEndpoint">
<address uri="jms:/faisal5_Queue?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory&java.naming.provider.url=tcp://127.0.0.1:61616&transport.jms.DestinationType=queue"/>
Also you better check you have configured activemq with esb correctly.
Thanks.
i have done all the changes in axis2 file and drop the jar files in lib
my message process is working fine and storing also
when ever i am sending request to proxy which consist store mediator and defined target.endpoint also after request message storing in message store its not processing
my configure files
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Message" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="full"/>
<property name="faisal" value="faisal" scope="default" type="STRING"/>
<property name="target.endpoint" value="JmsChecking" scope="default" type="STRING"/>
<store messageStore="faisal5"/>
</inSequence>
<outSequence>
<log level="full"/>
</outSequence>
</target>
<description></description>
</proxy
and message store is
<messageStore name="faisal5" class="org.wso2.carbon.message.store.persistence.jms.JMSMessageStore" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="java.naming.factory.initial">org.apache.activemq.jndi.ActiveMQInitialContextFactory</parameter>
<parameter name="java.naming.provider.url">tcp://localhost:61616</parameter>
<parameter name="store.jms.destination">faisal5_Queue</parameter>
<parameter name="store.jms.JMSSpecVersion">1.1</parameter>
<parameter name="store.jms.cache.connection">false</parameter>
</messageStore>
and message processor
<messageProcessor name="faisal" class="org.apache.synapse.message.processors.forward.ScheduledMessageForwardingProcessor" messageStore="faisal5" xmlns="http://ws.apache.org/ns/synapse">
<parameter name="interval">1000</parameter>
<parameter name="max.delivery.attempts">4</parameter>
</messageProcessor>
and endpoint define which is like this
and its entries
<endpoint xmlns="http://ws.apache.org/ns/synapse" name="JmsChecking">
<address uri="http://localhost:8282/services/JmscheckingEndpoint" format="soap11">
<suspendOnFailure>
<progressionFactor>1.0</progressionFactor>
</suspendOnFailure>
<markForSuspension>
<retriesBeforeSuspension>0</retriesBeforeSuspension>
<retryDelay>0</retryDelay>
</markForSuspension>
</address>
</endpoint>
end point consist log values proxy
proxy xmlns="http://ws.apache.org/ns/synapse" name="JmscheckingEndpoint" transports="https,http" statistics="disable" trace="disable" startOnLoad="true">
<target>
<inSequence>
<log level="custom">
<property name="Message" value="JMs working fine"/>
<property name="value" expression="//mail/text()"/>
</log>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
<description></description>
</proxy>
Now i am sending my request
this log value is printing like this
[2013-07-25 11:42:03,039] INFO - LogMediator Message = JMs working fine, value = faisal.shaik#youtility.in
[2013-07-25 11:42:03,039] INFO - LogMediator Message = JMs working fine, value = faisal.shaik#youtility.in
[2013-07-25 11:42:03,039] INFO - LogMediator Message = JMs working fine, value = faisal.shaik#youtility.in
[2013-07-25 11:42:03,039] INFO - LogMediator Message = JMs working fine, value = faisal.shaik#youtility.in
as well as message process is deactivating .if i am send one more request its just storing its not processing bcoz of message process is deactivate state
this JMS work only like this
MY scenario is i will get request if endpoint is available message will deliver and delete as well if endpoint is unavailable message will retry max mention times even also endpoint not available then it will store in message store
what is the use of this parameter will you please explain about this
i followed this link http://docs.wso2.org/wiki/display/ESB460/Store+and+Forward+Using+JMS+Message+Stores
where can i found this faisal5_Queue store point is it exist as folder
<parameter name="store.jms.destination">faisal5_Queue</parameter>
No it does not create a folder. when you mention the "store.jms.destination" using
faisal5_Queue wso2 esb will create an queue in your message broker(In your case ActiveMQ) with your specified name "faisal5_Queue". If you did not mention explicitly, WSO2 esb will create an queue with "YourMessageStoreName_Queue"
you can refer furthermore on these blogs to understand the behaviour of "Message Store" and "Message Processor"
http://vanjikumaran.blogspot.com/2013/08/jms-store-and-jms-processor-behavior.html
http://vanjikumaran.blogspot.com/2013/08/jms-messagenstore-and-jms-message.html
http://vanjikumaran.blogspot.com/2013/08/jms-messagen-store-and-jms-message.html