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 Thu, 26 Mar 2009 23:01:33 GMT
Thanks, for that, thought may be the case. 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.
If I send this to a Synapse Proxy then the real sequence is out of Quartz scope.

Kim

-----Original Message-----
From: Andreas Veithen [mailto:andreas.veithen@gmail.com] 
Sent: Friday, 27 March 2009 9:50 AM
To: dev@synapse.apache.org
Subject: Re: Class Mediator Exception after task schedule

In a proxy service, the transport headers are set by the incoming
transport. If you use the message injector then there is no incoming
transport and the transport headers are not set [1]. Therefore the
solution is straightforward: if the TRANSPORT_HEADERS property is
null, you need to create a new HashMap and initialize the
TRANSPORT_HEADERS property with this object.

Andreas

[1] Note that this would also be the case for a transport that has no
concept of "header".

On Thu, Mar 26, 2009 at 23:38, Kim Horn <kim.horn@icsglobal.net> wrote:
> In normal use within a proxy/ <in> sequence this code, CreateBasicAuthMediator,
works fine when called in a sequence.. From the debug statement the only line left not executed
is, line 66:
>
> map.put("Authorization", "Basic " + (String)Base64.encode(sAuth.getBytes()));
>
> Need to wrap this in try-catch; but I guess there is no map, as no TRANSPORTHEADER.
> I'l catch that too. I will check this.
>
> So no idea why map is null ?
> So how do I do a send from this sequence then ? This is my ultimate goal, this code was
removed
> from after the java call to simplify the problem example.
>
> What got me was the Quartz Error, before the stack trace. This seems strange design that
I am still in the Quartz task within a new sequence ?
>
> To me the Synapse tasks are still really weird and do not fit in well with Synapse. The
link between sequences, proxies and tasks needs to be at higher level. However, Low level
java tasks are also required. Synapse should be able to
> Schedule proxies and sequences at a higher semantic level, than the "magic" code used
now. These should be not
> In the scope of the quartz task. Even in Jeff Davis' book Tasks seem to work by magic
and the underlying mechanism of sending the message, is inexplicable.
>
>
> Thanks
> Kim
>
>
>
> -----Original Message-----
> From: Andreas Veithen [mailto:andreas.veithen@gmail.com]
> Sent: Thursday, 26 March 2009 7:58 PM
> To: dev@synapse.apache.org
> Subject: Re: Class Mediator Exception after task schedule
>
> Kim,
>
> The logs show a NullPointerException at line 66 in
> CreateBasicAuthMediator. Can you please identify the instruction on
> that line?
>
> Andreas
>
> On Thu, Mar 26, 2009 at 08:42, kimhorn <kim.horn@icsglobal.net> wrote:
>>
>> Why is this happening; Tasks are so weird.
>>
>> http://www.nabble.com/file/p22717175/log.txt log.txt
>>
>> org.apache.synapse.SynapseException: Error occured in the mediation of the
>> class mediator.
>>
>> Log is attached. The class works perfectly when called in other scripts.
>>
>>
>> Script is:
>> ----------
>> <definitions xmlns="http://ws.apache.org/ns/synapse">
>>  <task class="org.apache.synapse.startup.tasks.MessageInjector"
>> name="GetGuid">
>>    <property name="to" value="urn:doQuery"/>
>>    <property name="message">
>>      <doNothing/>
>>    </property>
>>    <trigger interval="30"/>
>>  </task>
>>  <in>
>>    <log level="full"/>
>>    <filter source="get-property('To')" regex="urn:doQuery">
>>      <then sequence="processStuff"/>
>>    </filter>
>>  </in>
>>  <out>
>>    <send/>
>>  </out>
>>  <sequence name="processStuff">
>>    <log level="custom">
>>      <property name="MSG" value="&gt;&gt;&gt;&gt;&gt;&gt;&gt;
Submit
>> STUFF"/>
>>    </log>
>>    <property name="Username" value="username"/>
>>    <property name="Password" value="password"/>
>>    <class name="net.icsglobal.thelma.synapse.CreateBasicAuthMediator"/>
>>  </sequence>
>> </definitions>
>>
>> CLASS is
>> ---------
>> public class CreateBasicAuthMediator implements Mediator {
>>        private static final Log log =
>> LogFactory.getLog(CreateBasicAuthMediator.class);
>>        private String reqUsername = null;
>>        private String reqPassword = null;
>>
>>        public int getTraceState() {
>>                return 0;
>>        }
>>
>>        public void setTraceState(int traceState) {
>>                traceState = 0;
>>        }
>>
>>        public String getType() {
>>                return this.getClass().getName();
>>        }
>>
>>        public boolean mediate(MessageContext synCtx) {
>>
>>                log.debug("CreateBasicAuthMediator: Create Auth Header Started...");
>>
>>                reqUsername = (String) synCtx.getProperty("Username");
>>                reqPassword = (String) synCtx.getProperty("Password");
>>
>>                if (reqUsername == null) {
>>                        log.debug("CreateBasicAuthMediator: ERROR: No
UserName...");
>>                        throw new SynapseException("Username property
MUST be provided!");
>>                }
>>
>>                if (reqPassword == null) {
>>                        log.debug("CreateBasicAuthMediator: ERROR: No
Password...");
>>                        throw new SynapseException("Password property
MUST be provided!");
>>                }
>>
>>                log.debug("CreateBasicAuthMediator: Creating Auth String...");
>>
>>                String sAuth = reqUsername + ":" + reqPassword;
>>
>>                log.debug("CreateBasicAuthMediator: Done String...");
>>
>>                //      Extract authentication headers
>>                org.apache.axis2.context.MessageContext mc = ((Axis2MessageContext)
>> synCtx).getAxis2MessageContext();
>>                Map map = (Map)
>> mc.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
>>                log.debug("CreateBasicAuthMediator: Got Map...");
>>
>>                // Set the authentication headers
>>                map.put("Authorization", "Basic " + (String)
>> Base64.encode(sAuth.getBytes()));
>>
>>                log.debug("CreateBasicAuthMediator: Auth Created succeeded!");
>>
>>                return true;
>>        }
>>
>> }
>>
>>
>>
>>
>> --
>> View this message in context: http://www.nabble.com/Class-Mediator-Exception-after-task-schedule-tp22717175p22717175.html
>> Sent from the Synapse - Dev mailing list archive at Nabble.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
>
>
> ---------------------------------------------------------------------
> 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


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


Mime
View raw message