Wednesday, January 11, 2012

Event-driven Publish-Subscribe SOAP over http messaging in Oracle OSB



This blog discuss how to implement Publish-Subscribe (one producer, multi subscribers) channel in Oracle OSB. This system embodies Event-driven architecture: the consumers listen to event-messages, published to a topic, by the producer. This channel is reliable, i.e. it implements:
durable subscriber: to avoid missing messages when the consumer is not listening (e.g. disconnect for maintenance)
guarantee delivery: to make sure that all messages are delivered even when the consumer fail
idempotent receiver: dealing with duplicate messages (receive no duplicate messages)
We use SOAP with WSDL since it's a good practice to define your interfaces with WSDL. We use http since in our existing system we use a lot of RPI-style web services over http.

How
1. build a jms producer business service (BS): SOAP based on the jmssimple.wsdl (downloadable below)
transport tab: jms protocol and the queue address (please read my other blog about how to setup jms resources in Weblogic)
jms transport tab: topic type, message type: text... handy for test since it's readable,no response
2. build one or more jms consumer proxy: SOAP also based on the jmssimple.wsdl,
transport tab: jms protocol and the queue address (same as the address in the BS),
jms transport tab: topic type and message type: text, durable susbcription, XA enable
message handling tab: enable transaction & same transaction response. The transaction will rollback (i.e. put the message back to the queue) in case if a fail consumer, thus this enables guarantee delivery.
3. wrap the producer BS with a proxy: SOAP with a wsdl, http transport.
Add a routing options in the request routing in the proxy message flow, enable the Quality of Service in this option.
4. make a consumer BS point to other webservice (e.g. a FileWriter in my example.)


Test:
1. Send a http message (e.g. using SOAPUI) to the producer proxy, the FileWriter service will write a file containing the message from the consumer BS.
2. Disable the FileWriter service
3. Send a http message to the producer proxy again.
4. After awhile turn on the FileWriter service service again, this service will catch up with the messages he missed and write these in the files.

Logging
You can watch the jms message in the jms log files: /servers / /logs/ jmsServers/ . By default the jms logging is off, so you may need to turn on the jms logging (console: JMS resource > Configuration > Logging tab.)

Retrial
You can define also how many times OSB will retry to deliver the messages and define a retrial time out. You may define also an error-channel queue to contain your undelivered messages (after fail retrial attempts.)

Please download the example here (osb 11.1.3 config export).

Using Oracle OSB is an easy way to learn SOA (click here there and voila... your SOA solution is ready.) In the future I will discuss how to implement this using open source ActiveMQ & Spring framework.

Note about terminologies:
I tried to use consistent terminologies (e.g. producer, consumer) while discussing point-to-point queue and publish-subscribe topic in my blogs. In practice, while discussing publish-subscribe topic people use publisher instead of producer and
subscriber instead of consumer.




See also blogs compilation about messaging for integration: http://soa-java.blogspot.nl/2012/01/asynchronous-messaging-for-integration.html


Please share comment.

Source: Steve's blog http://soa-java.blogspot.com

References
http://eaipatterns.com/
Hohpe's Enterprise Integration Patterns... one of the most popular SOA books in the market


The Definitive Guide to SOA: Oracle Service Bus

1 comment:

Anonymous said...

Great post! You say that a receiver receives a message just once. But what about message redelivery? I mean if one consumer fails after the number of retries configured on the topic and the message goes to the error destination. Then someone moves the message back to the topic. Is there a way to avoid that the receivers that had consumed the message before consume the message again? Thanks