Thursday, July 16, 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 read extra parameters from JMS queue/topic, these extra parameters are custom JMS header properties. We can read custom header property for JMS queue in OSB.

In this post, we show how to read 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.

In previous post, we see how we see set custom header property for JMS queue. Click here to read that post.

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

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

OSB_ReadCustomHeaderProperty_CreateProject

OSB_ReadCustomHeaderProperty_CreateProxy

OSB_ReadCustomHeaderProperty_serviceType




In Transport tab, choose jms from protocol drop-down as we are dealing with JMS queue i.e. we need to read the message from 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.

Make sure that “Get All Header” option is set to yes as we need to read JMS header properties. If we don’t select this option then we not able to read the custom header property from JMS queue.
OSB_ReadCustomHeaderProperty_Transport


In the message flow tab of proxy service, add pipeline pair after start node. Add stage node in request pipeline and inside stage add log action. We added log action to log custom jms header property value.

OSB_ReadCustomHeaderProperty_MessageFlow


Click on log action and then click on expression. We read the JMS custom header property from inbound variable, you can read the custom header property value using below syntax.

$inbound/ctx:transport/ctx:request/tp:headers/tp:user-header[@name='MessageType']/@value

Here MessageType is custom header property name.

OSB_ReadCustomHeaderProperty


Save your proxy service and deploy it to server. Now put message to JMS queue along with custom header property. Proxy picks the message and writes custom header property value in log file.

OSB_ReadCustomHeaderProperty_Testing


1 comments :

  1. How is that done in 12c. I can't see the Header when I try to add to the log activity

    ReplyDelete