Tuesday, September 16, 2014

Implementing Guaranteed delivery in WSO2 ESB

Start apacheMQ
~/activeMQ/apache-activemq-5.9.1/bin
./activemq start

Check the web console and make sure it is running
http://localhost:8161/admin

Copy following jars from apacheMq/lib to ESB_HOME/repository/components/lib
activemq-broker-5.9.1.jar  
activemq-client-5.9.1.jar 
geronimo-j2ee-management_1.1_spec-1.0.1.jar  
geronimo-jms_1.1_spec-1.1.1.jar

Build the SimpleStockQuoteService in ESB samples
~/ESB/wso2esb-4.8.1/samples/axis2Server/src/SimpleStockQuoteService$
ant

Start the axis2Server in ESB samples
~/products/ESB/wso2esb-4.8.1/samples/axis2Server$
./axis2server.sh

Make sure SimpleStockQuoteService is running by pointing the browser to
http://localhost:9000/services/SimpleStockQuoteService?wsdl


Start ESB
~/ESB/wso2esb-4.8.1/bin$
 ./wso2server.sh

Log into management console
https://10.100.0.115:9443/carbon/admin/index.jsp

Go to source view and paste this code
   


      org.apache.activemq.jndi.ActiveMQInitialContextFactory
      tcp://localhost:61616
      1.1




   
1000 1000 true

Log in to the management console and invoke the SampleProxy via TryIt tool. You will not see a response their (due to our proxy implementation here). But if you check the terminal of axis2Service you will see something like follows.
samples.services.SimpleStockQuoteService :: Generating quote for : APPLE
That means messagestore and processor has worked successfully and your message has hit the backend (i.e SimpleStockQuoteService) Also if you looked at web console of activeMQ for queues @
http://localhost:8161/admin/queues.jsp you would see that enqueued and dequeued messages are equal to one.




Test On guaranteed Delivery

Stop the SimpleStockQuoteService  Again invoke the SampleProxy from tryit tool (this time for symbol IBM) then if you check on activeMQ web console you would see that enqueued messages are 2 but dequeued message count is 1.

Also notice the error in ESB terminal.
ERROR - ForwardingService BlockingMessageSender of message processor [Forwarder] failed to send message to the endpoint NFO - ForwardingService Pausing the service of message processor [Forwarder] INFO - HTTPSender Unable to sendViaPost to url[http://localhost:9000/services/SimpleStockQuoteService] java.net.ConnectException: Connection refused

Then again start the SimpleStockQuoteService 
View the activeMQ web console you would see that both enqueued and dequeued messages count is 2.

Also in the axis2Server terminal you would see that it has received the request for symbol IBM
samples.services.SimpleStockQuoteService :: Generating quote for : IBM

Conclusion

Once the server is restarted enqueued messages have been delivered to the backend. This concludes the guaranteed delivery.


No comments: