Remsy
We are looking at that right now, but the usual pattern is to specify a
filter in the main sequence:
For example:
<task class="org.apache.synapse.startup.tasks.MessageInjector"
name="test-task">
<property name="to" value="urn:something"/>
<property name="message">
<m0:test xmlns:m0="http://services.samples/xsd"/>
</property>
<trigger interval="5"/>
</task>
<sequence name="main">
<!-- find the newly injected messages -->
<filter source="get-property('To')" regex="urn:something">
<sequence key="sequence-to-call"/>
</filter>
</sequence>
</definitions>
Schmilinsky, Remsy wrote:
> Hi. How can I specify a proxy address for a task ? I created a simple task,
> but it just calls the main sequence instead of the proxy URL passed in the
> "to" parameter.
>
> For instance, I want to choose the proxy service for the task, each proxy has
> a different sequence. It just keeps calling the main sequence...
>
> Here is the task class I created:
>
> import org.apache.axis2.addressing.EndpointReference;
> import org.apache.commons.logging.Log;
> import org.apache.commons.logging.LogFactory;
> import org.apache.synapse.ManagedLifecycle;
> import org.apache.synapse.MessageContext;
> import org.apache.synapse.core.SynapseEnvironment;
> import org.apache.synapse.startup.Task;
> import org.apache.synapse.util.PayloadHelper;
>
> /**
> * Injects a Message in to the Synapse environment
> */
> public class MessageInjector implements Task, ManagedLifecycle {
>
> /**
> * Holds the logger for logging purposes
> */
> private Log log = LogFactory.getLog(MessageInjector.class);
>
> /**
> * Holds the to address for the message to be injected
> */
> private String to = null;
>
> /**
> * Holds the SynapseEnv to which the message will be injected
> */
> private SynapseEnvironment synapseEnvironment;
>
> /**
> * Initializes the Injector
> *
> * @param se
> * SynapseEnvironment of synapse
> */
> public void init(SynapseEnvironment se) {
> synapseEnvironment = se;
> }
>
> /**
> * Set the to address of the message to be injected
> *
> * @param url
> * String containing the to address
> */
> public void setTo(String url) {
> to = url;
> }
>
> /**
> * This will be invoked by the schedular to inject the message
> * in to the SynapseEnvironment
> */
> public void execute() {
> String message = "Hello world !";
>
> log.debug("execute");
> if (synapseEnvironment == null) {
> log.error("Synapse Environment not set");
> return;
> }
> if (message == null) {
> log.error("message not set");
> return;
>
> }
> if (to == null) {
> log.error("to address not set");
> return;
>
> }
>
> MessageContext mc = synapseEnvironment.createMessageContext();
> mc.setTo(new EndpointReference(to));
> PayloadHelper.setTextPayload(mc, message);
> synapseEnvironment.injectMessage(mc);
>
> }
>
> /**
> * Destroys the Injector
> */
> public void destroy() {
> }
> }
>
> Here is the config file:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <syn:definitions xmlns:syn="http://ws.apache.org/ns/synapse">
> <syn:registry provider="org.wso2.esb.registry.ESBRegistry">
> <syn:parameter name="root">file:registry</syn:parameter>
> <syn:parameter name="cachableDuration">15000</syn:parameter>
> </syn:registry>
> <syn:proxy name="AnotherProxy" transports="http" startOnLoad="true"
> statistics="enable" trace="enable">
> <syn:target inSequence="main2">
> <syn:endpoint>
> <syn:address uri="vfs:file:///home/remsy/test/out"/>
> </syn:endpoint>
> <syn:outSequence>
> <syn:send>
> <syn:endpoint>
> <syn:address uri="vfs:file:///home/remsy/test/out"/>
> </syn:endpoint>
> </syn:send>
> </syn:outSequence>
> </syn:target>
> </syn:proxy>
> <syn:proxy name="Transformer" transports="http vfs" startOnLoad="true"
> statistics="enable" trace="enable">
> <syn:target inSequence="main">
> <syn:endpoint>
> <syn:address uri="vfs:file:///home/remsy/test/out"/>
> </syn:endpoint>
> <syn:outSequence>
> <syn:send>
> <syn:endpoint>
> <syn:address uri="vfs:file:///home/remsy/test/out"/>
> </syn:endpoint>
> </syn:send>
> </syn:outSequence>
> </syn:target>
> <syn:parameter
> name="transport.vfs.ContentType">text/plain</syn:parameter>
> <syn:parameter
> name="transport.vfs.ActionAfterFailure">MOVE</syn:parameter>
> <syn:parameter
> name="transport.vfs.MoveAfterProcess">file:///home/remsy/test/original</syn:parameter>
> <syn:parameter
> name="transport.vfs.MoveAfterFailure">file:///home/remsy/test/original</syn:parameter>
> <syn:parameter
> name="transport.vfs.ActionAfterProcess">MOVE</syn:parameter>
> <syn:parameter
> name="transport.vfs.FileNamePattern">.*\.txt</syn:parameter>
> <syn:parameter
> name="transport.vfs.FileURI">file:///home/remsy/test/in</syn:parameter>
> <syn:parameter name="transport.PollInterval">15</syn:parameter>
> </syn:proxy>
> <syn:sequence statistics="enable" name="main" trace="enable">
> <syn:log level="full" separator=","/>
> <syn:class name="MediatorTest"/>
> </syn:sequence>
> <syn:sequence name="fault">
> <syn:log level="full">
> <syn:property name="MESSAGE" value="Executing default
> "fault" sequence"/>
> <syn:property name="ERROR_CODE"
> expression="get-property('ERROR_CODE')"/>
> <syn:property name="ERROR_MESSAGE"
> expression="get-property('ERROR_MESSAGE')"/>
> </syn:log>
> <syn:drop/>
> </syn:sequence>
> <syn:sequence statistics="enable" name="main2" trace="enable">
> <syn:log level="full" separator=","/>
> </syn:sequence>
> <syn:task name="TestInjector" class="MessageInjector">
> <syn:trigger once="true"/>
> <syn:property name="to"
> value="http://localhost:8280/soap/AnotherProxy"/>
> </syn:task>
> </syn:definitions>
>
> thanks
>
> Remsy
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Behalf Of Paul Fremantle
> Sent: September 18, 2008 11:50 AM
> To: [email protected]
> Subject: Re: [esb-java-user] MQ series message listener
>
>
> Yes, Indika has got this working.
>
> Indika - can you please post some instructions?
>
> Thanks
> Paul
>
> Schmilinsky, Remsy wrote:
>> Hi. Esb uses Active MQ for message listening, is it possible to adapt it for
>> IBM MQ ? Our current infrastructure only supports this method.
>>
>> thanks
>>
>> Remsy
>>
>> _______________________________________________
>> Esb-java-user mailing list
>> [email protected]
>> http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-user
>>
>
--
Paul Fremantle
CTO and Co-Founder, WSO2
OASIS WS-RX TC Co-chair
VP, Apache Synapse
Office: +44 844 484 8143
Cell: +44 798 447 4618
blog: http://pzf.fremantle.org
[EMAIL PROTECTED]
"Oxygenating the Web Service Platform", www.wso2.com
_______________________________________________
Esb-java-user mailing list
[email protected]
http://mailman.wso2.org/cgi-bin/mailman/listinfo/esb-java-user