synapse-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kim Horn" <kim.h...@icsglobal.net>
Subject RE: Class Mediator Exception after task schedule
Date Fri, 27 Mar 2009 04:53:35 GMT
Thanks, for that. I have no issue using "new" to create a map; was
really asking about the <send> code.
Someone previously volunteered to create a java class to do a task proxy
send, so they thought it was a good approach; lost track who. So given I
have a message and headers now, any example code to do the send in the
Java would be very helpful.

Re
> "Yes.. but its like going out around and coming back in :)"

But the 
<in>
	<send>
<in> 
Is doing it anyhow conceptually,  I know not internally. 

All I really want to do is schedule a <sequence> every 15 minutes. I
have no need in the task to call Java; but I am forced to go this low
level, Why ? Synapse allows a sequence to contain Java calls. So why not
let the sequence call the Java, if I do need to just schedule Java code.
But to me Synapse is not about scheduling Java code but about higher
level stuff, <sequences>.  It appears this was a quick way to get Quartz
timers happening in Synapse; let them code Java and not scripting in
Synapse configuration language, Groovy, Javascript, XML etc.

It seem to me scheduling a <sequence> is the right and conceptually
clean approach in Synapse for all tasks. This is the use case for tasks.
Not low level Java Quartz stuff triggering Java code. Can someone
provide an example where scheduling a sequence would not work ?

Cut and paste From the Jeff Davis's book on Open SOA 

<task class="org.apache.synapse.startup.tasks.MessageInjector" #1
name="FetchOrders">
<property name="to" #2
value="http://localhost:8280/soap/QueuedOrderRequestor"/>
<property name="soapAction" value="urn:getOrders"/>
<property name="message"> 
<getOrders xmlns="uri:opensoa.chapter10.order">
<customerId>1001</customerId>
</getOrders>
</property>
<trigger interval="30"/> 
</task>
<in> 
<send/>
</in>
<proxy name="QueuedOrderRequestor" transports="http"> 
<target>
<endpoint>
<address uri="http://localhost:8280/soap/CustomerOrderQueueService"
format="soap11"/>
</endpoint>
</target>
</proxy>

To me the fact that the above works is not obvious at all and suggests
using side effects of a system. To work out
how the above works, what is doing the 2 sends ? There is the proxy
message send then the send to the endpoint....
Just seem really strange code to me; strange in that it does not
represent what is going on. Therefore will
End up producing a maintenance nightmaire. Computer languages should
express things clearly.

He really wants a sequence that's <sends> to this URI, every 30 seconds.
It's the same requirement as mine.
Same as example 300. Schedule a sequence that sends the message. This
example should have  the <filter>
Code added.

As suggested elsewhere the code above is an example of an Open Proxy ...
Oops introduced a maintenance/security issue.
But the example suggest the way other people are thinking about clean
"conceptual" ways to use tasks ... 

Thanks
Kim



-----Original Message-----
From: Asankha Perera [mailto:asankha.apache@gmail.com] On Behalf Of
Asankha C. Perera
Sent: Friday, 27 March 2009 2:40 PM
To: dev@synapse.apache.org
Subject: Re: Class Mediator Exception after task schedule

Hi Kim
> Are there any examples of code where I could do the send of the
message in the
> Java task code; create a new messageInjectorSenderMediator ? 
> So add the transport info then do the send.
>   
Hope this helps:

                Axis2MessageContext axis2smc = (Axis2MessageContext)
synCtx;
                org.apache.axis2.context.MessageContext axis2MessageCtx
=
                        axis2smc.getAxis2MessageContext();
                Object headers = axis2MessageCtx.getProperty(
                        
org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);

                if (headers != null && headers instanceof Map) {
                    Map headersMap = (HashMap) headers;
                    headersMap.put(name, resultValue); // <== adding a 
transport header
                }
                if (headers == null) {
                    Map headersMap = new HashMap();
                    headersMap.put(name, resultValue); // <== adding a 
transport header
                    axis2MessageCtx.setProperty(
                            
org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS,
                            headersMap);
                }
> If I send this to a Synapse Proxy then the real sequence is out of
Quartz scope.
>   
Yes.. but its like going out around and coming back in :)

cheers
asankha

-- 
Asankha C. Perera
AdroitLogic, http://adroitlogic.org

http://esbmagic.blogspot.com





---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@synapse.apache.org
For additional commands, e-mail: dev-help@synapse.apache.org


Mime
View raw message