Can we use multiple ObjectDB property files? - ipaf

Can we use multiple ObjectDB property files in pace automation framework ?

YES, This is new feature available in PAF 4.4.0 where we can define and use multiple object DBproperty files.
Example: (ObjectDB File configuration at flow level)
<flow id="flow1" objectDBName="objectDBFile1"></flow>
Example: (ObjectDB File configuration at activity level)
<flow id="flow1">
<call activity="activity1" xml="activity_xml_path"
objectDBName="objectDBFile1"></call>
<call activity="activity2" xml="activity_xml_path"
objectDBName="objectDBFile2"></call>
</flow>

Related

How can I get spring property in flow?

I work with Mule. And I have spring bean
<spring:bean id="`MyPropertiesSaver`" name="MyPropertiesSaver" class="MyPropertiesSaver">
<spring:property name="prop_name" value="${PROP_VALUE}"/>
</spring:bean>
Also I work with file in flow
<flow name="Handler" doc:name="Handler">
<file:inbound-endpoint `path="${PROP_VALUE}"` moveToPattern="#[header:originalFilename].txt" responseTimeout="10000" doc:name="File"/>
...
</flow>
So I get PROP_VALUE from system variables. I want to change path of file while programm is running. I change prop_name of class MyPropertiesSaver using MX4J. But path="${PROP_VALUE}" does not change. That's why I want to get prop_name from MyPropertiesSaver. Somthing like this
path="MyPropertiesSaver.prop_name"
How can I do that?
You need to extend the file message receiver to allow to externally set of the fileDir and disconnect-connect when this happens. Then in your connector use a service-override to use that customised message receiver.
Having a Dynamic Endpoint for File Inbound is not possible.
File Inbound should know where to look for when the flow is started.
If your usecase demands a dynamic file location and reading you can try the workaround with Mule Requester module.
Read throubh the following link for more details.
Unable to create dynamic file inbound endpoint in mule
Hope this helps.

read message from queue/topic in mule

I want to implement a consumer kind behaviour using Mule, ActiveMQ which can read JMS messages....there is some third party queue/topic. need to subscribe to them and start listening. How can I achieve that in mule?
Follow the instructions in this blog post to get a working connector. If you are using JMS1.1 you don't even need to specify queue or topic, they will behave the same. If you are using 1.0b, please make sure you specify the correct type.
Then, instead of using an outbound endpoint use an inbound endpoint:
<jms:inbound-endpoint topic="myTopic" connector-ref="Active_MQ" />
I do, however, recommend to use Anypoint Studio, that will provide you a very simple interface for this kind of configurations.
To read a message from activemq queue ot topic, can simply put in your flow for example:
<flow name="insert-operation" doc:name="insert-operation" doc:description="">
<jms:inbound-endpoint connector-ref="Active_MQ" exchange-pattern="request-response" queue="insert-jms" doc:name="JMS">
<idempotent-redelivery-policy idExpression="#[message.inboundProperties['JMSMessageID']]" />
<xa-transaction action="ALWAYS_BEGIN" />
</jms:inbound-endpoint>
...
</flow>

Simple axis2.xml for Axis2 embedded in webapp

I am developing a webapp with an embedded webservice with Axis2 using Maven.
The service implementation is a POJO with RPC-style interaction, the target appserver is Tomcat running the Axis2 servlet.
The "Hello world" works but now I need to configure some global axis2 settings in the axis2.xml file (placed under WEB-INF/conf).
Please provide or point to a simple configuration for axis2.xml for this common environment.
The default taken from the binary distribution has too many features activated (hotdeploy?) and also causes this problem:
<soapenv:Reason>
<soapenv:Text xml:lang="en-US">
The ServiceClass object does not implement the required method
in the following form: OMElement ping(OMElement e)
</soapenv:Text>
</soapenv:Reason>
As a reference: http://axis.apache.org/axis2/java/core/docs/servlet-transport.html says to configure the servlet transport in this way, but it does not solve the issue.
<transportReceiver name="http" class="org.apache.axis2.transport.http.AxisServletListener"/>
Apparently the problem is that the default axis2.xml sets raw xml messageReceivers, instead of the RPC ones.
Try to add this to the services.xml for the developed service, should fix the problem.
<messageReceivers>
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-only"
class="org.apache.axis2.rpc.receivers.RPCInOnlyMessageReceiver" />
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out"
class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</messageReceivers>
"Solution that worked for me was adding the operation tag in the service.xml against the Java Service method name:
<operation name="sayHello" >
<messageReceiver mep="http://www.w3.org/2004/08/wsdl/in-out" class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" />
</operation>
<parameter name="ServiceClass" locked="false">com.learning.webservices.pojo.HelloService</parameter>

mule jms connector

I am new to Mule and JMS. Just trying to figure out how to add a JMS end-point with a connector. Is there any JMS implementation provided by Mule or do I need to use an external JMS provider.
A simple example will be :-
<jms:activemq-connector name="Active_MQ" brokerURL="tcp://localhost:61616" validateConnections="true" doc:name="Active MQ"/>
To send a message to a queue :-
<flow name="JmsSendFlow" doc:name="JmsSendFlow" >
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8082" path="mainData" doc:name="HTTP"/>
<set-payload value="Test Data" />
<jms:outbound-endpoint queue="StudioOUT" connector-ref="Active_MQ" doc:name="JMS"/>
</flow>
To receive message from the queue :-
<flow name="JmsReceiveFlow" doc:name="JmsReceiveFlow" >
<jms:inbound-endpoint queue="StudioOUT" connector-ref="Active_MQ1" exchange-pattern="one-way"/>
<logger message="Message received#[message.payload]" level="INFO" doc:name="Logger"/>
</flow>
For more information about JMS:-
http://blogs.mulesoft.com/dev/newbie/mule-school-jms-tutorial/
Here is the ActiveMQ usage guide for Mule JMS connector.
Mule ActiveMQ integration
http://www.mulesoft.org/documentation/display/MULE3USER/ActiveMQ+Integration
This should help.
Drag out another HTTP connector and drop it in the canvas to create a new flow.
Give the flow a new name of postTopicMessageFlow.
In the HTTP Properties view, set the connector configuration to the existing
HTTP_Listener_Configuration.
Set the path to /jms and the allowed methods to GET.
Drag out another JMS connector and drop it into the process section of the flow.
In the JMS Properties view, select topic and set it to jms connectivity.
Set the connector configuration to the existing Active_MQ.
If you see an Attribute ‘action’ is required warning, ignore it.
Add a Set Payload transformer between the HTTP and JMS connector endpoints.
In the Set Payload Properties view, change the display name to Set Message and set the value
to a message query parameter.
Add a breakpoint to the Set Payload transformer.
Add a Property transformer after the Set Payload transformer.
In the Properties view, change the display name to Set Name.
Select Set Property and set the name to name and the value to your name.
Note: You can set this to a query parameter instead if you prefer.
Save the file to redeploy the application and make a request to
http://localhost:8081/jms?message=Hello.
Look at the console;; you should see your name and message displayed – along with those of
your classmates.

Tomcat vs Jetty JNDI Lookup

I use Spring to configure my Java Web App and in my Spring configuration I obtain a datasource via JNDI for Jetty as follows:
<jee:jndi-lookup id="dataSource" jndi-name="jdbc/myDataSource" />
but this won't work with Tomcat. With Tomcat I have to do this:
<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/myDataSource" />
Whats the best way to solve this? I am already using JNDI as a way to externalize configuration, so I can't externalize my externalized configuration! At the same time I absolutely loath the idea of having two separate Spring configuration files. HELP!!!
I found an answer here, but I thought it was a bit complicated, but it did give me the idea to use the very cool ServerDetector class that blogger had found.
Once I can dynamically figure what type of server I am running in, I was able to use the Spring expression language to do the rest of the work:
<jee:jndi-lookup id="myAppDataSource"
jndi-name="#{ (AppServerType == 'Jetty' ? 'jdbc/' : 'java:comp/env/jdbc/') +
'myAppDataSource' }" />
Easy!
After some experimenting, I figured out I could just force Jetty to use the same JNDI path as Tomcat. The following snippet is from my jetty-env.xml file:
<New id="myDataSource" class="org.mortbay.jetty.plus.naming.Resource">
<!-- We MUST specify the entire JNDI path here to force compliance with the Tomcat/J2EE convention -->
<Arg>java:comp/env/jdbc/myDataSource</Arg>
<Arg>
<New class="com.atomikos.jdbc.nonxa.AtomikosNonXADataSourceBean">
<Set name="uniqueResourceName">sbeDatabase</Set>
...............
</New>
</Arg>
</New>
Not sure if this is ideal, but it works.
Update:
It works if you put your jetty-env.xml file inside the WAR...but for whatever reason, one you move this configuration outside the WAR and into a context fragment file in Jetty's "contexts" directory then it throws an exception:
Check it out: http://jira.codehaus.org/browse/JETTY-273
The cleanest way to do it is to configure your configuration. ;)
Use a Spring property place holder. See
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/beans.html#beans-factory-placeholderconfigurer
The basic idea is that you just put a placeholder in your spring config with a property, and then it reads matching property from a properties file. You generate the properties file in your build process. Ive seen it done where the build tool (ant) reads an environment variable and then creates a properties file appropriate for the environment based of a skeleton file populated with tokens.

Resources