Thursday, July 2, 2015

JMS queue and Topics are mainly used for persistence and reliability, we use JMS adapter to connect to JMS queue or topic in SOA Suite but in OSB we use jms protocol to connect to JMS queue and topic, we can also use JCA adapter but jms protocol is always preferred.  We usually deals with XML or Non-XML content while working with JMS queue and topic and there are some pre-defined header properties for JMS queue and topic that are used for specific purpose.

Sometime we come across a requirement where we need to send extra parameters to system through JMS queue/topic but we don’t want to send that in message content so to achieve that we can use custom JMS header properties. We can set custom header property for JMS queue along with value and that can further read by target system and get required parameter value.

In this post, we show how to set custom JMS header properties in OSB. For this post, we created one sample queue (TargetQueue) on local server and we put the message to this queue along with custom header property. We created one OSB project in eclipse under OSB configuration and created required folder structures.

First create business service that will put the message to JMS queue, to create that right click on the business folder and click on new and choose business service option. Choose “Messaging service” as Service Type.

OSB Set JMS Custom Header Properties Create Business Service


In Message Type configuration, select “Text” as Request Message Type as we will send simple text message to test this use case and choose “None” as Response Message Type as we are not expecting any response back once we put the message to JMS queue.

OSB Set JMS Custom Header Properties Create Business Service


In Transport tab, choose jms from protocol drop-down as we are dealing with JNS queue i.e. we need to send that message to JMS queue. In Endpoint URI text box fill the required values for JMS endpoint URI, for this use case we use default connection factory and TargetQueue JMS queue. Choose default settings for all other tabs and save the business service.

OSB Set JMS Custom Header Properties JMS Endpoint URI


Now let’s create proxy service, for that right click on newly created business service, click on Oracle Service Bus and then choose Generate Proxy service option. This will create the proxy service. Open the proxy service and open the message flow tab.

OSB Set JMS Custom Header Properties Create proxy Service


In the message flow tab of proxy service, you see route node is added as we created proxy service directly from business service. Since we need to set custom header property for JMS queue so we need to add Transport Header action in the request action of route node.

OSB Set JMS Custom Header Properties Proxy Message Flow


Open the Transport header action and in first tab (Transport Header) click on “Add Header” button, this will add one header in below window. To set custom header property for JMS, choose “Other” and mention custom header property name, for this use case we set “MessageType” as custom header property for JMS queue. Then choose “Set Header to:” and click on <Expression> and assign value to custom header property.

OSB Set JMS Custom Header Properties


Save your proxy service and deploy it to server. Now test the proxy service, to test it open OSB test console and send text message. Then go to JMS queue and open the message, you see custom header property showing in the JMS queue.

OSB Set JMS Custom Header Properties Testing


OSB Set JMS Custom Header Properties Testing



0 comments :

Post a Comment