Search This Blog

SOA 11g- Set Custom JMS Header properties In Mediator & BPEL

In this post, I will show you how you can set custom JMS header properties in Mediator and BPEL components.

By Default a JMS message includes a number of header fields that contain information used to identify and route messages. The supported headers for an incoming message are:

Ø JMSCorrelationID
Ø   JMSDeliveryMode
Ø   JMSExpiration
Ø   JMSMessageID
Ø   JMSPriority
Ø   JMSRedelivered
Ø   JMSTimestamp
Ø   JMSType

But we can also set Custom properties.

Mediator: To set custom JMS header property in Mediator follows below steps.

Ø  Open .mplan file and click on assign activity. Here we are defining new custom header property (city).
Ø  To set city custom header property choose “jca.jms.JMSProperty” and append “.city” to it. You can assign any expression or hard-code this property value.








 





BPEL: To set custom JMS header property in BPEL follows below steps.
·         Go to *.bpel file, check the invoke code and add a new property called jca.jms.JMSProperty.city, for instance:

<invoke name="Invoke1" inputVariable="Invoke1_Produce_Message_InputVariable"
            partnerLink="Produce_Message" portType="ns1:Produce_Message_ptt"
            operation="Produce_Message" bpelx:invokeAsDetail="no">
              <bpelx:inputProperty name="jca.jms.JMSProperty.city" variable="cityVar"/>
 </invoke>


 

Currently this property is equal to cityVar but you can also use expression to assign value to city property.

              <bpelx:inputProperty name="jca.jms.JMSProperty.city" expression="2"/>

Remember you will not find this property in header tab, you need to manually set this property in *.bpel file for specific invoke.

When you will run the composite, you will see custom JMS header property at admin console for that queue.




Message Selector Proprty in JMS :


I will show you how to set Message Selector property in JMS adapter to filter the incoming message based on custom JMS header property.We use Message Selector property when your messaging application needs to filter the messages it receives.

 This field is also optional. It filters messages based on header and property information. The message selector rule is a Boolean expression. If the expression is true, then the message is consumed. If the expression is false, then the message is rejected. 

For example, you can enter logic, such as:  city in ( 'Mohali', 'Mumbai', 'Delhi')


Message Selector Property
I explained how to set custom JMS header property. In this post I will show you how to set Message Selector property in JMS adapter to filter the incoming message based on custom JMS header property.
We use Message Selector property when your messaging application needs to filter the messages it receives.
This field is also optional. It filters messages based on header and property information. The message selector rule is a Boolean expression. If the expression is true, then the message is consumed. If the expression is false, then the message is rejected.
For example, you can enter logic, such as:
·         city in (‘Mohali’, 'Mumbai', 'Delhi')
·         city=’Mohali’

To set the Message selector property, open JMS adapter configuration Wizard. Here you can set Message selector property as shown in below diagram.
- See more at: http://soawork.blogspot.de/2013/10/message-selector-property-jms-adapter.html#sthash.eBG71n2u.dpuf

Dynamically enable or disable items of ADF bound List (af:selectOneChoice) -Oracle ADF

This tutorial is about a requirement of conditionally enabling/disabling items (values) of adf bound List (af:selectOneChoice) component
here i am taking reference of default HR Schema (Departments and Location table )

See the steps-
  • Create a Fusion Web Application and business components using both tables
  •  Now create List of Values (Lov) on locationId of departments VO from Location VO
  • Set List Attribute to LocationId and for UI city will be shown
  • Now Drag Departments VO from Data Control on page as a form
  •  Select LocationId list field and delete f:selectItems from it, now drag af:selectItem as child of af:selectOneChoice and surround it with af:forEach 
  • Add tree binding of Location ViewObject to page bindings in order to populate list items using forEach
  •  Now select af:forEach and set its property and variable name, as we have to iterate through Location VO for list items
  •  Again select af:selectItem and set its value and label property using forEach variable's  
  • Now run your application, and see that list box is ready with values
  • Now we have to disable its values as a condition basis, i have written an Expression on af:selectItem's disabled property


  • I have written condition for DepartmentId 100 and 110, see in source of page

  • <af:selectOneChoice value="#{bindings.LocationId.inputValue}" label="#{bindings.LocationId.label}"
                                            required="#{bindings.LocationId.hints.mandatory}"
                                            shortDesc="#{bindings.LocationId.hints.tooltip}" id="soc1"
                                            contentStyle="width:150px;color:red;">
                            <af:forEach items="#{bindings.Locations1.rangeSet}" var="list">
                                <af:selectItem label="#{list.City}" id="si1" value="#{list.LocationId}"
                                               disabled="#{ (bindings.DepartmentId.inputValue==100 and (list.LocationId==1000 || list.LocationId==1300)) || (bindings.DepartmentId.inputValue==110 and (list.LocationId==1500 || list.LocationId==1600 || list.LocationId==1700 || list.LocationId==1800 || list.LocationId==1900))}"/>
                            </af:forEach>
                        </af:selectOneChoice>
    

  • Now value given in Expression for Location Id will be disabled for given Department
  • Run your page and select DepartmentId 100 and 110 to see disabled list items


EO Code snippet for ADF

Creating an entity instance


    public DepartmentEOImpl createDeptEntity() {
        //Find the entity definition from the implementation class
        EntityDefImpl departmentEODef = DepartmentEOImpl.getDefinitionObject();
        //Create the blank entity instance
        DepartmentEOImpl newDept = (DepartmentEOImpl)departmentEODef.createInstance2(this.getDBTransaction(), null);
        newDept.setDepartmentId(1000);
        try {
            getDBTransaction().commit();
        } catch (JboException ex) {
            getDBTransaction().rollback();
            throw ex;
        }
        return newDept;
    }

Find and update an entity row

    public void findAndUpdateDeptEntity(Integer deptId) {
        //Create Key
        Key key = DepartmentEOImpl.createPrimaryKey(deptId);
        //Find the entity row
        DepartmentEOImpl deptRow =
            (DepartmentEOImpl)DepartmentEOImpl.getDefinitionObject().findByPrimaryKey(getDBTransaction(), key);
        deptRow.setDepartmentName("IT Admin");
    }

Remove an entity row

    public void findAndRemoveDeptEntity(Integer deptId) {
        Key key = DepartmentEOImpl.createPrimaryKey(deptId);
        DepartmentEOImpl deptRow = (DepartmentEOImpl)DepartmentEOImpl.getDefinitionObject().findByPrimaryKey(getDBTransaction(), key);
        deptRow.remove();
    }

Find the entity object by using primary key

    private DepartmentEOImpl findDepartmentById(int deptId) {
        //Find the entity definition from the implementation class
        EntityDefImpl departmentEODef = DepartmentEOImpl.getDefinitionObject();
        //Create the Key object
        Key orderKey = DepartmentEOImpl.createPrimaryKey(new Integer(deptId));
        //Find and return the desired instance
        return (DepartmentEOImpl)departmentEODef.findByPrimaryKey(getDBTransaction(), orderKey);
    }

To programmatically access the destination entities using the association accessor generated on entity implementation class

    private DepartmentEOImpl findDepartmentById(int deptId) {
        EntityDefImpl deptEODef = DepartmentEOImpl.getDefinitionObject();
        //Find Creates the Key to find Department
        Key deptIdKey = DepartmentEOImpl.createPrimaryKey(new Integer(deptId));
        //Find the Department entity using deptId
        DepartmentEOImpl deptEOImpl = (DepartmentEOImpl)deptEODef.findByPrimaryKey(getDBTransaction(), deptIdKey);
        //Access Employees for this departament using association accessor getEmpEO() generated on DepartmentEOImpl class
        RowIterator rowIter = DepartmentEOImpl.getEmpEO();
        while (rowIter.hasNext()) {
            Row row = rowIter.next();
            //Row represent Emp entity instance
            //Business logic goes here
        }
    }