WSO2 Message Broker on-demand message consumtion from WSO2 ESB - wso2

I'm trying to setup the following scenario using ESB and Message Broker.
Flow 1:
Client 1 Sends the message to ESB -> ESB consumes the message and stores it into the queue -> End of flow 1;
Flow 2:
Client 2 sends a request to ESB to get messages -> ESB gets the messages from the queue defined for Client 2 -> ESB sends back a pack of message that were present in the queue
While there's no problems to implement Flow 1. Documentation and examples refer to store and forward pattern so I didn't see any live examples on consuming message upon clients request - the "store and pull" model.
Could anyone advise please?
Reference links:
http://docs.wso2.org/wiki/display/ESB460/Sample+702%3A+Introduction+to+Message+Forwarding+Processor
http://docs.wso2.org/wiki/display/MB201/Integrating+WSO2+ESB
Best Regards,
Vladimir.

You can refer to this URL: http://wso2.org/library/articles/2013/03/configuring-wso2-esb-wso2-message-broker
I am also struck on Flow 2. I am unable to get data from mesaagebroker through my proxy

First you need to save your message in a queue
<address uri="jms:/Queue1?transport.jms.ConnectionFactoryJNDIName=QueueConnectionFactory&java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory&java.naming.provider.url=tcp://localhost:5672&transport.jms.DestinationType=queue&java.naming.provider.url=repository/conf/jndi.properties" statistics="disable"/>
You need to specify the queue name in the repository/conf/jndi.properties as mentioned here
http://docs.wso2.org/wiki/display/MB201/Integrating+WSO2+ESB
Then you can define a proxy with the same name of the JMS queue to consume that queue
<proxy xmlns="http://ws.apache.org/ns/synapse" name="Queue1" transports="jms" startOnLoad="true" trace="disable" statistics="disable">
<target inSequence="your_in_sequence" outSequence="your_out_sequence" faultSequence="your_fault_sequence"/>
<parameter name="transport.jms.ContentType">
<rules>
<jmsProperty>contentType</jmsProperty>
<default>application/xml</default>
</rules>
</parameter>
</proxy>
You can use this proxy service to consume queue you have used to save the message

Well this is more like a custom requirement. You can achive this using a custom class mediator or a connector. [1]
[1] https://docs.wso2.com/display/ESB481/Creating+a+Connector

Related

WSO2 ESB. Differences between v. 5.0.0 and v. 4.9.0. Send mediator

In WSO2 ESB v. 4.9.0 send metiator did not terminate sequence where it is and all parent sequences and at last proxy service or API. So, in code :
...
<!-- This seqience has send mediator -->
<sequence key="ElabaFtpFileWrite"/>
<!-- This sequence has send mediator -->
<sequence key="ElabaSendMail"/>
<!-- for instance, some mediator or another logic -->
<log level="full"/>
...
second sequence and log mediator are always performed.
On the contrary, in version 5.0.0. nether second sequence nor log mediator are performed.
According to the documentation about send mediator of v. 5.0.0 second behavior is right. But why in v. 4.9.0 send worked in different way and I didn't find any notice about such issue.
I think I somehow did not notice because I am not very experienced user of WSO2 products.
I changed send mediator to call mediator in first and second sequences and then log mediator is performed.
Is such resolution right?
See https://github.com/wso2/wso2-synapse/commit/dc78d18210f3cbd8d2eb04bcd7236658ee3731f4 : on Jun 29, 2016, send mediator has been changed to return "false" (instead of "true") to avoid remaining mediators to be executed
The documentation reflect this : compare https://docs.wso2.com/display/ESB490/Send+Mediator and https://docs.wso2.com/display/ESB500/Send+Mediator you will notice this add-on :
Do not add any mediator configurations after Send mediator in the same sequence, because WSO2 ESB does not process them. Any mediator configuration after the Send mediator should go to the outSequence or receive sequence.

How to use two differnet queues in wso2 esb

I have Websphere MQ and Active MQ configured in WSO2 ESB. I want to get message from Websphere MQ and send it to ActiveMQ. When I used Websphere MQ Queue name to get the messages it is automatically creating a Queue in ActiveMQ and sing that and not accessing Websphere MQ. How to use two different Queue as I have mentioned?
My proxy to read message from Queue:
<proxy name="read_from_MQ" transports="jms" startOnLoad="true" trace="disable">
<description/>
<target>
<inSequence>
<log level="full" />
<store messageStore="JMSMS" />
<!--ActiveMQ message store-->
</inSequence>
</target>
<parameter name="transport.jms.Destination">QUEUE</parameter>
<!-- Webshpere MQ Queue but it creates a new one in ActiveMQ -->
</proxy>
Thanks.
Your usecase is to pick the messages from Webshpere MQ Queue and store it in a ActiveMQ message store. Have you configured listeners and senders for ActiveMQ in $ESB_HOME/repository/axis2/axis2.xml? If you did, you need to revert them. You only need to set up the broker server itself and do not need to configure the listeners and senders in axis2.xml for a message store. In your case, you only need to configure these for Webshpere MQ Queue, not for ActiveMQ. Please go through [1] for more details on this (specially Configure the Broker Server section)
[1] https://docs.wso2.com/display/ESB481/Store+and+Forward+Using+JMS+Message+Stores

SMPP using WSO2

Hi Followed the blog mentioned in SMS Transport sender in wso2 ESB and configured axis2.xml for transportSender and transportReceiver. I am able to send a message from ESB to SMPP simulator but I am unable to receive message from SMPP simulator to ESB.
In the SMPP Simulator, I tried by adding bot 't'/'r' to enable transmitter/receiver and also tried by giving tr assuming that it is for tranceiver in users.txt but still I am unable to get a response in ESB.
Could you please help in implementing SMPP -> ESB scenario. Any link that describes this procedure also helpful for me. ( I am unable to find such)
I am editing this to make my scenario more clear
My simulator is opensmpp-sim. I added the user details in user.txt as
name=esb
password=esb
timeout=unlimited
bound=t,r
I executed the simulator with port 2775.
In ESB, axis2.xml I gave the following configurations
Transport Receiver
<transportReceiver name="sms" class="org.apache.axis2.transport.sms.SMSMessageReciever">
<parameter name="systemType">cp</parameter>
<parameter name="systemId">esb</parameter>
<parameter name="password">esb</parameter>
<parameter name="host">192.168.0.2</parameter>
<parameter name="port">2775</parameter>
<parameter name="phoneNumber">94777179968</parameter>
</transportReceiver>
Transport Sender
<transportSender name="sms" class="org.apache.axis2.transport.sms.SMSSender">
<parameter name="systemType">cp</parameter>
<parameter name="systemId">esb</parameter>
<parameter name="password">esb</parameter>
<parameter name="host">127.0.0.1</parameter>
<parameter name="port">2775</parameter>
</transportSender>
Note: 192.168.0.2 = 127.0.0.1 = localhost
Scenarios
1. Sending a message from ESME (ESB) to SMSC (Simulator)
Sequence
<sequence xmlns="http://ws.apache.org/ns/synapse" name="TEST_SMS">
<send>
<endpoint key="SMSC"/>
</send>
</sequence>
Endpoint
sms://94777179968
I exposed this sequence as a REST API. When I send a message, the message reached Simulator but there is no response in return.
2. Sending a message from SMSC (Simulator) to ESMC (ESB)
From simulator when I send message, it reaches ESB. In debug mode the message is printed in ESB log. But I am unable to handle it. How can I configure proxy service/ sequence to get that message. My goal is to get that message and initiate a process.
Thanks in advance.

Can we Use Idempotent Receiver against Jms message with ActiveMq

I am inserting readings in Data Base using WSO2Esb and WSO2DSS my inserting is working fine
while i am getting request reading from mobile side i need response with 200 and unique value
some times connection failed after inserting means insertion is over but client did'nt get response in that case mobile side client sending request one more time so again my proxy sending this request to database .So my database storing duplicate values for every 2 or 3 readings its totally unfair for client for that i find a small solution
Using Idempotent service can we find solution for this
<!-- The example shows WSO2 ESB acting as an Idempotent Receiver -->
<definitions xmlns="http://ws.apache.org/ns/synapse">
<proxy name="IdempotencyReceivingProxy">
<target>
<inSequence>
<log level="full"/>
<!-- Store all messages in an Jmsmemory message store -->
<store messageStore="MyStore"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
<!-- Further mediation of messages are done in this sequence -->
<sequence name="next_seq">
<send>
<endpoint>
<address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
</endpoint>
</send>
</sequence>
<messageStore name="MyStore"/>
<!-- Resequencing Processor takes the next sequence number and hand over to "next_seq" and preserve Idempotency -->
<messageProcessor
class="org.apache.synapse.message.processors.resequence.ResequencingProcessor"
name="ResequencingProcessor" messageStore="MyStore">
<parameter name="interval">2000</parameter>
<!-- Takes the sequence number using Xpath -->
<parameter name="seqNumXpath" xmlns:m0="http://services.samples" expression="substring-after(//m0:placeOrder/m0:order/m0:symbol,'-')"/>
<parameter name="nextEsbSequence">next_seq</parameter>
<parameter name="deleteDuplicateMessages">true</parameter>
</messageProcessor>
</definitions>
for this i followed this link http://docs.wso2.org/wiki/display/IntegrationPatterns/Idempotent+Receiver
Is it suitable for my requirement
I don't think this would suit your requirement. What the resequencing processor does is, order the messages according to the number in seqNumXpath property. So the messages should include a number and you should obtain this number using a xpath expression. When deleteDuplicateMessages parameter is set to true, it will delete duplicate messages that have the same sequence number as obtained from seqNumXpath parameter.
In your case you can use a store and forward scenario to prevent client having to send multiple requests. Set FORCE_SC_ACCEPTED property to true in your proxy service to always return 202 response to client. Then message will be stored in msg store and will be forwarded using message processor.
http://docs.wso2.org/wiki/display/ESB470/Store+and+Forward+Using+JMS+Message+Stores
http://wso2.com/library/articles/2011/10/implementing-store-forward-messaging-patterns-wso2esb-part-1
Apache Camel has an idempotent consumer http://camel.apache.org/idempotent-consumer.html that uses a IdempotentRepository to see if it has been seen before; if it has, the message is consumed; if its not, then the message is processed and the ID is added to the repository. Take a look at http://camel.apache.org/sql-component.html particularly section 'Using the JDBC based idempotent repository'. This is exactly what we need. Because in our case the duplicate messages can arrive even days later ( offline clients e.g. mobile devices) but each message has a UUID field which can be used to detect duplicates.
Is there a similar implementation available in wso2esb? If yes any pointers to the documentation? If no what are our alternatives to get this behaviour while using wso2esb?

How to populate SOAP headers like From, ReplyTo in ESB 4.0.3

We are using WSO2 ESB 4.0.3 with Data services feature on MAC OSX 10.7.4.
I have proxy service which forwards the message to Data Service. When there is any fault in Data service the fault is returned to calling proxy service in OUTSEQUENCE. Now if there is any error I forward this to common error handler from proxy service which happens in OUTSEQUENCE. This common error handler is another proxy service only.
Now when the Error handling is completed the control returns back to original proxy service which called the error handling proxy service. But what happens is when the control returns to original proxy service from error handler it AGAIN starts executing the OUTSEQUENCE of proxy service.
So for me it is executing the OUTSEQUENCE of proxy service twice in case of fault from Data Service.
Is it standard behavior? I used to Java kind of executing where when the call from method returns it starts executing the next line. But here looks like it again starts executing the OUTSEQUENCE from beginning.
To avert executing the OUTSEQUENCE from beginning again I populate the value at "transport" scope in Error hanlder proxy which will used in filter mediator to avoid executing the logic in OUTSEQUENCE twice.
I am trying to find if there are any SOAP headers I can use instead of setting the property. I see no SOAP headers being set like "From" or "ReplyTo" and I believe message co-ordination happens with MessageId. How can we use these SOAP headers instead of property to divert the flow logic.
Please help.
thanks
Abhijit
In this case instead of using send mediator to invoke the web service you can use the call out mediator. Which makes a blocking call to error handling service and returns to the same place.
And also with esb 4.0.3 you can specify the receive sequence at the send mediator level. By default the response is received at the outsequence level.
eg. <send receive="fundTransferSequence">
<endpoint>
<address encoding="UTF-8" statistics="disable"
uri="http://10.1.23.11:8888/EgateValidWS/EgateValidWSSoapHttpPort" >
</address>
</endpoint>
</send>